Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
c8d69f1e
D
Docs
项目概览
OpenHarmony
/
Docs
大约 2 年 前同步成功
通知
161
Star
293
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
c8d69f1e
编写于
8月 25, 2023
作者:
W
wangjian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
I18n中ArkTs语法整改
Signed-off-by:
N
wangjian
<
wangjian497@huawei.com
>
上级
ffb524ca
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
5 addition
and
24 deletion
+5
-24
zh-cn/application-dev/reference/apis/js-apis-i18n.md
zh-cn/application-dev/reference/apis/js-apis-i18n.md
+5
-24
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-i18n.md
浏览文件 @
c8d69f1e
...
@@ -1123,10 +1123,7 @@ constructor(country: string, options?: PhoneNumberFormatOptions)
...
@@ -1123,10 +1123,7 @@ constructor(country: string, options?: PhoneNumberFormatOptions)
**示例:**
**示例:**
```
ts
```
ts
interface
PhoneNumberFormatOptions
{
let
option
:
I18n
.
PhoneNumberFormatOptions
=
{
type
:
"
E164
"
};
type
?:
string
;
}
let
option
:
PhoneNumberFormatOptions
=
{
type
:
"
E164
"
};
let
phoneNumberFormat
:
I18n
.
PhoneNumberFormat
=
new
I18n
.
PhoneNumberFormat
(
"
CN
"
,
option
);
let
phoneNumberFormat
:
I18n
.
PhoneNumberFormat
=
new
I18n
.
PhoneNumberFormat
(
"
CN
"
,
option
);
```
```
...
@@ -2210,12 +2207,8 @@ static unitConvert(fromUnit: UnitInfo, toUnit: UnitInfo, value: number, locale:
...
@@ -2210,12 +2207,8 @@ static unitConvert(fromUnit: UnitInfo, toUnit: UnitInfo, value: number, locale:
**示例:**
**示例:**
```
ts
```
ts
interface
UnitInfo
{
let
fromUnit
:
I18n
.
UnitInfo
=
{
unit
:
"
cup
"
,
measureSystem
:
"
US
"
};
unit
:
string
;
let
toUnit
:
I18n
.
UnitInfo
=
{
unit
:
"
liter
"
,
measureSystem
:
"
SI
"
};
measureSystem
:
string
;
}
let
fromUnit
:
UnitInfo
=
{
unit
:
"
cup
"
,
measureSystem
:
"
US
"
};
let
toUnit
:
UnitInfo
=
{
unit
:
"
liter
"
,
measureSystem
:
"
SI
"
};
let
res
:
string
=
I18n
.
I18NUtil
.
unitConvert
(
fromUnit
,
toUnit
,
1000
,
"
en-US
"
,
"
long
"
);
// res = 236.588 liters
let
res
:
string
=
I18n
.
I18NUtil
.
unitConvert
(
fromUnit
,
toUnit
,
1000
,
"
en-US
"
,
"
long
"
);
// res = 236.588 liters
```
```
...
@@ -2369,16 +2362,10 @@ getLanguageInfoArray(languages: Array<string>, options?: SortOptions): Arr
...
@@ -2369,16 +2362,10 @@ getLanguageInfoArray(languages: Array<string>, options?: SortOptions): Arr
```
ts
```
ts
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
interface
SortOptions
{
locale
?:
string
;
isUseLocalName
?:
boolean
;
isSuggestedFirst
?:
boolean
;
}
// 当系统语言为zh-Hans,系统地区为CN,系统Locale为zh-Hans-CN时
// 当系统语言为zh-Hans,系统地区为CN,系统Locale为zh-Hans-CN时
let
systemLocaleManager
:
I18n
.
SystemLocaleManager
=
new
I18n
.
SystemLocaleManager
();
let
systemLocaleManager
:
I18n
.
SystemLocaleManager
=
new
I18n
.
SystemLocaleManager
();
let
languages
:
string
[]
=
[
"
zh-Hans
"
,
"
en-US
"
,
"
pt
"
,
"
ar
"
];
let
languages
:
string
[]
=
[
"
zh-Hans
"
,
"
en-US
"
,
"
pt
"
,
"
ar
"
];
let
sortOptions
:
SortOptions
=
{
locale
:
"
zh-Hans-CN
"
,
isUseLocalName
:
true
,
isSuggestedFirst
:
true
};
let
sortOptions
:
I18n
.
SortOptions
=
{
locale
:
"
zh-Hans-CN
"
,
isUseLocalName
:
true
,
isSuggestedFirst
:
true
};
try
{
try
{
// 排序后的语言顺序为: [zh-Hans, en-US, pt, ar]
// 排序后的语言顺序为: [zh-Hans, en-US, pt, ar]
let
sortedLanguages
:
Array
<
I18n
.
LocaleItem
>
=
systemLocaleManager
.
getLanguageInfoArray
(
languages
,
sortOptions
);
let
sortedLanguages
:
Array
<
I18n
.
LocaleItem
>
=
systemLocaleManager
.
getLanguageInfoArray
(
languages
,
sortOptions
);
...
@@ -2424,16 +2411,10 @@ getRegionInfoArray(regions: Array<string>, options?: SortOptions): Array&l
...
@@ -2424,16 +2411,10 @@ getRegionInfoArray(regions: Array<string>, options?: SortOptions): Array&l
```
ts
```
ts
import
{
BusinessError
}
from
'
@ohos.base
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
interface
SortOptions
{
locale
?:
string
;
isUseLocalName
?:
boolean
;
isSuggestedFirst
?:
boolean
;
}
// 当系统语言为zh-Hans,系统地区为CN,系统Locale为zh-Hans-CN时
// 当系统语言为zh-Hans,系统地区为CN,系统Locale为zh-Hans-CN时
let
systemLocaleManager
:
I18n
.
SystemLocaleManager
=
new
I18n
.
SystemLocaleManager
();
let
systemLocaleManager
:
I18n
.
SystemLocaleManager
=
new
I18n
.
SystemLocaleManager
();
let
regions
:
string
[]
=
[
"
CN
"
,
"
US
"
,
"
PT
"
,
"
EG
"
];
let
regions
:
string
[]
=
[
"
CN
"
,
"
US
"
,
"
PT
"
,
"
EG
"
];
let
sortOptions
:
SortOptions
=
{
locale
:
"
zh-Hans-CN
"
,
isUseLocalName
:
false
,
isSuggestedFirst
:
true
};
let
sortOptions
:
I18n
.
SortOptions
=
{
locale
:
"
zh-Hans-CN
"
,
isUseLocalName
:
false
,
isSuggestedFirst
:
true
};
try
{
try
{
// 排序后的地区顺序为: [CN, EG, US, PT]
// 排序后的地区顺序为: [CN, EG, US, PT]
let
sortedRegions
:
Array
<
I18n
.
LocaleItem
>
=
systemLocaleManager
.
getRegionInfoArray
(
regions
,
sortOptions
);
let
sortedRegions
:
Array
<
I18n
.
LocaleItem
>
=
systemLocaleManager
.
getRegionInfoArray
(
regions
,
sortOptions
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录