未验证 提交 44267a5f 编写于 作者: O openharmony_ci 提交者: Gitee

!2036 修改参数错误问题

Merge pull request !2036 from sunyaozu/master
...@@ -113,12 +113,17 @@ getSystemLanguage(): string ...@@ -113,12 +113,17 @@ getSystemLanguage(): string
## i18n.setSystemLanguage ## i18n.setSystemLanguage
setSystemLanguage(): boolean setSystemLanguage(language: string): boolean
设置系统语言。 设置系统语言。
**系统能力**:SystemCapability.Global.I18n **系统能力**:SystemCapability.Global.I18n
- 参数:
| 参数名 | 类型 | 说明 |
| -------- | -------- | -------- |
| language | string | 语言ID。 |
- 返回值: - 返回值:
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
...@@ -126,7 +131,7 @@ setSystemLanguage(): boolean ...@@ -126,7 +131,7 @@ setSystemLanguage(): boolean
- 示例: - 示例:
``` ```
i18n.setSystemLanguage(); i18n.setSystemLanguage('zh');
``` ```
...@@ -151,12 +156,17 @@ getSystemLanguages(): Array<string> ...@@ -151,12 +156,17 @@ getSystemLanguages(): Array<string>
## i18n.getSystemCountries ## i18n.getSystemCountries
getSystemCountries(): Array<string> getSystemCountries(language: string): Array<string>
获取系统支持的区域列表。 获取针对输入语言系统支持的区域列表。
**系统能力**:SystemCapability.Global.I18n **系统能力**:SystemCapability.Global.I18n
- 参数:
| 参数名 | 类型 | 说明 |
| -------- | -------- | -------- |
| language | string | 语言ID。 |
- 返回值: - 返回值:
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
...@@ -164,7 +174,7 @@ getSystemCountries(): Array<string> ...@@ -164,7 +174,7 @@ getSystemCountries(): Array<string>
- 示例: - 示例:
``` ```
i18n.getSystemCountries(); i18n.getSystemCountries('zh');
``` ```
...@@ -189,12 +199,17 @@ getSystemRegion(): string ...@@ -189,12 +199,17 @@ getSystemRegion(): string
## i18n.setSystemRegion ## i18n.setSystemRegion
setSystemRegion(): boolean setSystemRegion(region: string): boolean
设置系统区域。 设置系统区域。
**系统能力**:SystemCapability.Global.I18n **系统能力**:SystemCapability.Global.I18n
- 参数:
| 参数名 | 类型 | 说明 |
| -------- | -------- | -------- |
| region | string | 地区ID。 |
- 返回值: - 返回值:
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
...@@ -645,21 +660,23 @@ format(number: string): string ...@@ -645,21 +660,23 @@ format(number: string): string
表示电话号码格式化对象可设置的属性。 表示电话号码格式化对象可设置的属性。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Global.I18n
| 名称 | 参数类型 | 可读 | 可写 | 说明 | | 名称 | 参数类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| type | string | 是 | 是 | 表示对电话号码格式化的类型,取值范围:"E164",&nbsp;"INTERNATIONAL",&nbsp;"NATIONAL",&nbsp;"RFC3966"。<br/>**系统能力**:SystemCapability.Global.I18n | | type | string | 是 | 是 | 表示对电话号码格式化的类型,取值范围:"E164",&nbsp;"INTERNATIONAL",&nbsp;"NATIONAL",&nbsp;"RFC3966"。 |
## UnitInfo<sup>8+</sup> ## UnitInfo<sup>8+</sup>
度量衡单位信息。 度量衡单位信息。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Global.I18n
| 名称 | 参数类型 | 可读 | 可写 | 说明 | | 名称 | 参数类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| unit | string | 是 | 是 | 单位的名称,如:"meter",&nbsp;"inch",&nbsp;"cup"等。 | | unit | string | 是 | 是 | 单位的名称,如:"meter",&nbsp;"inch",&nbsp;"cup"等。 |
| measureSystem | string | 是 | 是 | 单位的度量体系,取值包括:"SI",&nbsp;"US",&nbsp;"UK"。<br/>**系统能力**:SystemCapability.Global.I18n | | measureSystem | string | 是 | 是 | 单位的度量体系,取值包括:"SI",&nbsp;"US",&nbsp;"UK"。 |
## Util<sup>8+</sup> ## Util<sup>8+</sup>
...@@ -695,7 +712,7 @@ unitConvert(fromUnit: UnitInfo, toUnit: UnitInfo, value: number, locale: string, ...@@ -695,7 +712,7 @@ unitConvert(fromUnit: UnitInfo, toUnit: UnitInfo, value: number, locale: string,
## getInstance<sup>8+</sup> ## getInstance<sup>8+</sup>
getInstance(): IndexUtil getInstance(locale?:string): IndexUtil
创建并返回IndexUtil对象。 创建并返回IndexUtil对象。
...@@ -742,7 +759,7 @@ getIndexList(): Array&lt;string&gt; ...@@ -742,7 +759,7 @@ getIndexList(): Array&lt;string&gt;
### addLocale<sup>8+</sup> ### addLocale<sup>8+</sup>
addLocale(locale: string) addLocale(locale: string): void
将新的locale对应的索引加入当前索引列表。 将新的locale对应的索引加入当前索引列表。
...@@ -1375,3 +1392,116 @@ getFirstPreferredLanguage(): string ...@@ -1375,3 +1392,116 @@ getFirstPreferredLanguage(): string
``` ```
var firstPreferredLanguage = i18n.getFirstPreferredLanguage(); var firstPreferredLanguage = i18n.getFirstPreferredLanguage();
``` ```
## i18n.getTimeZone<sup>8+</sup>
getTimeZone(zoneID?: string): TimeZone
获取时区ID对应的时区对象。
**系统能力**:SystemCapability.Global.I18n
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| zondID | string | 否 | 时区ID。 |
- 返回值:
| 类型 | 说明 |
| -------- | -------- |
| TimeZone | 时区ID对应的时区对象。 |
- 示例:
```
var timezone = i18n.getTimeZone();
```
## RelativeTimeFormat<sup>8+</sup>
### getID<sup>8+</sup>
getID(): string
获取时区对象的ID。
**系统能力**:SystemCapability.Global.I18n
- 返回值:
| 类型 | 说明 |
| -------- | -------- |
| string | 时区对象对应的时区ID。 |
- 示例:
```
var timezone = i18n.getTimeZone();
timezone.getID();
```
### getDisplayName<sup>8+</sup>
getDisplayName(locale?: string, isDST?: boolean): string
获取时区对象在指定区域的表示。
**系统能力**:SystemCapability.Global.I18n
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| locale | string | 否 | 区域ID。 |
| isDST | boolean | 否 | 表示获取时区对象的表示时是否考虑夏令时。 |
- 返回值:
| 类型 | 说明 |
| -------- | -------- |
| string | 时区对象在指定区域的表示。 |
- 示例:
```
var timezone = i18n.getTimeZone();
timezone.getDisplayName("zh-CN", false);
```
### getRawOffset<sup>8+</sup>
getRawOffset(): number
获取时区对象表示的时区与UTC时区的偏差。
**系统能力**:SystemCapability.Global.I18n
- 返回值:
| 类型 | 说明 |
| -------- | -------- |
| number | 时区对象表示的时区与UTC时区的偏差。 |
- 示例:
```
var timezone = i18n.getTimeZone();
timezone.getRawOffset();
```
### getOffset<sup>8+</sup>
getOffset(date?: number): number
获取某一时刻时区对象表示的时区与UTC时区的偏差。
**系统能力**:SystemCapability.Global.I18n
- 返回值:
| 类型 | 说明 |
| -------- | -------- |
| number | 某一时刻时区对象表示的时区与UTC时区的偏差。 |
- 示例:
```
var timezone = i18n.getTimeZone();
timezone.getOffset(1234567890);
```
\ No newline at end of file
...@@ -18,21 +18,23 @@ import Intl from '@ohos.intl'; ...@@ -18,21 +18,23 @@ import Intl from '@ohos.intl';
### 属性 ### 属性
**系统能力**:以下各项对应的系统能力均为SystemCapability.Global.I18n
| 名称 | 参数类型 | 可读 | 可写 | 说明 | | 名称 | 参数类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| language | string | 是 | 否 | 与区域设置关联的语,&nbsp;如:zh。<br/>**系统能力**:SystemCapability.Global.I18n | | language | string | 是 | 否 | 与区域设置关联的语,&nbsp;如:zh。 |
| script | string | 是 | 否 | 语言的书写方式,如:Hans。<br/>**系统能力**:SystemCapability.Global.I18n | | script | string | 是 | 否 | 语言的书写方式,如:Hans。 |
| region | string | 是 | 否 | 与区域设置相关的地区,如:CN。<br/>**系统能力**:SystemCapability.Global.I18n | | region | string | 是 | 否 | 与区域设置相关的地区,如:CN。 |
| baseName | string | 是 | 否 | Locale的基本核心信息(由语言脚本与地区组成),如:zh-Hans-CN。<br/>**系统能力**:SystemCapability.Global.I18n | | baseName | string | 是 | 否 | Locale的基本核心信息(由语言脚本与地区组成),如:zh-Hans-CN。 |
| caseFirst | string | 是 | 否 | 区域的整理规则是否考虑大小写,取值包括:"upper",&nbsp;"lower",&nbsp;"false"。<br/>**系统能力**:SystemCapability.Global.I18n | | caseFirst | string | 是 | 否 | 区域的整理规则是否考虑大小写,取值包括:"upper",&nbsp;"lower",&nbsp;"false"。 |
| calendar | string | 是 | 否 | 区域的日历信息,取值包括:"buddhist",&nbsp;"chinese",&nbsp;"coptic","dangi",&nbsp;"ethioaa",&nbsp;"ethiopic",&nbsp;"gregory",&nbsp;"hebrew",&nbsp;"indian",&nbsp;"islamic",&nbsp;"islamic-umalqura",&nbsp;"islamic-tbla",&nbsp;"islamic-civil",&nbsp;"islamic-rgsa",&nbsp;"iso8601",&nbsp;"japanese",&nbsp;"persian",&nbsp;"roc",&nbsp;"islamicc"。<br/>**系统能力**:SystemCapability.Global.I18n | | calendar | string | 是 | 否 | 区域的日历信息,取值包括:"buddhist",&nbsp;"chinese",&nbsp;"coptic","dangi",&nbsp;"ethioaa",&nbsp;"ethiopic",&nbsp;"gregory",&nbsp;"hebrew",&nbsp;"indian",&nbsp;"islamic",&nbsp;"islamic-umalqura",&nbsp;"islamic-tbla",&nbsp;"islamic-civil",&nbsp;"islamic-rgsa",&nbsp;"iso8601",&nbsp;"japanese",&nbsp;"persian",&nbsp;"roc",&nbsp;"islamicc"。 |
| collation | string | 是 | 否 | 区域的排序规则,取值包括:"big5han",&nbsp;"compat",&nbsp;"dict",&nbsp;"direct",&nbsp;"ducet",&nbsp;"eor",&nbsp;"gb2312",&nbsp;"phonebk",&nbsp;"phonetic",&nbsp;"pinyin",&nbsp;"reformed",&nbsp;"searchjl",&nbsp;"stroke",&nbsp;"trad",&nbsp;"unihan",&nbsp;"zhuyin"。<br/>**系统能力**:SystemCapability.Global.I18n | | collation | string | 是 | 否 | 区域的排序规则,取值包括:"big5han",&nbsp;"compat",&nbsp;"dict",&nbsp;"direct",&nbsp;"ducet",&nbsp;"eor",&nbsp;"gb2312",&nbsp;"phonebk",&nbsp;"phonetic",&nbsp;"pinyin",&nbsp;"reformed",&nbsp;"searchjl",&nbsp;"stroke",&nbsp;"trad",&nbsp;"unihan",&nbsp;"zhuyin"。 |
| hourCycle | string | 是 | 否 | 区域的时制信息,取值包括:"h12",&nbsp;"h23",&nbsp;"h11",&nbsp;"h24"。<br/>**系统能力**:SystemCapability.Global.I18n | | hourCycle | string | 是 | 否 | 区域的时制信息,取值包括:"h12",&nbsp;"h23",&nbsp;"h11",&nbsp;"h24"。 |
| numberingSystem | string | 是 | 否 | 区域使用的数字系统,取值包括:"adlm",&nbsp;"ahom",&nbsp;"arab",&nbsp;"arabext",&nbsp;"bali",&nbsp;"beng",&nbsp;"bhks",&nbsp;"brah",&nbsp;"cakm",&nbsp;"cham",&nbsp;"deva",&nbsp;"diak",&nbsp;"fullwide",&nbsp;"gong",&nbsp;"gonm",&nbsp;"gujr",&nbsp;"guru",&nbsp;"hanidec",&nbsp;"hmng",&nbsp;"hmnp",&nbsp;"java",&nbsp;"kali",&nbsp;"khmr",&nbsp;"knda",&nbsp;"lana",&nbsp;"lanatham",&nbsp;"laoo",&nbsp;"latn",&nbsp;"lepc",&nbsp;"limb",&nbsp;"mathbold",&nbsp;"mathdbl",&nbsp;"mathmono",&nbsp;"mathsanb",&nbsp;"mathsans",&nbsp;"mlym",&nbsp;"modi",&nbsp;"mong",&nbsp;"mroo",&nbsp;"mtei",&nbsp;"mymr",&nbsp;"mymrshan",&nbsp;"mymrtlng",&nbsp;"newa",&nbsp;"nkoo",&nbsp;"olck",&nbsp;"orya",&nbsp;"osma",&nbsp;"rohg",&nbsp;"saur",&nbsp;"segment",&nbsp;"shrd",&nbsp;"sind",&nbsp;"sinh",&nbsp;"sora",&nbsp;"sund",&nbsp;"takr",&nbsp;"talu",&nbsp;"tamldec",&nbsp;"telu",&nbsp;"thai",&nbsp;"tibt",&nbsp;"tirh",&nbsp;"vaii",&nbsp;"wara",&nbsp;"wcho"。<br/>**系统能力**:SystemCapability.Global.I18n | | numberingSystem | string | 是 | 否 | 区域使用的数字系统,取值包括:"adlm",&nbsp;"ahom",&nbsp;"arab",&nbsp;"arabext",&nbsp;"bali",&nbsp;"beng",&nbsp;"bhks",&nbsp;"brah",&nbsp;"cakm",&nbsp;"cham",&nbsp;"deva",&nbsp;"diak",&nbsp;"fullwide",&nbsp;"gong",&nbsp;"gonm",&nbsp;"gujr",&nbsp;"guru",&nbsp;"hanidec",&nbsp;"hmng",&nbsp;"hmnp",&nbsp;"java",&nbsp;"kali",&nbsp;"khmr",&nbsp;"knda",&nbsp;"lana",&nbsp;"lanatham",&nbsp;"laoo",&nbsp;"latn",&nbsp;"lepc",&nbsp;"limb",&nbsp;"mathbold",&nbsp;"mathdbl",&nbsp;"mathmono",&nbsp;"mathsanb",&nbsp;"mathsans",&nbsp;"mlym",&nbsp;"modi",&nbsp;"mong",&nbsp;"mroo",&nbsp;"mtei",&nbsp;"mymr",&nbsp;"mymrshan",&nbsp;"mymrtlng",&nbsp;"newa",&nbsp;"nkoo",&nbsp;"olck",&nbsp;"orya",&nbsp;"osma",&nbsp;"rohg",&nbsp;"saur",&nbsp;"segment",&nbsp;"shrd",&nbsp;"sind",&nbsp;"sinh",&nbsp;"sora",&nbsp;"sund",&nbsp;"takr",&nbsp;"talu",&nbsp;"tamldec",&nbsp;"telu",&nbsp;"thai",&nbsp;"tibt",&nbsp;"tirh",&nbsp;"vaii",&nbsp;"wara",&nbsp;"wcho"。 |
| numeric | boolean | 是 | 否 | 是否对数字字符具有特殊的排序规则处理。<br/>**系统能力**:SystemCapability.Global.I18n | | numeric | boolean | 是 | 否 | 是否对数字字符具有特殊的排序规则处理。 |
### constructor ### constructor<sup>8+</sup>
constructor() constructor()
...@@ -48,7 +50,7 @@ constructor() ...@@ -48,7 +50,7 @@ constructor()
### constructor ### constructor
constructor(locale: string, options?: options) constructor(locale: string, options?: LocaleOptions)
创建区域对象 创建区域对象
...@@ -58,7 +60,7 @@ constructor(locale: string, options?: options) ...@@ -58,7 +60,7 @@ constructor(locale: string, options?: options)
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| locale | string | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | | locale | string | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 |
| options | options | 否 | 用于创建区域对象的选项。 | | options | LocaleOptions | 否 | 用于创建区域对象的选项。 |
- 示例: - 示例:
``` ```
...@@ -126,10 +128,26 @@ minimize(): Locale ...@@ -126,10 +128,26 @@ minimize(): Locale
``` ```
## LocaleOptions
表示区域初始化选项。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Global.I18n
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| calendar | string | 是 | 是 | 日历参数,如:"buddhist", "chinese", "coptic", "dangi", "ethioaa", "ethiopic", "gregory", "hebrew", "indian", "islamic", "islamic-umalqura", "islamic-tbla", "islamic-civil", "islamic-rgsa", "iso8601", "japanese", "persian", "roc", "islamicc"。 |
| collation | string | 是 | 是 | 排序参数,取值包括:"big5han", "compat", "dict", "direct", "ducet", "emoji", "eor", "gb2312", "phonebk", "phonetic", "pinyin", "reformed ", "search", "searchjl", "standard", "stroke", "trad", "unihan", "zhuyin"。 |
| hourCycle | string | 是 | 是 | 时制格式,取值包括:"h11",&nbsp;"h12",&nbsp;"h23",&nbsp;"h24"。 |
| numberingSystem | string | 是 | 是 | 数字系统,取值包括:"adlm",&nbsp;"ahom",&nbsp;"arab",&nbsp;"arabext",&nbsp;"bali",&nbsp;"beng",&nbsp;"bhks",&nbsp;"brah",&nbsp;"cakm",&nbsp;"cham",&nbsp;"deva",&nbsp;"diak",&nbsp;"fullwide",&nbsp;"gong",&nbsp;"gonm",&nbsp;"gujr",&nbsp;"guru",&nbsp;"hanidec",&nbsp;"hmng",&nbsp;"hmnp",&nbsp;"java",&nbsp;"kali",&nbsp;"khmr",&nbsp;"knda",&nbsp;"lana",&nbsp;"lanatham",&nbsp;"laoo",&nbsp;"latn",&nbsp;"lepc",&nbsp;"limb",&nbsp;"mathbold",&nbsp;"mathdbl",&nbsp;"mathmono",&nbsp;"mathsanb",&nbsp;"mathsans",&nbsp;"mlym",&nbsp;"modi",&nbsp;"mong",&nbsp;"mroo",&nbsp;"mtei",&nbsp;"mymr",&nbsp;"mymrshan",&nbsp;"mymrtlng",&nbsp;"newa",&nbsp;"nkoo",&nbsp;"olck",&nbsp;"orya",&nbsp;"osma",&nbsp;"rohg",&nbsp;"saur",&nbsp;"segment",&nbsp;"shrd",&nbsp;"sind",&nbsp;"sinh",&nbsp;"sora",&nbsp;"sund",&nbsp;"takr",&nbsp;"talu",&nbsp;"tamldec",&nbsp;"telu",&nbsp;"thai",&nbsp;"tibt",&nbsp;"tirh",&nbsp;"vaii",&nbsp;"wara",&nbsp;"wcho"。 |
| numeric | boolean | 是 | 是 | 是否使用12小时制。 |
| caseFirst | string | 是 | 是 | 表示大写、小写的排序顺序,取值范围:"upper",&nbsp;"lower",&nbsp;"false"。 |
## DateTimeFormat ## DateTimeFormat
### constructor ### constructor<sup>8+</sup>
constructor() constructor()
...@@ -145,7 +163,7 @@ constructor() ...@@ -145,7 +163,7 @@ constructor()
### constructor ### constructor
constructor(locale: string, options?: DateTimeOptions) constructor(locale: string | Array<string>, options?: DateTimeOptions)
创建时间日期格式化对象。 创建时间日期格式化对象。
...@@ -154,7 +172,7 @@ constructor(locale: string, options?: DateTimeOptions) ...@@ -154,7 +172,7 @@ constructor(locale: string, options?: DateTimeOptions)
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| locale | string | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | | locale | string \| Array<string> | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 |
| options | [DateTimeOptions](#datetimeoptions) | 否 | 用于创建时间日期格式化的选项。 | | options | [DateTimeOptions](#datetimeoptions) | 否 | 用于创建时间日期格式化的选项。 |
- 示例: - 示例:
...@@ -163,20 +181,6 @@ constructor(locale: string, options?: DateTimeOptions) ...@@ -163,20 +181,6 @@ constructor(locale: string, options?: DateTimeOptions)
``` ```
### constructor
constructor(locales: Array&lt;string&gt;, options?: DateTimeOptions)
创建时间日期格式化对象。
**系统能力**:SystemCapability.Global.I18n
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| locales | Array&lt;string&gt; | 是 | 包含区域设置信息的字符串的数组。 |
| options | [DateTimeOptions](#datetimeoptions) | 否 | 用于创建时间日期格式化的选项。 |
- 示例: - 示例:
``` ```
var datefmt= new Intl.DateTimeFormat(["ban", "zh"], { dateStyle: 'full', timeStyle: 'medium' }); var datefmt= new Intl.DateTimeFormat(["ban", "zh"], { dateStyle: 'full', timeStyle: 'medium' });
...@@ -211,7 +215,7 @@ format(date: Date): string ...@@ -211,7 +215,7 @@ format(date: Date): string
### formatRange ### formatRange
formatRange(fromDate: Date, toDate: Date): string formatRange(startDate: Date, endDate: Date): string
格式化时间日期段字符串。 格式化时间日期段字符串。
...@@ -261,33 +265,35 @@ resolvedOptions(): DateTimeOptions ...@@ -261,33 +265,35 @@ resolvedOptions(): DateTimeOptions
表示时间日期格式化选项。 表示时间日期格式化选项。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Global.I18n
| 名称 | 参数类型 | 可读 | 可写 | 说明 | | 名称 | 参数类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| locale | string | 是 | 否 | 区域参数,&nbsp;如:zh-Hans-CN。<br/>**系统能力**:SystemCapability.Global.I18n | | locale | string | 是 | 否 | 区域参数,&nbsp;如:zh-Hans-CN。 |
| dateStyle | string | 是 | 是 | 日期显示格式,取值包括:"long",&nbsp;"short",&nbsp;"medium",&nbsp;"full"。<br/>**系统能力**:SystemCapability.Global.I18n | | dateStyle | string | 是 | 是 | 日期显示格式,取值包括:"long",&nbsp;"short",&nbsp;"medium",&nbsp;"full"。 |
| timeStyle | string | 是 | 是 | 时间显示格式,取值包括:"long",&nbsp;"short",&nbsp;"medium",&nbsp;"full"。<br/>**系统能力**:SystemCapability.Global.I18n | | timeStyle | string | 是 | 是 | 时间显示格式,取值包括:"long",&nbsp;"short",&nbsp;"medium",&nbsp;"full"。 |
| hourCycle | string | 是 | 是 | 时制格式,取值包括:"h11",&nbsp;"h12",&nbsp;"h23",&nbsp;"h24"。<br/>**系统能力**:SystemCapability.Global.I18n | | hourCycle | string | 是 | 是 | 时制格式,取值包括:"h11",&nbsp;"h12",&nbsp;"h23",&nbsp;"h24"。 |
| timeZone | string | 是 | 是 | 使用的时区(合法的IANA时区ID)。<br/>**系统能力**:SystemCapability.Global.I18n | | timeZone | string | 是 | 是 | 使用的时区(合法的IANA时区ID)。 |
| numberingSystem | string | 是 | 是 | 数字系统,取值包括:"adlm",&nbsp;"ahom",&nbsp;"arab",&nbsp;"arabext",&nbsp;"bali",&nbsp;"beng",&nbsp;"bhks",&nbsp;"brah",&nbsp;"cakm",&nbsp;"cham",&nbsp;"deva",&nbsp;"diak",&nbsp;"fullwide",&nbsp;"gong",&nbsp;"gonm",&nbsp;"gujr",&nbsp;"guru",&nbsp;"hanidec",&nbsp;"hmng",&nbsp;"hmnp",&nbsp;"java",&nbsp;"kali",&nbsp;"khmr",&nbsp;"knda",&nbsp;"lana",&nbsp;"lanatham",&nbsp;"laoo",&nbsp;"latn",&nbsp;"lepc",&nbsp;"limb",&nbsp;"mathbold",&nbsp;"mathdbl",&nbsp;"mathmono",&nbsp;"mathsanb",&nbsp;"mathsans",&nbsp;"mlym",&nbsp;"modi",&nbsp;"mong",&nbsp;"mroo",&nbsp;"mtei",&nbsp;"mymr",&nbsp;"mymrshan",&nbsp;"mymrtlng",&nbsp;"newa",&nbsp;"nkoo",&nbsp;"olck",&nbsp;"orya",&nbsp;"osma",&nbsp;"rohg",&nbsp;"saur",&nbsp;"segment",&nbsp;"shrd",&nbsp;"sind",&nbsp;"sinh",&nbsp;"sora",&nbsp;"sund",&nbsp;"takr",&nbsp;"talu",&nbsp;"tamldec",&nbsp;"telu",&nbsp;"thai",&nbsp;"tibt",&nbsp;"tirh",&nbsp;"vaii",&nbsp;"wara",&nbsp;"wcho"。<br/>**系统能力**:SystemCapability.Global.I18n | | numberingSystem | string | 是 | 是 | 数字系统,取值包括:"adlm",&nbsp;"ahom",&nbsp;"arab",&nbsp;"arabext",&nbsp;"bali",&nbsp;"beng",&nbsp;"bhks",&nbsp;"brah",&nbsp;"cakm",&nbsp;"cham",&nbsp;"deva",&nbsp;"diak",&nbsp;"fullwide",&nbsp;"gong",&nbsp;"gonm",&nbsp;"gujr",&nbsp;"guru",&nbsp;"hanidec",&nbsp;"hmng",&nbsp;"hmnp",&nbsp;"java",&nbsp;"kali",&nbsp;"khmr",&nbsp;"knda",&nbsp;"lana",&nbsp;"lanatham",&nbsp;"laoo",&nbsp;"latn",&nbsp;"lepc",&nbsp;"limb",&nbsp;"mathbold",&nbsp;"mathdbl",&nbsp;"mathmono",&nbsp;"mathsanb",&nbsp;"mathsans",&nbsp;"mlym",&nbsp;"modi",&nbsp;"mong",&nbsp;"mroo",&nbsp;"mtei",&nbsp;"mymr",&nbsp;"mymrshan",&nbsp;"mymrtlng",&nbsp;"newa",&nbsp;"nkoo",&nbsp;"olck",&nbsp;"orya",&nbsp;"osma",&nbsp;"rohg",&nbsp;"saur",&nbsp;"segment",&nbsp;"shrd",&nbsp;"sind",&nbsp;"sinh",&nbsp;"sora",&nbsp;"sund",&nbsp;"takr",&nbsp;"talu",&nbsp;"tamldec",&nbsp;"telu",&nbsp;"thai",&nbsp;"tibt",&nbsp;"tirh",&nbsp;"vaii",&nbsp;"wara",&nbsp;"wcho"。 |
| hour12 | boolean | 是 | 是 | 是否使用12小时制。<br/>**系统能力**:SystemCapability.Global.I18n | | hour12 | boolean | 是 | 是 | 是否使用12小时制。 |
| weekday | string | 是 | 是 | 工作日的显示格式,取值包括:"long",&nbsp;"short",&nbsp;"narrow"。<br/>**系统能力**:SystemCapability.Global.I18n | | weekday | string | 是 | 是 | 工作日的显示格式,取值包括:"long",&nbsp;"short",&nbsp;"narrow"。 |
| era | string | 是 | 是 | 时代的显示格式,取值包括:"long",&nbsp;"short",&nbsp;"narrow"。<br/>**系统能力**:SystemCapability.Global.I18n | | era | string | 是 | 是 | 时代的显示格式,取值包括:"long",&nbsp;"short",&nbsp;"narrow"。 |
| year | string | 是 | 是 | 年份的显示格式,取值包括:"numeric",&nbsp;"2-digit"。<br/>**系统能力**:SystemCapability.Global.I18n | | year | string | 是 | 是 | 年份的显示格式,取值包括:"numeric",&nbsp;"2-digit"。 |
| month | string | 是 | 是 | 月份的显示格式,取值包括:"numeric",&nbsp;"2-digit",&nbsp;"long",&nbsp;"short",&nbsp;"narrow"。<br/>**系统能力**:SystemCapability.Global.I18n | | month | string | 是 | 是 | 月份的显示格式,取值包括:"numeric",&nbsp;"2-digit",&nbsp;"long",&nbsp;"short",&nbsp;"narrow"。 |
| day | string | 是 | 是 | 日期的显示格式,取值包括:"numeric",&nbsp;"2-digit"。<br/>**系统能力**:SystemCapability.Global.I18n | | day | string | 是 | 是 | 日期的显示格式,取值包括:"numeric",&nbsp;"2-digit"。 |
| hour | string | 是 | 是 | 小时的显示格式,取值包括:"numeric",&nbsp;"2-digit"。<br/>**系统能力**:SystemCapability.Global.I18n | | hour | string | 是 | 是 | 小时的显示格式,取值包括:"numeric",&nbsp;"2-digit"。 |
| minute | string | 是 | 是 | 分钟的显示格式,取值包括:"numeric",&nbsp;"2-digit"。<br/>**系统能力**:SystemCapability.Global.I18n | | minute | string | 是 | 是 | 分钟的显示格式,取值包括:"numeric",&nbsp;"2-digit"。 |
| second | string | 是 | 是 | 秒钟的显示格式,取值包括:"numeric",&nbsp;"2-digit"。<br/>**系统能力**:SystemCapability.Global.I18n | | second | string | 是 | 是 | 秒钟的显示格式,取值包括:"numeric",&nbsp;"2-digit"。 |
| timeZoneName | string | 是 | 是 | 时区名称的本地化表示。<br/>**系统能力**:SystemCapability.Global.I18n | | timeZoneName | string | 是 | 是 | 时区名称的本地化表示。 |
| dayPeriod | string | 是 | 是 | 时段的显示格式,取值包括:"long",&nbsp;"short",&nbsp;"narrow"。<br/>**系统能力**:SystemCapability.Global.I18n | | dayPeriod | string | 是 | 是 | 时段的显示格式,取值包括:"long",&nbsp;"short",&nbsp;"narrow"。 |
| localeMatcher | string | 是 | 是 | 要使用的区域匹配算法,取值包括:"lookup",&nbsp;"best&nbsp;fit"。<br/>**系统能力**:SystemCapability.Global.I18n | | localeMatcher | string | 是 | 是 | 要使用的区域匹配算法,取值包括:"lookup",&nbsp;"best&nbsp;fit"。 |
| formatMatcher | string | 是 | 是 | 要使用的格式匹配算法,取值包括:"basic",&nbsp;"best&nbsp;fit"。<br/>**系统能力**:SystemCapability.Global.I18n | | formatMatcher | string | 是 | 是 | 要使用的格式匹配算法,取值包括:"basic",&nbsp;"best&nbsp;fit"。 |
## NumberFormat ## NumberFormat
### constructor ### constructor<sup>8+</sup>
constructor() constructor()
...@@ -303,7 +309,7 @@ constructor() ...@@ -303,7 +309,7 @@ constructor()
### constructor ### constructor
constructor(locale: string, options?: NumberOptions) constructor(locale: string | Array<string>, options?: NumberOptions)
创建数字格式化对象。 创建数字格式化对象。
...@@ -312,7 +318,7 @@ constructor(locale: string, options?: NumberOptions) ...@@ -312,7 +318,7 @@ constructor(locale: string, options?: NumberOptions)
参数: 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| locale | string | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | | locale | string \| Array<string> | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 |
| options | [NumberOptions](#numberoptions) | 否 | 用于创建数字格式化的选项。 | | options | [NumberOptions](#numberoptions) | 否 | 用于创建数字格式化的选项。 |
- 示例: - 示例:
...@@ -321,26 +327,6 @@ constructor(locale: string, options?: NumberOptions) ...@@ -321,26 +327,6 @@ constructor(locale: string, options?: NumberOptions)
``` ```
### constructor
constructor(locales: Array&lt;string&gt;, options?: NumberOptions)
创建数字格式化对象。
**系统能力**:SystemCapability.Global.I18n
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| locales | Array&lt;string&gt; | 是 | 包含区域设置信息的字符串的数组。 |
| options | [NumberOptions](#numberoptions) | 否 | 用于创建数字格式化的选项。 |
- 示例:
```
var numfmt = new Intl.NumberFormat(["en-GB", "zh"], {style:'decimal', notation:"scientific"});
```
### format ### format
format(number: number): string; format(number: number): string;
...@@ -392,27 +378,29 @@ resolvedOptions(): NumberOptions ...@@ -392,27 +378,29 @@ resolvedOptions(): NumberOptions
表示设备支持的能力。 表示设备支持的能力。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Global.I18n
| 名称 | 参数类型 | 可读 | 可写 | 说明 | | 名称 | 参数类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| locale | string | 是 | 否 | 区域参数,&nbsp;如:"zh-Hans-CN"。<br/>**系统能力**:SystemCapability.Global.I18n | | locale | string | 是 | 否 | 区域参数,&nbsp;如:"zh-Hans-CN"。 |
| currency | string | 是 | 是 | 货币单位,&nbsp;如:"EUR","CNY","USD"等。<br/>**系统能力**:SystemCapability.Global.I18n | | currency | string | 是 | 是 | 货币单位,&nbsp;如:"EUR","CNY","USD"等。 |
| currencySign | string | 是 | 是 | 货币单位的符号显示,取值包括:&nbsp;"symbol","narrowSymbol","code","name"&nbsp;<br/>**系统能力**:SystemCapability.Global.I18n | | currencySign | string | 是 | 是 | 货币单位的符号显示,取值包括:&nbsp;"symbol","narrowSymbol","code","name"&nbsp;。 |
| currencyDisplay | string | 是 | 是 | 货币的显示方式,取值包括:"symbol",&nbsp;"narrowSymbol",&nbsp;"code",&nbsp;"name"。<br/>**系统能力**:SystemCapability.Global.I18n | | currencyDisplay | string | 是 | 是 | 货币的显示方式,取值包括:"symbol",&nbsp;"narrowSymbol",&nbsp;"code",&nbsp;"name"。 |
| unit | string | 是 | 是 | 单位名称,如:"meter","inch",“hectare”等。<br/>**系统能力**:SystemCapability.Global.I18n | | unit | string | 是 | 是 | 单位名称,如:"meter","inch",“hectare”等。 |
| unitDisplay | string | 是 | 是 | 单位的显示格式,取值包括:"long",&nbsp;"short",&nbsp;"medium"。<br/>**系统能力**:SystemCapability.Global.I18n | | unitDisplay | string | 是 | 是 | 单位的显示格式,取值包括:"long",&nbsp;"short",&nbsp;"medium"。 |
| unitUsage | string | 是 | 是 | 单位的使用场景,取值包括:"default",&nbsp;"area-land-agricult",&nbsp;"area-land-commercl",&nbsp;"area-land-residntl",&nbsp;"length-person",&nbsp;"length-person-small",&nbsp;"length-rainfall",&nbsp;"length-road",&nbsp;"length-road-small",&nbsp;"length-snowfall",&nbsp;"length-vehicle",&nbsp;"length-visiblty",&nbsp;"length-visiblty-small",&nbsp;"length-person-informal",&nbsp;"length-person-small-informal",&nbsp;"length-road-informal",&nbsp;"speed-road-travel",&nbsp;"speed-wind",&nbsp;"temperature-person",&nbsp;"temperature-weather",&nbsp;"volume-vehicle-fuel"。<br/>**系统能力**:SystemCapability.Global.I18n | | unitUsage | string | 是 | 是 | 单位的使用场景,取值包括:"default",&nbsp;"area-land-agricult",&nbsp;"area-land-commercl",&nbsp;"area-land-residntl",&nbsp;"length-person",&nbsp;"length-person-small",&nbsp;"length-rainfall",&nbsp;"length-road",&nbsp;"length-road-small",&nbsp;"length-snowfall",&nbsp;"length-vehicle",&nbsp;"length-visiblty",&nbsp;"length-visiblty-small",&nbsp;"length-person-informal",&nbsp;"length-person-small-informal",&nbsp;"length-road-informal",&nbsp;"speed-road-travel",&nbsp;"speed-wind",&nbsp;"temperature-person",&nbsp;"temperature-weather",&nbsp;"volume-vehicle-fuel"。 |
| signDisplay | string | 是 | 是 | 数字符号的显示格式,取值包括:"auto",&nbsp;"never",&nbsp;"always",&nbsp;"expectZero"。<br/>**系统能力**:SystemCapability.Global.I18n | | signDisplay | string | 是 | 是 | 数字符号的显示格式,取值包括:"auto",&nbsp;"never",&nbsp;"always",&nbsp;"expectZero"。 |
| compactDisplay | string | 是 | 是 | 紧凑型的显示格式,取值包括:"long",&nbsp;"short"。<br/>**系统能力**:SystemCapability.Global.I18n | | compactDisplay | string | 是 | 是 | 紧凑型的显示格式,取值包括:"long",&nbsp;"short"。 |
| notation | string | 是 | 是 | 数字的格式化规格,取值包括:"standard",&nbsp;"scientific",&nbsp;"engineering",&nbsp;"compact"。<br/>**系统能力**:SystemCapability.Global.I18n | | notation | string | 是 | 是 | 数字的格式化规格,取值包括:"standard",&nbsp;"scientific",&nbsp;"engineering",&nbsp;"compact"。 |
| localeMatcher | string | 是 | 是 | 要使用的区域匹配算法,取值包括:"lookup",&nbsp;"best&nbsp;fit"。<br/>**系统能力**:SystemCapability.Global.I18n | | localeMatcher | string | 是 | 是 | 要使用的区域匹配算法,取值包括:"lookup",&nbsp;"best&nbsp;fit"。 |
| style | string | 是 | 是 | 数字的显示格式,取值包括:"decimal",&nbsp;"currency",&nbsp;"percent",&nbsp;"unit"。<br/>**系统能力**:SystemCapability.Global.I18n | | style | string | 是 | 是 | 数字的显示格式,取值包括:"decimal",&nbsp;"currency",&nbsp;"percent",&nbsp;"unit"。 |
| numberingSystem | string | 是 | 是 | 数字系统,取值包括:"adlm",&nbsp;"ahom",&nbsp;"arab",&nbsp;"arabext",&nbsp;"bali",&nbsp;"beng",&nbsp;"bhks",&nbsp;"brah",&nbsp;"cakm",&nbsp;"cham",&nbsp;"deva",&nbsp;"diak",&nbsp;"fullwide",&nbsp;"gong",&nbsp;"gonm",&nbsp;"gujr",&nbsp;"guru",&nbsp;"hanidec",&nbsp;"hmng",&nbsp;"hmnp",&nbsp;"java",&nbsp;"kali",&nbsp;"khmr",&nbsp;"knda",&nbsp;"lana",&nbsp;"lanatham",&nbsp;"laoo",&nbsp;"latn",&nbsp;"lepc",&nbsp;"limb",&nbsp;"mathbold",&nbsp;"mathdbl",&nbsp;"mathmono",&nbsp;"mathsanb",&nbsp;"mathsans",&nbsp;"mlym",&nbsp;"modi",&nbsp;"mong",&nbsp;"mroo",&nbsp;"mtei",&nbsp;"mymr",&nbsp;"mymrshan",&nbsp;"mymrtlng",&nbsp;"newa",&nbsp;"nkoo",&nbsp;"olck",&nbsp;"orya",&nbsp;"osma",&nbsp;"rohg",&nbsp;"saur",&nbsp;"segment",&nbsp;"shrd",&nbsp;"sind",&nbsp;"sinh",&nbsp;"sora",&nbsp;"sund",&nbsp;"takr",&nbsp;"talu",&nbsp;"tamldec",&nbsp;"telu",&nbsp;"thai",&nbsp;"tibt",&nbsp;"tirh",&nbsp;"vaii",&nbsp;"wara",&nbsp;"wcho"。<br/>**系统能力**:SystemCapability.Global.I18n | | numberingSystem | string | 是 | 是 | 数字系统,取值包括:"adlm",&nbsp;"ahom",&nbsp;"arab",&nbsp;"arabext",&nbsp;"bali",&nbsp;"beng",&nbsp;"bhks",&nbsp;"brah",&nbsp;"cakm",&nbsp;"cham",&nbsp;"deva",&nbsp;"diak",&nbsp;"fullwide",&nbsp;"gong",&nbsp;"gonm",&nbsp;"gujr",&nbsp;"guru",&nbsp;"hanidec",&nbsp;"hmng",&nbsp;"hmnp",&nbsp;"java",&nbsp;"kali",&nbsp;"khmr",&nbsp;"knda",&nbsp;"lana",&nbsp;"lanatham",&nbsp;"laoo",&nbsp;"latn",&nbsp;"lepc",&nbsp;"limb",&nbsp;"mathbold",&nbsp;"mathdbl",&nbsp;"mathmono",&nbsp;"mathsanb",&nbsp;"mathsans",&nbsp;"mlym",&nbsp;"modi",&nbsp;"mong",&nbsp;"mroo",&nbsp;"mtei",&nbsp;"mymr",&nbsp;"mymrshan",&nbsp;"mymrtlng",&nbsp;"newa",&nbsp;"nkoo",&nbsp;"olck",&nbsp;"orya",&nbsp;"osma",&nbsp;"rohg",&nbsp;"saur",&nbsp;"segment",&nbsp;"shrd",&nbsp;"sind",&nbsp;"sinh",&nbsp;"sora",&nbsp;"sund",&nbsp;"takr",&nbsp;"talu",&nbsp;"tamldec",&nbsp;"telu",&nbsp;"thai",&nbsp;"tibt",&nbsp;"tirh",&nbsp;"vaii",&nbsp;"wara",&nbsp;"wcho"。 |
| useGrouping | boolean | 是 | 是 | 是否分组显示。<br/>**系统能力**:SystemCapability.Global.I18n | | useGrouping | boolean | 是 | 是 | 是否分组显示。 |
| miniumumIntegerDigits | number | 是 | 是 | 表示要使用的最小整数位数,取值范围:1~21。<br/>**系统能力**:SystemCapability.Global.I18n | | minimumIntegerDigits | number | 是 | 是 | 表示要使用的最小整数位数,取值范围:1~21。 |
| miniumumFractionDigits | number | 是 | 是 | 表示要使用的最小分数位数,取值范围:0~20。<br/>**系统能力**:SystemCapability.Global.I18n | | minimumFractionDigits | number | 是 | 是 | 表示要使用的最小分数位数,取值范围:0~20。 |
| maxiumumFractionDigits | number | 是 | 是 | 表示要使用的最大分数位数,取值范围:1~21。<br/>**系统能力**:SystemCapability.Global.I18n | | maximumFractionDigits | number | 是 | 是 | 表示要使用的最大分数位数,取值范围:1~21。 |
| miniumumSignificantDigits | number | 是 | 是 | 表示要使用的最低有效位数,取值范围:1~21。<br/>**系统能力**:SystemCapability.Global.I18n | | minimumSignificantDigits | number | 是 | 是 | 表示要使用的最低有效位数,取值范围:1~21。 |
| maxiumumSignificantDigits | number | 是 | 是 | 表示要使用的最大有效位数,取值范围:1~21。<br/>**系统能力**:SystemCapability.Global.I18n | | maximumSignificantDigits | number | 是 | 是 | 表示要使用的最大有效位数,取值范围:1~21。 |
## Collator<sup>8+</sup> ## Collator<sup>8+</sup>
...@@ -434,7 +422,7 @@ constructor() ...@@ -434,7 +422,7 @@ constructor()
### constructor<sup>8+</sup> ### constructor<sup>8+</sup>
constructor(locale: string | Array&lt;string&gt;, options?: CollatorOptions) constructor(locale: string | Array<string>, options?: CollatorOptions)
创建排序对象。 创建排序对象。
...@@ -444,12 +432,12 @@ constructor(locale: string | Array&lt;string&gt;, options?: CollatorOptions) ...@@ -444,12 +432,12 @@ constructor(locale: string | Array&lt;string&gt;, options?: CollatorOptions)
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| locale | string\|Array&lt;string&gt; | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | | locale | string \| Array<string> | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 |
| options | [CollatorOptions](#collatoroptions) | 否 | 用于创建排序对象的选项。 | | options | [CollatorOptions](#collatoroptions) | 否 | 用于创建排序对象的选项。 |
- 示例: - 示例:
``` ```
var collator = new Intl.Collator("zh-CN", {"localeMatcher": "lookup", "usage": "sort"}); var collator = new Intl.Collator("zh-CN", {localeMatcher: "lookup", usage: "sort"});
``` ```
...@@ -503,15 +491,17 @@ resolvedOptions(): CollatorOptions ...@@ -503,15 +491,17 @@ resolvedOptions(): CollatorOptions
表示Collator可设置的属性。 表示Collator可设置的属性。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Global.I18n
| 名称 | 参数类型 | 可读 | 可写 | 说明 | | 名称 | 参数类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| localeMatcher | string | 是 | 是 | locale匹配算法,取值范围:"best&nbsp;fit",&nbsp;"lookup"。<br/>**系统能力**:SystemCapability.Global.I18n | | localeMatcher | string | 是 | 是 | locale匹配算法,取值范围:"best&nbsp;fit",&nbsp;"lookup"。 |
| usage | string | 是 | 是 | 比较的用途,取值范围:"sort",&nbsp;"search"。<br/>**系统能力**:SystemCapability.Global.I18n | | usage | string | 是 | 是 | 比较的用途,取值范围:"sort",&nbsp;"search"。 |
| sensitivity | string | 是 | 是 | 表示字符串中的哪些差异会导致非零结果值,取值范围:"base",&nbsp;"accent",&nbsp;"case",&nbsp;"variant"。<br/>**系统能力**:SystemCapability.Global.I18n | | sensitivity | string | 是 | 是 | 表示字符串中的哪些差异会导致非零结果值,取值范围:"base",&nbsp;"accent",&nbsp;"case",&nbsp;"variant"。 |
| ignorePunctuation | boolean | 是 | 是 | 表示是否忽略标点符号,取值范围:true,&nbsp;false。<br/>**系统能力**:SystemCapability.Global.I18n | | ignorePunctuation | boolean | 是 | 是 | 表示是否忽略标点符号,取值范围:true,&nbsp;false。 |
| collation | string | 是 | 是 | 排序规则,取值范围:"big5han",&nbsp;"compat",&nbsp;"dict",&nbsp;"direct",&nbsp;"ducet",&nbsp;"eor",&nbsp;"gb2312",&nbsp;"phonebk",&nbsp;"phonetic",&nbsp;"pinyin",&nbsp;"reformed",&nbsp;"searchjl",&nbsp;"stroke",&nbsp;"trad",&nbsp;"unihan",&nbsp;"zhuyin"。<br/>**系统能力**:SystemCapability.Global.I18n | | collation | string | 是 | 是 | 排序规则,取值范围:"big5han",&nbsp;"compat",&nbsp;"dict",&nbsp;"direct",&nbsp;"ducet",&nbsp;"eor",&nbsp;"gb2312",&nbsp;"phonebk",&nbsp;"phonetic",&nbsp;"pinyin",&nbsp;"reformed",&nbsp;"searchjl",&nbsp;"stroke",&nbsp;"trad",&nbsp;"unihan",&nbsp;"zhuyin"。 |
| numeric | boolean | 是 | 是 | 是否使用数字排序,取值范围:true,&nbsp;false。<br/>**系统能力**:SystemCapability.Global.I18n | | numeric | boolean | 是 | 是 | 是否使用数字排序,取值范围:true,&nbsp;false。 |
| caseFirst | string | 是 | 是 | 表示大写、小写的排序顺序,取值范围:"upper",&nbsp;"lower",&nbsp;"false"。<br/>**系统能力**:SystemCapability.Global.I18n | | caseFirst | string | 是 | 是 | 表示大写、小写的排序顺序,取值范围:"upper",&nbsp;"lower",&nbsp;"false"。 |
## PluralRules<sup>8+</sup> ## PluralRules<sup>8+</sup>
...@@ -533,7 +523,7 @@ constructor() ...@@ -533,7 +523,7 @@ constructor()
### constructor<sup>8+</sup> ### constructor<sup>8+</sup>
constructor(locale: string | Array&lt;string&gt;, options?: PluralRulesOptions) constructor(locale: string | Array<string>, options?: PluralRulesOptions)
创建PluralRules对象。 创建PluralRules对象。
...@@ -542,7 +532,7 @@ constructor(locale: string | Array&lt;string&gt;, options?: PluralRulesOptions) ...@@ -542,7 +532,7 @@ constructor(locale: string | Array&lt;string&gt;, options?: PluralRulesOptions)
参数: 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| locale | string\|Array&lt;string&gt; | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | | locale | string \| Array<string> | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 |
| options | [PluralRulesOptions](#pluralrulesoptions) | 否 | 用于创建单复数对象的选项。 | | options | [PluralRulesOptions](#pluralrulesoptions) | 否 | 用于创建单复数对象的选项。 |
- 示例: - 示例:
...@@ -580,15 +570,17 @@ select(n: number): string ...@@ -580,15 +570,17 @@ select(n: number): string
表示PluralRules对象可设置的属性。 表示PluralRules对象可设置的属性。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Global.I18n
| 名称 | 参数类型 | 可读 | 可写 | 说明 | | 名称 | 参数类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| localeMatcher | string | 是 | 是 | locale匹配算法,取值包括:"best&nbsp;fit",&nbsp;"lookup"。<br/>**系统能力**:SystemCapability.Global.I18n | | localeMatcher | string | 是 | 是 | locale匹配算法,取值包括:"best&nbsp;fit",&nbsp;"lookup"。 |
| type | string | 是 | 是 | 排序的类型,取值包括:"cardinal",&nbsp;"ordinal"。<br/>**系统能力**:SystemCapability.Global.I18n | | type | string | 是 | 是 | 排序的类型,取值包括:"cardinal",&nbsp;"ordinal"。 |
| minimumIntegerDigits | number | 是 | 是 | 表示要使用的最小整数位数,取值范围:1~21。<br/>**系统能力**:SystemCapability.Global.I18n | | minimumIntegerDigits | number | 是 | 是 | 表示要使用的最小整数位数,取值范围:1~21。 |
| minimumFractionDigits | number | 是 | 是 | 表示要使用的最小分数位数,取值范围:0~20。<br/>**系统能力**:SystemCapability.Global.I18n | | minimumFractionDigits | number | 是 | 是 | 表示要使用的最小分数位数,取值范围:0~20。 |
| maximumFractionDigits | number | 是 | 是 | 表示要使用的最大分数位数,取值范围:1~21。<br/>**系统能力**:SystemCapability.Global.I18n | | maximumFractionDigits | number | 是 | 是 | 表示要使用的最大分数位数,取值范围:1~21。 |
| minimumSignificantDigits | number | 是 | 是 | 表示要使用的最低有效位数,取值范围:1~21。<br/>**系统能力**:SystemCapability.Global.I18n | | minimumSignificantDigits | number | 是 | 是 | 表示要使用的最低有效位数,取值范围:1~21。 |
| maximumSignificantDigits | number | 是 | 是 | 表示要使用的最大有效位数,取值范围:1~21。<br/>**系统能力**:SystemCapability.Global.I18n | | maximumSignificantDigits | number | 是 | 是 | 表示要使用的最大有效位数,取值范围:1~21。 |
## RelativeTimeFormat<sup>8+</sup> ## RelativeTimeFormat<sup>8+</sup>
...@@ -610,7 +602,7 @@ constructor() ...@@ -610,7 +602,7 @@ constructor()
### constructor<sup>8+</sup> ### constructor<sup>8+</sup>
constructor(locale: string | Array&lt;string&gt;, options?: RelativeTimeFormatInputOptions) constructor(locale: string | Array<string>, options?: RelativeTimeFormatInputOptions)
创建相对时间格式化对象。 创建相对时间格式化对象。
...@@ -619,7 +611,7 @@ constructor(locale: string | Array&lt;string&gt;, options?: RelativeTimeFormatIn ...@@ -619,7 +611,7 @@ constructor(locale: string | Array&lt;string&gt;, options?: RelativeTimeFormatIn
参数: 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| locale | string\|Array&lt;string&gt; | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | | locale | string \| Array<string> | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 |
| options | [RelativeTimeFormatInputOptions](#relativetimeformatinputoptions) | 否 | 用于创建相对时间格式化对象的选项。 | | options | [RelativeTimeFormatInputOptions](#relativetimeformatinputoptions) | 否 | 用于创建相对时间格式化对象的选项。 |
- 示例: - 示例:
...@@ -630,7 +622,7 @@ constructor(locale: string | Array&lt;string&gt;, options?: RelativeTimeFormatIn ...@@ -630,7 +622,7 @@ constructor(locale: string | Array&lt;string&gt;, options?: RelativeTimeFormatIn
### format<sup>8+</sup> ### format<sup>8+</sup>
format(value: numeric, unit: string): string format(value: number, unit: string): string
依据locale和格式化选项,对value和unit进行格式化。 依据locale和格式化选项,对value和unit进行格式化。
...@@ -639,7 +631,7 @@ format(value: numeric, unit: string): string ...@@ -639,7 +631,7 @@ format(value: numeric, unit: string): string
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | numeric | 是 | 相对时间格式化的数值。 | | value | number | 是 | 相对时间格式化的数值。 |
| unit | string | 是 | 相对时间格式化的单位,取值包括:"year",&nbsp;"quarter",&nbsp;"month",&nbsp;"week",&nbsp;"day",&nbsp;"hour",&nbsp;"minute",&nbsp;"second"。 | | unit | string | 是 | 相对时间格式化的单位,取值包括:"year",&nbsp;"quarter",&nbsp;"month",&nbsp;"week",&nbsp;"day",&nbsp;"hour",&nbsp;"minute",&nbsp;"second"。 |
- 返回值: - 返回值:
...@@ -656,7 +648,7 @@ format(value: numeric, unit: string): string ...@@ -656,7 +648,7 @@ format(value: numeric, unit: string): string
### formatToParts<sup>8+</sup> ### formatToParts<sup>8+</sup>
formatToParts(value: numeric, unit: string): Array&lt;Object&gt; formatToParts(value: number, unit: string): Array<object>
返回一个对象数组,表示可用于自定义区域设置格式的相对时间格式。 返回一个对象数组,表示可用于自定义区域设置格式的相对时间格式。
...@@ -665,13 +657,13 @@ formatToParts(value: numeric, unit: string): Array&lt;Object&gt; ...@@ -665,13 +657,13 @@ formatToParts(value: numeric, unit: string): Array&lt;Object&gt;
- 参数: - 参数:
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | numeric | 是 | 相对时间格式化的数值。 | | value | number | 是 | 相对时间格式化的数值。 |
| unit | string | 是 | 相对时间格式化的单位,取值包括:"year",&nbsp;"quarter",&nbsp;"month",&nbsp;"week",&nbsp;"day",&nbsp;"hour",&nbsp;"minute",&nbsp;"second"。 | | unit | string | 是 | 相对时间格式化的单位,取值包括:"year",&nbsp;"quarter",&nbsp;"month",&nbsp;"week",&nbsp;"day",&nbsp;"hour",&nbsp;"minute",&nbsp;"second"。 |
- 返回值: - 返回值:
| 类型 | 说明 | | 类型 | 说明 |
| -------- | -------- | | -------- | -------- |
| Array&lt;Object&gt; | 返回可用于自定义区域设置格式的相对时间格式的对象数组。 | | Array<object> | 返回可用于自定义区域设置格式的相对时间格式的对象数组。 |
- 示例: - 示例:
``` ```
...@@ -704,20 +696,24 @@ resolvedOptions(): RelativeTimeFormatResolvedOptions ...@@ -704,20 +696,24 @@ resolvedOptions(): RelativeTimeFormatResolvedOptions
表示RelativeTimeFormat对象可设置的属性。 表示RelativeTimeFormat对象可设置的属性。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Global.I18n
| 名称 | 参数类型 | 可读 | 可写 | 说明 | | 名称 | 参数类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| localeMatcher | string | 是 | 是 | locale匹配算法,取值包括:"best&nbsp;fit",&nbsp;"lookup"。<br/>**系统能力**:SystemCapability.Global.I18n | | localeMatcher | string | 是 | 是 | locale匹配算法,取值包括:"best&nbsp;fit",&nbsp;"lookup"。 |
| numeric | string | 是 | 是 | 输出消息的格式,取值包括:"always",&nbsp;"auto"。<br/>**系统能力**:SystemCapability.Global.I18n | | numeric | string | 是 | 是 | 输出消息的格式,取值包括:"always",&nbsp;"auto"。 |
| style | string | 是 | 是 | 国际化消息的长度,取值包括:"long",&nbsp;"short",&nbsp;"narrow"。<br/>**系统能力**:SystemCapability.Global.I18n | | style | string | 是 | 是 | 国际化消息的长度,取值包括:"long",&nbsp;"short",&nbsp;"narrow"。 |
## RelativeTimeFormatResolvedOptions<sup>8+</sup><a name=relativetimeformatresolvedoptions></a> ## RelativeTimeFormatResolvedOptions<sup>8+</sup><a name=relativetimeformatresolvedoptions></a>
表示RelativeTimeFormat对象可设置的属性。 表示RelativeTimeFormat对象可设置的属性。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Global.I18n
| 名称 | 参数类型 | 可读 | 可写 | 说明 | | 名称 | 参数类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| locale | string | 是 | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。<br/>**系统能力**:SystemCapability.Global.I18n | | locale | string | 是 | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 |
| numeric | string | 是 | 是 | 输出消息的格式,取值包括:"always",&nbsp;"auto"。<br/>**系统能力**:SystemCapability.Global.I18n | | numeric | string | 是 | 是 | 输出消息的格式,取值包括:"always",&nbsp;"auto"。 |
| style | string | 是 | 是 | 国际化消息的长度,取值包括:"long",&nbsp;"short",&nbsp;"narrow"。<br/>**系统能力**:SystemCapability.Global.I18n | | style | string | 是 | 是 | 国际化消息的长度,取值包括:"long",&nbsp;"short",&nbsp;"narrow"。 |
| numberingSystem | string | 是 | 是 | 使用的数字系统。<br/>**系统能力**:SystemCapability.Global.I18n | | numberingSystem | string | 是 | 是 | 使用的数字系统。 |
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册