提交 5ddf1982 编写于 作者: S sunyaozu

complement intl and i18n api document

Signed-off-by: Nsunyaozu <sunyaozu@huawei.com>
上级 fa9ed42f
......@@ -111,6 +111,63 @@ getSystemLanguage(): string
```
## i18n.setSystemLanguage
setSystemLanguage(): boolean
设置系统语言。
**系统能力**:SystemCapability.Global.I18n
- 返回值:
| 类型 | 说明 |
| -------- | -------- |
| boolean | 返回true,表示系统语言设置成功;返回false,表示系统语言设置失败。 |
- 示例:
```
i18n.setSystemLanguage();
```
## i18n.getSystemLanguages
getSystemLanguages(): Array<string>
获取系统支持的语言列表。
**系统能力**:SystemCapability.Global.I18n
- 返回值:
| 类型 | 说明 |
| -------- | -------- |
| Array<string> | 系统支持的语言ID列表。 |
- 示例:
```
i18n.getSystemLanguages();
```
## i18n.getSystemCountries
getSystemCountries(): Array<string>
获取系统支持的区域列表。
**系统能力**:SystemCapability.Global.I18n
- 返回值:
| 类型 | 说明 |
| -------- | -------- |
| Array<string> | 系统支持的区域ID列表。 |
- 示例:
```
i18n.getSystemCountries();
```
## i18n.getSystemRegion
getSystemRegion(): string
......@@ -130,6 +187,25 @@ getSystemRegion(): string
```
## i18n.setSystemRegion
setSystemRegion(): boolean
设置系统区域。
**系统能力**:SystemCapability.Global.I18n
- 返回值:
| 类型 | 说明 |
| -------- | -------- |
| boolean | 返回true,表示系统区域设置成功;返回false,表示系统区域设置失败。 |
- 示例:
```
i18n.setSystemRegion();
```
## i18n.getSystemLocale
getSystemLocale(): string
......@@ -149,6 +225,55 @@ getSystemLocale(): string
```
## i18n.setSystemLocale
setSystemLocale(locale: string): boolean
设置系统Locale。
**系统能力**:SystemCapability.Global.I18n
- 参数:
| 参数名 | 类型 | 说明 |
| -------- | -------- | -------- |
| locale | string | 指定区域ID,例如zh-CN。 |
- 返回值:
| 类型 | 说明 |
| -------- | -------- |
| boolean | 返回true,表示系统Locale设置成功;返回false,表示系统Locale设置失败。 |
- 示例:
```
i18n.setSystemLocale('zh-CN');
```
## i18n.isSuggested
isSuggested(language: string, region?: string): boolean
判断当前语言和区域是否匹配。
**系统能力**:SystemCapability.Global.I18n
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| language | string | 是 | 合法的语言ID,例如zh。 |
| region | string | 否 | 合法的地区ID,例如CN |
- 返回值:
| 类型 | 说明 |
| -------- | -------- |
| boolean | 返回true,表示当前语言和地区匹配;返回false,表示当前语言和地区不匹配。 |
- 示例:
```
i18n.isSuggested('zh', 'CN');
```
## i18n.getCalendar<sup>8+</sup>
getCalendar(locale: string, type? : string): Calendar
......
......@@ -32,6 +32,20 @@ import Intl from '@ohos.intl';
| numeric | boolean | 是 | 否 | 是否对数字字符具有特殊的排序规则处理。<br/>**系统能力**:SystemCapability.Global.I18n |
### constructor
constructor()
创建区域对象
**系统能力**:SystemCapability.Global.I18n
- 示例:
```
var locale = new Intl.Locale();
```
### constructor
constructor(locale: string, options?: options)
......@@ -115,6 +129,20 @@ minimize(): Locale
## DateTimeFormat
### constructor
constructor()
创建时间日期格式化对象。
**系统能力**:SystemCapability.Global.I18n
- 示例:
```
var datefmt= new Intl.DateTimeFormat();
```
### constructor
constructor(locale: string, options?: DateTimeOptions)
......@@ -259,6 +287,20 @@ resolvedOptions(): DateTimeOptions
## NumberFormat
### constructor
constructor()
创建数字格式化对象。
**系统能力**:SystemCapability.Global.I18n
- 示例:
```
var numfmt = new Intl.NumberFormat();
```
### constructor
constructor(locale: string, options?: NumberOptions)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册