提交 4cc639e6 编写于 作者: S shawn_he

update docs

Signed-off-by: Nshawn_he <shawn.he@huawei.com>
上级 3808892c
...@@ -83,7 +83,7 @@ Checks whether the localized script for the specified language is displayed from ...@@ -83,7 +83,7 @@ Checks whether the localized script for the specified language is displayed from
- Return value - Return value
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | The value **true** indicates that the localized script is displayed from right to left, and value **false** indicates the opposite.| | boolean | Returns **true** if the localized script is displayed from right to left; returns **false** otherwise.|
- Example - Example
``` ```
...@@ -111,6 +111,73 @@ Obtains the system language. ...@@ -111,6 +111,73 @@ Obtains the system language.
``` ```
## i18n.setSystemLanguage
setSystemLanguage(language: string): boolean
Sets the system language.
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Description|
| -------- | -------- | -------- |
| language | string | Language ID.|
- Return value
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example
```
i18n.setSystemLanguage('zh');
```
## i18n.getSystemLanguages
getSystemLanguages(): Array<string>
Obtains the list of system languages.
**System capability**: SystemCapability.Global.I18n
- Return value
| Type| Description|
| -------- | -------- |
| Array<string> | List of the IDs of system languages.|
- Example
```
i18n.getSystemLanguages();
```
## i18n.getSystemCountries
getSystemCountries(language: string): Array<string>
Obtains the list of countries and regions supported for the specified language.
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Description|
| -------- | -------- | -------- |
| language | string | Language ID.|
- Return value
| Type| Description|
| -------- | -------- |
| Array<string> | List of the IDs of the countries and regions supported for the specified language.|
- Example
```
i18n.getSystemCountries('zh');
```
## i18n.getSystemRegion ## i18n.getSystemRegion
getSystemRegion(): string getSystemRegion(): string
...@@ -130,6 +197,30 @@ Obtains the system region. ...@@ -130,6 +197,30 @@ Obtains the system region.
``` ```
## i18n.setSystemRegion
setSystemRegion(region: string): boolean
Sets the system region.
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Description|
| -------- | -------- | -------- |
| region | string | Region ID.|
- Return value
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example
```
i18n.setSystemRegion();
```
## i18n.getSystemLocale ## i18n.getSystemLocale
getSystemLocale(): string getSystemLocale(): string
...@@ -149,6 +240,55 @@ Obtains the system locale. ...@@ -149,6 +240,55 @@ Obtains the system locale.
``` ```
## i18n.setSystemLocale
setSystemLocale(locale: string): boolean
Sets the system locale.
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Description|
| -------- | -------- | -------- |
| locale | string | System locale ID, for example, **zh-CN**.|
- Return value
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example
```
i18n.setSystemLocale('zh-CN');
```
## i18n.isSuggested
isSuggested(language: string, region?: string): boolean
Checks whether the system language matches the specified region.
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| language | string | Yes| Valid language ID, for example, **zh**.|
| region | string | No| Valid region ID, for example, **CN**.|
- Return value
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the system language matches the specified region; returns **false** otherwise.|
- Example
```
i18n.isSuggested('zh', 'CN');
```
## i18n.getCalendar<sup>8+</sup> ## i18n.getCalendar<sup>8+</sup>
getCalendar(locale: string, type? : string): Calendar getCalendar(locale: string, type? : string): Calendar
...@@ -161,7 +301,7 @@ Obtains a **Calendar** object. ...@@ -161,7 +301,7 @@ Obtains a **Calendar** object.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| locale | string | Yes| Valid locale value, for example, **zh-Hans-CN**.| | locale | string | Yes| Valid locale value, for example, **zh-Hans-CN**.|
| type | string | No| Valid calendar type. Currently, the valid types are as follows: buddhist, chinese, coptic, ethiopic, hebrew, gregory, indian, islamic\_civil, islamic\_tbla, islamic\_umalqura, japanese, and persian. If this parameter is left unspecified, the default calendar type of the specified locale is used.| | type | string | No| Valid calendar type. Currently, the valid types are as follows: **buddhist**, **chinese**, **coptic**, **ethiopic**, **hebrew**, **gregory**, **indian**, **islamic\_civil**, **islamic\_tbla**, **islamic\_umalqura**, **japanese**, and **persian**. If this parameter is left unspecified, the default calendar type of the specified locale is used.|
- Return value - Return value
| Type| Description| | Type| Description|
...@@ -295,7 +435,7 @@ Obtains the start day of a week for this **Calendar** object. ...@@ -295,7 +435,7 @@ Obtains the start day of a week for this **Calendar** object.
- Return value - Return value
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| number | Start day of a week. The value **1** indicates Sunday, and value **7** indicates Saturday.| | number | Start day of a week. The value **1** indicates Sunday, and the value **7** indicates Saturday.|
- Example - Example
``` ```
...@@ -315,7 +455,7 @@ Sets the start day of a week for this **Calendar** object. ...@@ -315,7 +455,7 @@ Sets the start day of a week for this **Calendar** object.
- Parameters - Parameters
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | number | No| Start day of a week. The value **1** indicates Sunday, and value **7** indicates Saturday.| | value | number | No| Start day of a week. The value **1** indicates Sunday, and the value **7** indicates Saturday.|
- Example - Example
``` ```
...@@ -375,7 +515,7 @@ Obtains the value of the specified field in the **Calendar** object. ...@@ -375,7 +515,7 @@ Obtains the value of the specified field in the **Calendar** object.
- Parameters - Parameters
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| field | string | Yes| Value of the specified field in the **Calendar** object. Currently, a valid field can be any of the following: era, year, month, week\_of\_year, week\_of\_month, date, day\_of\_year, day\_of\_week, day\_of\_week\_in\_month, hour, hour\_of\_day, minute, second, millisecond, zone\_offset, dst\_offset, year\_woy, dow\_local, extended\_year, julian\_day, milliseconds\_in\_day, is\_leap\_month.| | field | string | Yes| Value of the specified field in the **Calendar** object. Currently, a valid field can be any of the following: **era**, **year**, **month**, **week\_of\_year**, **week\_of\_month**, **date**, **day\_of\_year**, **day\_of\_week**, **day\_of\_week\_in\_month**, **hour**, **hour\_of\_day**, **minute**, **second**, **millisecond**, **zone\_offset**, **dst\_offset**, **year\_woy**, **dow\_local**, **extended\_year**, **julian\_day**, **milliseconds\_in\_day**, **is\_leap\_month**.|
- Return value - Return value
| Type| Description| | Type| Description|
...@@ -431,7 +571,7 @@ Checks whether the specified date in this **Calendar** object is a weekend. ...@@ -431,7 +571,7 @@ Checks whether the specified date in this **Calendar** object is a weekend.
- Return value - Return value
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | The value **true** indicates that the date is a weekend, and value **false** indicates a weekday.| | boolean | Returns **true** if the date is a weekend; returns **false** if the date is a weekday.|
- Example - Example
``` ```
...@@ -482,7 +622,7 @@ Checks whether the format of the specified phone number is valid. ...@@ -482,7 +622,7 @@ Checks whether the format of the specified phone number is valid.
- Return value - Return value
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | The value **true** indicates the phone number format is valid, and value **false** indicates the opposite.| | boolean | Returns **true** if the phone number format is valid; returns **false** otherwise.|
- Example - Example
``` ```
...@@ -520,21 +660,23 @@ Formats a phone number. ...@@ -520,21 +660,23 @@ Formats a phone number.
Defines the options for this PhoneNumberFormat object. Defines the options for this PhoneNumberFormat object.
**System capability**: SystemCapability.Global.I18n
| Name| Type| Readable| Writable| Description| | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| type | string | Yes| Yes| Format type of a phone number. The value can be **E164**, **INTERNATIONAL**, **NATIONAL**, or **RFC3966**.<br>**System capability**: SystemCapability.Global.I18n| | type | string | Yes| Yes| Format type of a phone number. The value can be **E164**, **INTERNATIONAL**, **NATIONAL**, or **RFC3966**.|
## UnitInfo<sup>8+</sup> ## UnitInfo<sup>8+</sup>
Defines the measurement unit information. Defines the measurement unit information.
**System capability**: SystemCapability.Global.I18n
| Name| Type| Readable| Writable| Description| | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| unit | string | Yes| Yes| Name of the measurement unit, for example, **meter**, **inch**, or **cup**.| | unit | string | Yes| Yes| Name of the measurement unit, for example, **meter**, **inch**, or **cup**.|
| measureSystem | string | Yes| Yes| Measurement system. The value can be **SI**, **US**, or **UK**.<br>**System capability**: SystemCapability.Global.I18n| | measureSystem | string | Yes| Yes| Measurement system. The value can be **SI**, **US**, or **UK**.|
## Util<sup>8+</sup> ## Util<sup>8+</sup>
...@@ -568,12 +710,9 @@ Converts one measurement unit into another and formats the unit based on the spe ...@@ -568,12 +710,9 @@ Converts one measurement unit into another and formats the unit based on the spe
``` ```
## IndexUtil<sup>8+</sup> ## getInstance<sup>8+</sup>
### getInstance<sup>8+</sup>
getInstance(): IndexUtil getInstance(locale?:string): IndexUtil
Creates an **IndexUtil** object. Creates an **IndexUtil** object.
...@@ -595,6 +734,9 @@ Creates an **IndexUtil** object. ...@@ -595,6 +734,9 @@ Creates an **IndexUtil** object.
``` ```
## IndexUtil<sup>8+</sup>
### getIndexList<sup>8+</sup> ### getIndexList<sup>8+</sup>
getIndexList(): Array&lt;string&gt; getIndexList(): Array&lt;string&gt;
...@@ -617,7 +759,7 @@ Obtains the index list for this **locale** object. ...@@ -617,7 +759,7 @@ Obtains the index list for this **locale** object.
### addLocale<sup>8+</sup> ### addLocale<sup>8+</sup>
addLocale(locale: string) addLocale(locale: string): void
Adds the index of the new **locale** object to the index list. Adds the index of the new **locale** object to the index list.
...@@ -679,7 +821,7 @@ Checks whether the input character string is composed of digits. ...@@ -679,7 +821,7 @@ Checks whether the input character string is composed of digits.
- Return value - Return value
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | The value **true** indicates that the input character is a digit, and value **false** indicates the opposite.| | boolean | Returns **true** if the input character is a digit; returns **false** otherwise.|
- Example - Example
``` ```
...@@ -703,7 +845,7 @@ Checks whether the input character is a space. ...@@ -703,7 +845,7 @@ Checks whether the input character is a space.
- Return value - Return value
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | The value **true** indicates that the input character is a space, and value **false** indicates the opposite.| | boolean | Returns **true** if the input character is a space; returns **false** otherwise.|
- Example - Example
``` ```
...@@ -727,7 +869,7 @@ Checks whether the input character is a white space. ...@@ -727,7 +869,7 @@ Checks whether the input character is a white space.
- Return value - Return value
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | The value **true** indicates that the input character is a white space, and value **false** indicates the opposite.| | boolean | Returns **true** if the input character is a white space; returns **false** otherwise.|
- Example - Example
``` ```
...@@ -751,7 +893,7 @@ Checks whether the input character is of the right to left (RTL) language. ...@@ -751,7 +893,7 @@ Checks whether the input character is of the right to left (RTL) language.
- Return value - Return value
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | The value **true** indicates that the input character is of the RTL language, and value **false** indicates the opposite.| | boolean | Returns **true** if the input character is of the RTL language; returns **false** otherwise.|
- Example - Example
``` ```
...@@ -775,7 +917,7 @@ Checks whether the input character is an ideographic character. ...@@ -775,7 +917,7 @@ Checks whether the input character is an ideographic character.
- Return value - Return value
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | The value **true** indicates that the input character is an ideographic character, and value **false** indicates the opposite.| | boolean | Returns **true** if the input character is an ideographic character; returns **false** otherwise.|
- Example - Example
``` ```
...@@ -799,7 +941,7 @@ Checks whether the input character is a letter. ...@@ -799,7 +941,7 @@ Checks whether the input character is a letter.
- Return value - Return value
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | The value **true** indicates that the input character is a letter, and value **false** indicates the opposite.| | boolean | Returns **true** if the input character is a letter; returns **false** otherwise.|
- Example - Example
``` ```
...@@ -823,7 +965,7 @@ Checks whether the input character is a lowercase letter. ...@@ -823,7 +965,7 @@ Checks whether the input character is a lowercase letter.
- Return value - Return value
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | The value **true** indicates that the input character is a lowercase letter, and value **false** indicates the opposite.| | boolean | Returns **true** if the input character is a lowercase letter; returns **false** otherwise.|
- Example - Example
``` ```
...@@ -847,7 +989,7 @@ Checks whether the input character is an uppercase letter. ...@@ -847,7 +989,7 @@ Checks whether the input character is an uppercase letter.
- Return value - Return value
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | The value true indicates that the input character is an uppercase letter, and value false indicates the opposite.| | boolean | Returns **true** if the input character is an uppercase letter; returns **false** otherwise.|
- Example - Example
``` ```
...@@ -1105,7 +1247,7 @@ Checks whether the position specified by the offset is a text boundary. If **tru ...@@ -1105,7 +1247,7 @@ Checks whether the position specified by the offset is a text boundary. If **tru
- Return value - Return value
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | The value **true** indicates that the position specified by the offset is a text boundary, and value **false** indicates the opposite.| | boolean | Returns **true** if the position specified by the offset is a text boundary; returns **false** otherwise.|
- Example - Example
``` ```
...@@ -1127,7 +1269,7 @@ Checks whether the 24-hour clock is used. ...@@ -1127,7 +1269,7 @@ Checks whether the 24-hour clock is used.
- Return value - Return value
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | The value **true** indicates that the 24-hour clock is used, and value **false** indicates the opposite.| | boolean | Returns **true** if the 24-hour clock is used; returns **false** otherwise.|
- Example - Example
``` ```
...@@ -1146,12 +1288,12 @@ Sets the 24-hour clock. ...@@ -1146,12 +1288,12 @@ Sets the 24-hour clock.
- Parameters - Parameters
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| option | boolean | Yes| Whether to enable the 24-hour clock. The value **true** means to enable the 24-hour clock, and value **false** means the opposite.| | option | boolean | Yes| Whether to enable the 24-hour clock. The value **true** means to enable the 24-hour clock, and the value **false** means the opposite.|
- Return value - Return value
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | The value **true** indicates that the 24-hour clock is enabled, and value **false** indicates the opposite.| | boolean | Returns **true** if the 24-hour clock is enabled; returns **false** otherwise.|
- Example - Example
``` ```
...@@ -1177,7 +1319,7 @@ Adds a preferred language to the specified position on the preferred language li ...@@ -1177,7 +1319,7 @@ Adds a preferred language to the specified position on the preferred language li
- Return value - Return value
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | The value **true** indicates that the preferred language is successfully added, and value **false** indicates the opposite.| | boolean | Returns **true** if the preferred language is successfully added; returns **false** otherwise.|
- Example - Example
``` ```
...@@ -1188,9 +1330,9 @@ Adds a preferred language to the specified position on the preferred language li ...@@ -1188,9 +1330,9 @@ Adds a preferred language to the specified position on the preferred language li
``` ```
## i18n.removeDisplayLanguage<sup>8+</sup> ## i18n.removePreferredLanguage<sup>8+</sup>
removeDisplayLanguage(index: number): boolean removePreferredLanguage(index: number): boolean
Deletes a preferred language from the specified position on the preferred language list. Deletes a preferred language from the specified position on the preferred language list.
...@@ -1204,7 +1346,7 @@ Deletes a preferred language from the specified position on the preferred langua ...@@ -1204,7 +1346,7 @@ Deletes a preferred language from the specified position on the preferred langua
- Return value - Return value
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | The value **true** indicates that the preferred language is deleted, and value **false** indicates the opposite.| | boolean | Returns **true** if the preferred language is deleted; returns **false** otherwise.|
- Example - Example
``` ```
...@@ -1218,14 +1360,14 @@ Deletes a preferred language from the specified position on the preferred langua ...@@ -1218,14 +1360,14 @@ Deletes a preferred language from the specified position on the preferred langua
getPreferredLanguageList(): Array<string> getPreferredLanguageList(): Array<string>
Obtains the preferred language list. Obtains the list of preferred languages.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Return value - Return value
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Array<string> | Preferred language list.| | Array<string> | List of preferred languages.|
- Example - Example
``` ```
...@@ -1237,16 +1379,129 @@ Obtains the preferred language list. ...@@ -1237,16 +1379,129 @@ Obtains the preferred language list.
getFirstPreferredLanguage(): string getFirstPreferredLanguage(): string
Obtains the preferred language that best matches the HAP resource. Obtains the first language in the preferred language list.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Return value - Return value
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| string | Preferred language that best matches the HAP resource.| | string | First language in the preferred language list.|
- Example - Example
``` ```
var firstPreferredLanguage = i18n.getFirstPreferredLanguage(); var firstPreferredLanguage = i18n.getFirstPreferredLanguage();
``` ```
## i18n.getTimeZone<sup>8+</sup>
getTimeZone(zoneID?: string): TimeZone
Obtains the **TimeZone** object corresponding to the specified time zone ID.
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| zondID | string | No| Time zone ID.|
- Return value
| Type| Description|
| -------- | -------- |
| TimeZone | **TimeZone** object corresponding to the time zone ID.|
- Example
```
var timezone = i18n.getTimeZone();
```
## RelativeTimeFormat<sup>8+</sup>
### getID<sup>8+</sup>
getID(): string
Obtains the ID of the specified **TimeZone** object.
**System capability**: SystemCapability.Global.I18n
- Return value
| Type| Description|
| -------- | -------- |
| string | Time zone ID corresponding to the **TimeZone** object.|
- Example
```
var timezone = i18n.getTimeZone();
timezone.getID();
```
### getDisplayName<sup>8+</sup>
getDisplayName(locale?: string, isDST?: boolean): string
Obtains the representation of a **TimeZone** object in the specified locale.
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| locale | string | No| System locale ID.|
| isDST | boolean | No| Whether to consider DST when obtaining the representation of the **TimeZone** object.|
- Return value
| Type| Description|
| -------- | -------- |
| string | Representation of the **TimeZone** object in the specified locale.|
- Example
```
var timezone = i18n.getTimeZone();
timezone.getDisplayName("zh-CN", false);
```
### getRawOffset<sup>8+</sup>
getRawOffset(): number
Obtains the offset between the time zone represented by a **TimeZone** object and the UTC time zone.
**System capability**: SystemCapability.Global.I18n
- Return value
| Type| Description|
| -------- | -------- |
| number | Offset between the time zone represented by the **TimeZone** object and the UTC time zone.|
- Example
```
var timezone = i18n.getTimeZone();
timezone.getRawOffset();
```
### getOffset<sup>8+</sup>
getOffset(date?: number): number
Obtains the offset between the time zone represented by a **TimeZone** object and the UTC time zone at a certain time point.
**System capability**: SystemCapability.Global.I18n
- Return value
| Type| Description|
| -------- | -------- |
| number | Offset between the time zone represented by the **TimeZone** object and the UTC time zone at a certain time point.|
- Example
```
var timezone = i18n.getTimeZone();
timezone.getOffset(1234567890);
```
...@@ -18,23 +18,39 @@ import Intl from '@ohos.intl'; ...@@ -18,23 +18,39 @@ import Intl from '@ohos.intl';
### Attributes ### Attributes
**System capability**: SystemCapability.Global.I18n
| Name| Type| Readable| Writable| Description| | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| language | string | Yes| No| Language associated with the locale, for example, **zh**.<br>**System capability**: SystemCapability.Global.I18n| | language | string | Yes| No| Language associated with the locale, for example, **zh**.|
| script | string | Yes| No| Script type of the language, for example, **Hans**.<br>**System capability**: SystemCapability.Global.I18n| | script | string | Yes| No| Script type of the language, for example, **Hans**.|
| region | string | Yes| No| Region associated with the locale, for example, **CN**.<br>**System capability**: SystemCapability.Global.I18n| | region | string | Yes| No| Region associated with the locale, for example, **CN**.|
| baseName | string | Yes| No| Basic key information about the locale, which consists of the language, script, and region, for example, **zh-Hans-CN**.<br>**System capability**: SystemCapability.Global.I18n| | baseName | string | Yes| No| Basic key information about the locale, which consists of the language, script, and region, for example, **zh-Hans-CN**.|
| caseFirst | string | Yes| No| Whether case is taken into account for the locale's collation rules. The value can be **upper**, **lower**, or **false**.<br>**System capability**: SystemCapability.Global.I18n| | caseFirst | string | Yes| No| Whether case is taken into account for the locale's collation rules. The value can be **upper**, **lower**, or **false**.|
| calendar | string | Yes| No| Calendar for the locale. The value can be any of the following: buddhist, chinese, coptic, dangi, ethioaa, ethiopic, gregory, hebrew, indian, islamic, islamic-umalqura, islamic-tbla, islamic-civil, islamic-rgsa, iso8601, japanese, persian, roc, islamicc.<br>**System capability**: SystemCapability.Global.I18n| | calendar | string | Yes| No| Calendar for the locale. The value can be any of the following: **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 | Yes| No| Rule for sorting regions. The value can be any of the following: big5han, compat, dict, direct, ducet, eor, gb2312, phonebk, phonetic, pinyin, reformed, searchjl, stroke, trad, unihan, zhuyin.<br>**System capability**: SystemCapability.Global.I18n| | collation | string | Yes| No| Rule for sorting regions. The value can be any of the following: **big5han**, **compat**, **dict**, **direct**, **ducet**, **eor**, **gb2312**, **phonebk**, **phonetic**, **pinyin**, **reformed**, **searchjl**, **stroke**, **trad**, **unihan**, **zhuyin**.|
| hourCycle | string | Yes| No| Time system for the locale. The value can be any of the following: h12, h23, h11, and h24.<br>**System capability**: SystemCapability.Global.I18n| | hourCycle | string | Yes| No| Time system for the locale. The value can be any of the following: **h12**, **h23**, **h11**, **h24**.|
| numberingSystem | string | Yes| No| Numbering system for the locale. The value can be any of the following: adlm, ahom, arab, arabext, bali, beng, bhks, brah, cakm, cham, deva, diak, fullwide, gong, gonm, gujr, guru, hanidec, hmng, hmnp, java, kali, khmr, knda, lana, lanatham, laoo, latn, lepc, limb, mathbold, mathdbl, mathmono, mathsanb, mathsans, mlym, modi, mong, mroo, mtei, mymr, mymrshan, mymrtlng, newa, nkoo, olck, orya, osma, rohg, saur, segment, shrd, sind, sinh, sora, sund, takr, talu, tamldec, telu, thai, tibt, tirh, vaii, wara, wcho.<br>**System capability**: SystemCapability.Global.I18n| | numberingSystem | string | Yes| No| Numbering system for the locale. The value can be any of the following: **adlm**, **ahom**, **arab**, **arabext**, **bali**, **beng**, **bhks**, **brah**, **cakm**, **cham**, **deva**, **diak**, **fullwide**, **gong**, **gonm**, **gujr**, **guru**, **hanidec**, **hmng**, **hmnp**, **java**, **kali**, **khmr**, **knda**, **lana**, **lanatham**, **laoo**, **latn**, **lepc**, **limb**, **mathbold**, **mathdbl**, **mathmono**, **mathsanb**, **mathsans**, **mlym**, **modi**, **mong**, **mroo**, **mtei**, **mymr**, **mymrshan**, **mymrtlng**, **newa**, **nkoo**, **olck**, **orya**, **osma**, **rohg**, **saur**, **segment**, **shrd**, **sind**, **sinh**, **sora**, **sund**, **takr**, **talu**, **tamldec**, **telu**, **thai**, **tibt**, **tirh**, **vaii**, **wara**, **wcho**.|
| numeric | boolean | Yes| No| Whether to apply special collation rules for numeric characters.<br>**System capability**: SystemCapability.Global.I18n| | numeric | boolean | Yes| No| Whether to apply special collation rules for numeric characters.|
### constructor<sup>8+</sup>
constructor()
Creates a Locale object.
**System capability**: SystemCapability.Global.I18n
- Example
```
var locale = new Intl.Locale();
```
### constructor ### constructor
constructor(locale: string, options?: options) constructor(locale: string, options?: LocaleOptions)
Creates a Locale object. Creates a Locale object.
...@@ -44,7 +60,7 @@ Creates a Locale object. ...@@ -44,7 +60,7 @@ Creates a Locale object.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| locale | string | Yes| A string containing locale information, including the language, optional script, and region.| | locale | string | Yes| A string containing locale information, including the language, optional script, and region.|
| options | options | No| Options for creating the **Locale** object.| | options | LocaleOptions | No| Options for creating the **Locale** object.|
- Example - Example
``` ```
...@@ -112,32 +128,42 @@ Minimizes information of the **Locale** object. If the script and locale informa ...@@ -112,32 +128,42 @@ Minimizes information of the **Locale** object. If the script and locale informa
``` ```
## LocaleOptions
Represents the locale options.
**System capability**: SystemCapability.Global.I18n
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| calendar | string | Yes| Yes| Calendar for the locale. The calue can be any of the following: **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 | Yes| Yes| Collation rule. The value can be any of the following: **big5han**, **compat**, **dict**, **direct**, **ducet**, **emoji**, **eor**, **gb2312**, **phonebk**, **phonetic**, **pinyin**, **reformed**, **search**, **searchjl**, **standard**, **stroke**, **trad**, **unihan**, **zhuyin**.|
| hourCycle | string | Yes| Yes| Time system for the locale. The value can be any of the following: **h11**, **h12**, **h23**, **h24**.|
| numberingSystem | string | Yes| Yes| Numbering system for the locale. The value can be any of the following: **adlm**, **ahom**, **arab**, **arabext**, **bali**, **beng**, **bhks**, **brah**, **cakm**, **cham**, **deva**, **diak**, **fullwide**, **gong**, **gonm**, **gujr**, **guru**, **hanidec**, **hmng**, **hmnp**, **java**, **kali**, **khmr**, **knda**, **lana**, **lanatham**, **laoo**, **latn**, **lepc**, **limb**, **mathbold**, **mathdbl**, **mathmono**, **mathsanb**, **mathsans**, **mlym**, **modi**, **mong**, **mroo**, **mtei**, **mymr**, **mymrshan**, **mymrtlng**, **newa**, **nkoo**, **olck**, **orya**, **osma**, **rohg**, **saur**, **segment**, **shrd**, **sind**, **sinh**, **sora**, **sund**, **takr**, **talu**, **tamldec**, **telu**, **thai**, **tibt**, **tirh**, **vaii**, **wara**, **wcho**.|
| numeric | boolean | Yes| Yes| Whether to use the 12-hour clock.|
| caseFirst | string | Yes| Yes| Whether upper case or lower case is sorted first. The value can be **upper**, **lower**, or **false**.|
## DateTimeFormat ## DateTimeFormat
### constructor ### constructor<sup>8+</sup>
constructor(locale: string, options?: DateTimeOptions) constructor()
Creates a **DateTimeOptions** object for the specified locale. Creates a **DateTimeOptions** object for the specified locale.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| locale | string | Yes| A string containing locale information, including the language, optional script, and region.|
| options | [DateTimeOptions](#datetimeoptions) | No| Options for creating a **DateTimeFormat** object.|
- Example - Example
``` ```
var datefmt= new Intl.DateTimeFormat("zh-CN", { dateStyle: 'full', timeStyle: 'medium' }); var datefmt= new Intl.DateTimeFormat();
``` ```
### constructor ### constructor
constructor(locales: Array&lt;string&gt;, options?: DateTimeOptions) constructor(locale: string | Array<string>, options?: DateTimeOptions)
Creates a **DateTimeOptions** object for the specified locale. Creates a **DateTimeOptions** object for the specified locale.
...@@ -146,9 +172,15 @@ Creates a **DateTimeOptions** object for the specified locale. ...@@ -146,9 +172,15 @@ Creates a **DateTimeOptions** object for the specified locale.
- Parameters - Parameters
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| locales | Array&lt;string&gt; | Yes| An array of strings containing locale information.| | locale | string \| Array<string> | Yes| A string containing locale information, including the language, optional script, and region.|
| options | [DateTimeOptions](#datetimeoptions) | No| Options for creating a **DateTimeFormat** object.| | options | [DateTimeOptions](#datetimeoptions) | No| Options for creating a **DateTimeFormat** object.|
- Example
```
var datefmt= new Intl.DateTimeFormat("zh-CN", { dateStyle: 'full', timeStyle: 'medium' });
```
- Example - Example
``` ```
var datefmt= new Intl.DateTimeFormat(["ban", "zh"], { dateStyle: 'full', timeStyle: 'medium' }); var datefmt= new Intl.DateTimeFormat(["ban", "zh"], { dateStyle: 'full', timeStyle: 'medium' });
...@@ -183,7 +215,7 @@ Formats the specified date and time. ...@@ -183,7 +215,7 @@ Formats the specified date and time.
### formatRange ### formatRange
formatRange(fromDate: Date, toDate: Date): string formatRange(startDate: Date, endDate: Date): string
Formats the specified date range. Formats the specified date range.
...@@ -233,69 +265,65 @@ Obtains the formatting options for **DateTimeFormat** object. ...@@ -233,69 +265,65 @@ Obtains the formatting options for **DateTimeFormat** object.
Provides the options for the **DateTimeFormat** object. Provides the options for the **DateTimeFormat** object.
**System capability**: SystemCapability.Global.I18n
| Name| Type| Readable| Writable| Description| | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| locale | string | Yes| No| Locale, for example, **zh-Hans-CN**.<br>**System capability**: SystemCapability.Global.I18n| | locale | string | Yes| No| Locale, for example, **zh-Hans-CN**.|
| dateStyle | string | Yes| Yes| Date display format. The value can be **long**, **short**, **medium**, or **full**.<br>**System capability**: SystemCapability.Global.I18n| | dateStyle | string | Yes| Yes| Date display format. The value can be **long**, **short**, **medium**, or **full**.|
| timeStyle | string | Yes| Yes| Time display format. The value can be **long**, **short**, **medium**, or **full**.<br>**System capability**: SystemCapability.Global.I18n| | timeStyle | string | Yes| Yes| Time display format. The value can be **long**, **short**, **medium**, or **full**.|
| hourCycle | string | Yes| Yes| Time system for the locale. The value can be any of the following: h11, h12, h23, h24.<br>**System capability**: SystemCapability.Global.I18n| | hourCycle | string | Yes| Yes| Time system for the locale. The value can be any of the following: **h11**, **h12**, **h23**, **h24**.|
| timeZone | string | Yes| Yes| Time zone represented by a valid IANA time zone ID.<br>**System capability**: SystemCapability.Global.I18n| | timeZone | string | Yes| Yes| Time zone represented by a valid IANA time zone ID.|
| numberingSystem | string | Yes| Yes| Numbering system for the locale. The value can be any of the following: adlm, ahom, arab, arabext, bali, beng, bhks, brah, cakm, cham, deva, diak, fullwide, gong, gonm, gujr, guru, hanidec, hmng, hmnp, java, kali, khmr, knda, lana, lanatham, laoo, latn, lepc, limb, mathbold, mathdbl, mathmono, mathsanb, mathsans, mlym, modi, mong, mroo, mtei, mymr, mymrshan, mymrtlng, newa, nkoo, olck, orya, osma, rohg, saur, segment, shrd, sind, sinh, sora, sund, takr, talu, tamldec, telu, thai, tibt, tirh, vaii, wara, wcho.<br>**System capability**: SystemCapability.Global.I18n| | numberingSystem | string | Yes| Yes| Numbering system for the locale. The value can be any of the following: **adlm**, **ahom**, **arab**, **arabext**, **bali**, **beng**, **bhks**, **brah**, **cakm**, **cham**, **deva**, **diak**, **fullwide**, **gong**, **gonm**, **gujr**, **guru**, **hanidec**, **hmng**, **hmnp**, **java**, **kali**, **khmr**, **knda**, **lana**, **lanatham**, **laoo**, **latn**, **lepc**, **limb**, **mathbold**, **mathdbl**, **mathmono**, **mathsanb**, **mathsans**, **mlym**, **modi**, **mong**, **mroo**, **mtei**, **mymr**, **mymrshan**, **mymrtlng**, **newa**, **nkoo**, **olck**, **orya**, **osma**, **rohg**, **saur**, **segment**, **shrd**, **sind**, **sinh**, **sora**, **sund**, **takr**, **talu**, **tamldec**, **telu**, **thai**, **tibt**, **tirh**, **vaii**, **wara**, **wcho**.|
| hour12 | boolean | Yes| Yes| Whether to use the 12-hour clock.<br>**System capability**: SystemCapability.Global.I18n| | hour12 | boolean | Yes| Yes| Whether to use the 12-hour clock.|
| weekday | string | Yes| Yes| Workday display format. The value can be **long**, **short**, or **narrow**.<br>**System capability**: SystemCapability.Global.I18n| | weekday | string | Yes| Yes| Workday display format. The value can be **long**, **short**, or **narrow**.|
| era | string | Yes| Yes| Era display format. The value can be **long**, **short**, or **narrow**.<br>**System capability**: SystemCapability.Global.I18n| | era | string | Yes| Yes| Era display format. The value can be **long**, **short**, or **narrow**.|
| year | string | Yes| Yes| Year display format. The value can be **numeric** or **2-digit**. <br>**System capability**: SystemCapability.Global.I18n| | year | string | Yes| Yes| Year display format. The value can be **numeric** or **2-digit**. |
| month | string | Yes| Yes| Month display format. The value can be any of the following: numeric, 2-digit, long, short, narrow.<br>**System capability**: SystemCapability.Global.I18n| | month | string | Yes| Yes| Month display format. The value can be any of the following: **numeric**, **2-digit**, **long**, **short**, **narrow**.|
| day | string | Yes| Yes| Day display format. The value can be **numeric** or **2-digit**.<br>**System capability**: SystemCapability.Global.I18n| | day | string | Yes| Yes| Day display format. The value can be **numeric** or **2-digit**.|
| hour | string | Yes| Yes| Hour display format. The value can be **numeric** or **2-digit**.<br>**System capability**: SystemCapability.Global.I18n| | hour | string | Yes| Yes| Hour display format. The value can be **numeric** or **2-digit**.|
| minute | string | Yes| Yes| Minute display format. The value can be **numeric** or **2-digit**.<br>**System capability**: SystemCapability.Global.I18n| | minute | string | Yes| Yes| Minute display format. The value can be **numeric** or **2-digit**.|
| second | string | Yes| Yes| Seconds display format. The value can be **numeric** or **2-digit**.<br>**System capability**: SystemCapability.Global.I18n| | second | string | Yes| Yes| Seconds display format. The value can be **numeric** or **2-digit**.|
| timeZoneName | string | Yes| Yes| Localized representation of a time zone name.<br>**System capability**: SystemCapability.Global.I18n| | timeZoneName | string | Yes| Yes| Localized representation of a time zone name.|
| dayPeriod | string | Yes| Yes| Time period display format. The value can be **long**, **short**, or **narrow**.<br>**System capability**: SystemCapability.Global.I18n| | dayPeriod | string | Yes| Yes| Time period display format. The value can be **long**, **short**, or **narrow**.|
| localeMatcher | string | Yes| Yes| Locale matching algorithm. The value can be **lookup** or **best fit**.<br>**System capability**: SystemCapability.Global.I18n| | localeMatcher | string | Yes| Yes| Locale matching algorithm. The value can be **lookup** or **best fit**.|
| formatMatcher | string | Yes| Yes| Format matching algorithm. The value can be **basic** or **best fit**.<br>**System capability**: SystemCapability.Global.I18n| | formatMatcher | string | Yes| Yes| Format matching algorithm. The value can be **basic** or **best fit**.|
## NumberFormat ## NumberFormat
### constructor ### constructor<sup>8+</sup>
constructor(locale: string, options?: NumberOptions) constructor()
Creates a **NumberFormat** object for the specified locale. Creates a **NumberFormat** object for the specified locale.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| locale | string | Yes| A string containing locale information, including the language, optional script, and region.|
| options | [NumberOptions](#numberoptions) | No| Options for creating a **NumberFormat** object.|
- Example - Example
``` ```
var numfmt = new Intl.NumberFormat("en-GB", {style:'decimal', notation:"scientific"}); var numfmt = new Intl.NumberFormat();
``` ```
### constructor ### constructor
constructor(locales: Array&lt;string&gt;, options?: NumberOptions) constructor(locale: string | Array<string>, options?: NumberOptions)
Creates a **NumberFormat** object for the specified locale. Creates a **NumberFormat** object for the specified locale.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
- Parameters Parameters
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| locales | Array&lt;string&gt; | Yes| An array of strings containing locale information.| | locale | string \| Array<string> | Yes| A string containing locale information, including the language, optional script, and region.|
| options | [NumberOptions](#numberoptions) | No| Options for creating a **NumberFormat** object.| | options | [NumberOptions](#numberoptions) | No| Options for creating a **NumberFormat** object.|
- Example - Example
``` ```
var numfmt = new Intl.NumberFormat(["en-GB", "zh"], {style:'decimal', notation:"scientific"}); var numfmt = new Intl.NumberFormat("en-GB", {style:'decimal', notation:"scientific"});
``` ```
...@@ -350,27 +378,29 @@ Obtains the options of the **NumberFormat** object. ...@@ -350,27 +378,29 @@ Obtains the options of the **NumberFormat** object.
Provides the device capability. Provides the device capability.
**System capability**: SystemCapability.Global.I18n
| Name| Type| Readable| Writable| Description| | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| locale | string | Yes| No| Locale, for example, **zh-Hans-CN**.<br>**System capability**: SystemCapability.Global.I18n| | locale | string | Yes| No| Locale, for example, **zh-Hans-CN**.|
| currency | string | Yes| Yes| Currency unit, for example, **EUR**, **CNY**, or **USD**.<br>**System capability**: SystemCapability.Global.I18n| | currency | string | Yes| Yes| Currency unit, for example, **EUR**, **CNY**, or **USD**.|
| currencySign | string | Yes| Yes| Currency unit symbol. The value can be **symbol**, **narrowSymbol**, **code**, or **name**.<br>**System capability**: SystemCapability.Global.I18n| | currencySign | string | Yes| Yes| Currency unit symbol. The value can be **symbol**, **narrowSymbol**, **code**, or **name**.|
| currencyDisplay | string | Yes| Yes| Currency display mode. The value can be **symbol**, **narrowSymbol**, **code**, or **name**.<br>**System capability**: SystemCapability.Global.I18n| | currencyDisplay | string | Yes| Yes| Currency display mode. The value can be **symbol**, **narrowSymbol**, **code**, or **name**.|
| unit | string | Yes| Yes| Unit name, for example, **meter**, **inch**, or **hectare**.<br>**System capability**: SystemCapability.Global.I18n| | unit | string | Yes| Yes| Unit name, for example, **meter**, **inch**, or **hectare**.|
| unitDisplay | string | Yes| Yes| Unit display format. The value can be **long**, **short**, or **medium**.<br>**System capability**: SystemCapability.Global.I18n| | unitDisplay | string | Yes| Yes| Unit display format. The value can be **long**, **short**, or **medium**.|
| unitUsage | string | Yes| Yes| Unit usage scenario. The value can be any of the following: default, area-land-agricult, area-land-commercl, area-land-residntl, length-person, length-person-small, length-rainfall, length-road, length-road-small, length-snowfall, length-vehicle, length-visiblty, length-visiblty-small, length-person-informal, length-person-small-informal, length-road-informal, speed-road-travel, speed-wind, temperature-person, temperature-weather, volume-vehicle-fuel.<br>**System capability**: SystemCapability.Global.I18n| | unitUsage | string | Yes| Yes| Unit usage scenario. The value can be any of the following: **default**, **area-land-agricult**, **area-land-commercl**, **area-land-residntl**, **length-person**, **length-person-small**, **length-rainfall**, **length-road**, **length-road-small**, **length-snowfall**, **length-vehicle**, **length-visiblty**, **length-visiblty-small**, **length-person-informal**, **length-person-small-informal**, **length-road-informal**, **speed-road-travel**, **speed-wind**, **temperature-person**, **temperature-weather**, **volume-vehicle-fuel**.|
| signDisplay | string | Yes| Yes| Number sign display format. The value can be **auto**, **never**, always**, or **expectZero**.<br>**System capability**: SystemCapability.Global.I18n| | signDisplay | string | Yes| Yes| Number sign display format. The value can be **auto**, **never**, always**, or **expectZero**.|
| compactDisplay | string | Yes| Yes| Compact display format. The value can be **long** or **short**.<br>**System capability**: SystemCapability.Global.I18n| | compactDisplay | string | Yes| Yes| Compact display format. The value can be **long** or **short**.|
| notation | string | Yes| Yes| Number formatting specification. The value can be **standard**, **scientific**, engineering**, or **compact**.<br>**System capability**: SystemCapability.Global.I18n| | notation | string | Yes| Yes| Number formatting specification. The value can be **standard**, **scientific**, engineering**, or **compact**.|
| localeMatcher | string | Yes| Yes| Locale matching algorithm. The value can be **lookup** or **best fit**.<br>**System capability**: SystemCapability.Global.I18n| | localeMatcher | string | Yes| Yes| Locale matching algorithm. The value can be **lookup** or **best fit**.|
| style | string | Yes| Yes| Number display format. The value can be **decimal**, **currency**, **percent**, or **unit**.<br>**System capability**: SystemCapability.Global.I18n| | style | string | Yes| Yes| Number display format. The value can be **decimal**, **currency**, **percent**, or **unit**.|
| numberingSystem | string | Yes| Yes| Numbering system for the locale. The value can be any of the following: adlm, ahom, arab, arabext, bali, beng, bhks, brah, cakm, cham, deva, diak, fullwide, gong, gonm, gujr, guru, hanidec, hmng, hmnp, java, kali, khmr, knda, lana, lanatham, laoo, latn, lepc, limb, mathbold, mathdbl, mathmono, mathsanb, mathsans, mlym, modi, mong, mroo, mtei, mymr, mymrshan, mymrtlng, newa, nkoo, olck, orya, osma, rohg, saur, segment, shrd, sind, sinh, sora, sund, takr, talu, tamldec, telu, thai, tibt, tirh, vaii, wara, wcho.<br>**System capability**: SystemCapability.Global.I18n| | numberingSystem | string | Yes| Yes| Numbering system for the locale. The value can be any of the following: **adlm**, **ahom**, **arab**, **arabext**, **bali**, **beng**, **bhks**, **brah**, **cakm**, **cham**, **deva**, **diak**, **fullwide**, **gong**, **gonm**, **gujr**, **guru**, **hanidec**, **hmng**, **hmnp**, **java**, **kali**, **khmr**, **knda**, **lana**, **lanatham**, **laoo**, **latn**, **lepc**, **limb**, **mathbold**, **mathdbl**, **mathmono**, **mathsanb**, **mathsans**, **mlym**, **modi**, **mong**, **mroo**, **mtei**, **mymr**, **mymrshan**, **mymrtlng**, **newa**, **nkoo**, **olck**, **orya**, **osma**, **rohg**, **saur**, **segment**, **shrd**, **sind**, **sinh**, **sora**, **sund**, **takr**, **talu**, **tamldec**, **telu**, **thai**, **tibt**, **tirh**, **vaii**, **wara**, **wcho**.|
| useGrouping | boolean | Yes| Yes| Whether to use grouping for display.<br>**System capability**: SystemCapability.Global.I18n| | useGrouping | boolean | Yes| Yes| Whether to use grouping for display.|
| miniumumIntegerDigits | number | Yes| Yes| Minimum number of digits allowed in the integer part of a number. The value ranges from **1** to **21**.<br>**System capability**: SystemCapability.Global.I18n| | minimumIntegerDigits | number | Yes| Yes| Minimum number of digits allowed in the integer part of a number. The value ranges from **1** to **21**.|
| miniumumFractionDigits | number | Yes| Yes| Minimum number of digits in the fraction part of a number. The value ranges from **1** to **20**.<br>**System capability**: SystemCapability.Global.I18n| | minimumFractionDigits | number | Yes| Yes| Minimum number of digits in the fraction part of a number. The value ranges from **0** to **20**.|
| maxiumumFractionDigits | number | Yes| Yes| Maximum number of digits in the fraction part of a number. The value ranges from **1** to **21**.<br>**System capability**: SystemCapability.Global.I18n| | maximumFractionDigits | number | Yes| Yes| Maximum number of digits in the fraction part of a number. The value ranges from **1** to **21**.|
| miniumumSignificantDigits | number | Yes| Yes| Minimum number of the least significant digits. The value ranges from **1** to **21**.<br>**System capability**: SystemCapability.Global.I18n| | minimumSignificantDigits | number | Yes| Yes| Minimum number of the least significant digits. The value ranges from **1** to **21**.|
| maxiumumSignificantDigits | number | Yes| Yes| Maximum number of the least significant digits. The value ranges from **1** to **21**.<br>**System capability**: SystemCapability.Global.I18n| | maximumSignificantDigits | number | Yes| Yes| Maximum number of the least significant digits. The value ranges from **1** to **21**.|
## Collator<sup>8+</sup> ## Collator<sup>8+</sup>
...@@ -392,7 +422,7 @@ Creates a Collator object. ...@@ -392,7 +422,7 @@ Creates a Collator object.
### constructor<sup>8+</sup> ### constructor<sup>8+</sup>
constructor(locale: string | Array&lt;string&gt;, options?: CollatorOptions) constructor(locale: string | Array<string>, options?: CollatorOptions)
Creates a Collator object. Creates a Collator object.
...@@ -402,12 +432,12 @@ Creates a Collator object. ...@@ -402,12 +432,12 @@ Creates a Collator object.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| locale | string\|Array&lt;string&gt; | Yes| A string containing locale information, including the language, optional script, and region.| | locale | string \| Array<string> | Yes| A string containing locale information, including the language, optional script, and region.|
| options | [CollatorOptions](#collatoroptions) | No| Options for creating a **Collator** object.| | options | [CollatorOptions](#collatoroptions) | No| Options for creating a **Collator** object.|
- Example - Example
``` ```
var collator = new Intl.Collator("zh-CN", {"localeMatcher": "lookup", "usage": "sort"}); var collator = new Intl.Collator("zh-CN", {localeMatcher: "lookup", usage: "sort"});
``` ```
...@@ -461,15 +491,17 @@ Returns properties reflecting the locale and collation options of a **Collator** ...@@ -461,15 +491,17 @@ Returns properties reflecting the locale and collation options of a **Collator**
Represents the properties of a **Collator** object. Represents the properties of a **Collator** object.
**System capability**: SystemCapability.Global.I18n
| Name| Type| Readable| Writable| Description| | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| localeMatcher | string | Yes| Yes| Locale matching algorithm. The value can be **lookup** or **best fit**.<br>**System capability**: SystemCapability.Global.I18n| | localeMatcher | string | Yes| Yes| Locale matching algorithm. The value can be **lookup** or **best fit**.|
| usage | string | Yes| Yes| Whether the comparison is for sorting or for searching. The value can be **sort** or **search**.<br>**System capability**: SystemCapability.Global.I18n| | usage | string | Yes| Yes| Whether the comparison is for sorting or for searching. The value can be **sort** or **search**.|
| sensitivity | string | Yes| Yes| Differences in the strings that lead to non-zero return values. The value can be **base**, **accent**, **case**, or **variant**.<br>**System capability**: SystemCapability.Global.I18n| | sensitivity | string | Yes| Yes| Differences in the strings that lead to non-zero return values. The value can be **base**, **accent**, **case**, or **variant**.|
| ignorePunctuation | boolean | Yes| Yes| Whether punctuation is ignored. The value can be **true** or **false**.<br>**System capability**: SystemCapability.Global.I18n| | ignorePunctuation | boolean | Yes| Yes| Whether punctuation is ignored. The value can be **true** or **false**.|
| collation | string | Yes| Yes| Rule for sorting regions. The value can be any of the following: big5han, compat, dict, direct, ducet, eor, gb2312, phonebk, phonetic, pinyin, reformed, searchjl, stroke, trad, unihan, zhuyin.<br>**System capability**: SystemCapability.Global.I18n| | collation | string | Yes| Yes| Rule for sorting regions. The value can be any of the following: **big5han**, **compat**, **dict**, **direct**, **ducet**, **eor**, **gb2312**, **phonebk**, **phonetic**, **pinyin**, **reformed**, **searchjl**, **stroke**, **trad**, **unihan**, **zhuyin**.|
| numeric | boolean | Yes| Yes| Whether numeric collation is used. The value can be **true** or **false**.<br>**System capability**: SystemCapability.Global.I18n| | numeric | boolean | Yes| Yes| Whether numeric collation is used. The value can be **true** or **false**.|
| caseFirst | string | Yes| Yes| Whether upper case or lower case is sorted first. The value can be **upper**, **lower**, or **false**.<br>**System capability**: SystemCapability.Global.I18n| | caseFirst | string | Yes| Yes| Whether upper case or lower case is sorted first. The value can be **upper**, **lower**, or **false**.|
## PluralRules<sup>8+</sup> ## PluralRules<sup>8+</sup>
...@@ -491,7 +523,7 @@ Create a **PluralRules** object. ...@@ -491,7 +523,7 @@ Create a **PluralRules** object.
### constructor<sup>8+</sup> ### constructor<sup>8+</sup>
constructor(locale: string | Array&lt;string&gt;, options?: PluralRulesOptions) constructor(locale: string | Array<string>, options?: PluralRulesOptions)
Create a **PluralRules** object. Create a **PluralRules** object.
...@@ -500,7 +532,7 @@ Create a **PluralRules** object. ...@@ -500,7 +532,7 @@ Create a **PluralRules** object.
Parameters Parameters
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| locale | string\|Array&lt;string&gt; | Yes| A string containing locale information, including the language, optional script, and region.| | locale | string \| Array<string> | Yes| A string containing locale information, including the language, optional script, and region.|
| options | [PluralRulesOptions](#pluralrulesoptions) | No| Options for creating a **PluralRules** object.| | options | [PluralRulesOptions](#pluralrulesoptions) | No| Options for creating a **PluralRules** object.|
- Example - Example
...@@ -525,7 +557,7 @@ Obtains a string that represents the singular-plural type of the specified numbe ...@@ -525,7 +557,7 @@ Obtains a string that represents the singular-plural type of the specified numbe
- Return value - Return value
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| string | Singular-plural type. The value can be any of the following: one, two, few, many, others.| | string | Singular-plural type. The value can be any of the following: **one**, **two**, **few**, **many**, **others**.|
- Example - Example
``` ```
...@@ -538,15 +570,17 @@ Obtains a string that represents the singular-plural type of the specified numbe ...@@ -538,15 +570,17 @@ Obtains a string that represents the singular-plural type of the specified numbe
Represents the properties of a **PluralRules** object. Represents the properties of a **PluralRules** object.
**System capability**: SystemCapability.Global.I18n
| Name| Type| Readable| Writable| Description| | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| localeMatcher | string | Yes| Yes| Locale matching algorithm. The value can be **lookup** or **best fit**.<br>**System capability**: SystemCapability.Global.I18n| | localeMatcher | string | Yes| Yes| Locale matching algorithm. The value can be **lookup** or **best fit**.|
| type | string | Yes| Yes| Sorting type. The value can be **cardinal** or **ordinal**.<br>**System capability**: SystemCapability.Global.I18n| | type | string | Yes| Yes| Sorting type. The value can be **cardinal** or **ordinal**.|
| minimumIntegerDigits | number | Yes| Yes| Minimum number of digits allowed in the integer part of a number. The value ranges from **1** to **21**.<br>**System capability**: SystemCapability.Global.I18n| | minimumIntegerDigits | number | Yes| Yes| Minimum number of digits allowed in the integer part of a number. The value ranges from **1** to **21**.|
| minimumFractionDigits | number | Yes| Yes| Minimum number of digits in the fraction part of a number. The value ranges from **0** to **20**.<br>**System capability**: SystemCapability.Global.I18n| | minimumFractionDigits | number | Yes| Yes| Minimum number of digits in the fraction part of a number. The value ranges from **0** to **20**.|
| maximumFractionDigits | number | Yes| Yes| Maximum number of digits in the fraction part of a number. The value ranges from **1** to **21**.<br>**System capability**: SystemCapability.Global.I18n| | maximumFractionDigits | number | Yes| Yes| Maximum number of digits in the fraction part of a number. The value ranges from **1** to **21**.|
| minimumSignificantDigits | number | Yes| Yes| Minimum number of the least significant digits. The value ranges from **1** to **21**.<br>**System capability**: SystemCapability.Global.I18n| | minimumSignificantDigits | number | Yes| Yes| Minimum number of the least significant digits. The value ranges from **1** to **21**.|
| maximumSignificantDigits | number | Yes| Yes| Maximum number of the least significant digits. The value ranges from **1** to **21**.<br>**System capability**: SystemCapability.Global.I18n| | maximumSignificantDigits | number | Yes| Yes| Maximum number of the least significant digits. The value ranges from **1** to **21**.|
## RelativeTimeFormat<sup>8+</sup> ## RelativeTimeFormat<sup>8+</sup>
...@@ -568,7 +602,7 @@ Creates a **RelativeTimeFormat** object. ...@@ -568,7 +602,7 @@ Creates a **RelativeTimeFormat** object.
### constructor<sup>8+</sup> ### constructor<sup>8+</sup>
constructor(locale: string | Array&lt;string&gt;, options?: RelativeTimeFormatInputOptions) constructor(locale: string | Array<string>, options?: RelativeTimeFormatInputOptions)
Creates a **RelativeTimeFormat** object. Creates a **RelativeTimeFormat** object.
...@@ -577,7 +611,7 @@ Creates a **RelativeTimeFormat** object. ...@@ -577,7 +611,7 @@ Creates a **RelativeTimeFormat** object.
Parameters Parameters
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| locale | string\|Array&lt;string&gt; | Yes| A string containing locale information, including the language, optional script, and region.| | locale | string \| Array<string> | Yes| A string containing locale information, including the language, optional script, and region.|
| options | [RelativeTimeFormatInputOptions](#relativetimeformatinputoptions) | No| Options for creating a **RelativeTimeFormat** object.| | options | [RelativeTimeFormatInputOptions](#relativetimeformatinputoptions) | No| Options for creating a **RelativeTimeFormat** object.|
- Example - Example
...@@ -588,7 +622,7 @@ Parameters ...@@ -588,7 +622,7 @@ Parameters
### format<sup>8+</sup> ### format<sup>8+</sup>
format(value: numeric, unit: string): string format(value: number, unit: string): string
Formats the value and unit based on the specified locale and formatting options. Formats the value and unit based on the specified locale and formatting options.
...@@ -597,8 +631,8 @@ Formats the value and unit based on the specified locale and formatting options. ...@@ -597,8 +631,8 @@ Formats the value and unit based on the specified locale and formatting options.
- Parameters - Parameters
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | numeric | Yes| Value to format.| | value | number | Yes| Value to format.|
| unit | string | Yes| Unit to format. The value can be any of the following: year, quarter, month, week, day, hour, minute, second.| | unit | string | Yes| Unit to format. The value can be any of the following: **year**, **quarter**, **month**, **week**, **day**, **hour**, **minute**, **second**.|
- Return value - Return value
| Type| Description| | Type| Description|
...@@ -614,7 +648,7 @@ Formats the value and unit based on the specified locale and formatting options. ...@@ -614,7 +648,7 @@ Formats the value and unit based on the specified locale and formatting options.
### formatToParts<sup>8+</sup> ### formatToParts<sup>8+</sup>
formatToParts(value: numeric, unit: string): Array&lt;Object&gt; formatToParts(value: number, unit: string): Array<object>
Returns an array of RelativeTimeFormat objects in parts for locale-aware formatting. Returns an array of RelativeTimeFormat objects in parts for locale-aware formatting.
...@@ -623,13 +657,13 @@ Returns an array of RelativeTimeFormat objects in parts for locale-aware formatt ...@@ -623,13 +657,13 @@ Returns an array of RelativeTimeFormat objects in parts for locale-aware formatt
- Parameters - Parameters
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| value | numeric | Yes| Value to format.| | value | number | Yes| Value to format.|
| unit | string | Yes| Unit to format. The value can be any of the following: year, quarter, month, week, day, hour, minute, second.| | unit | string | Yes| Unit to format. The value can be any of the following: **year**, **quarter**, **month**, **week**, **day**, **hour**, **minute**, **second**.|
- Return value - Return value
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Array&lt;Object&gt; | An array of **RelativeTimeFormat** objects in parts.| | Array<object> | An array of **RelativeTimeFormat** objects in parts.|
- Example - Example
``` ```
...@@ -662,20 +696,24 @@ Obtains the formatting options for **RelativeTimeFormat** objects. ...@@ -662,20 +696,24 @@ Obtains the formatting options for **RelativeTimeFormat** objects.
Represents the properties of a **RelativeTimeFormat** object. Represents the properties of a **RelativeTimeFormat** object.
**System capability**: SystemCapability.Global.I18n
| Name| Type| Readable| Writable| Description| | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| localeMatcher | string | Yes| Yes| Locale matching algorithm. The value can be **lookup** or **best fit**.<br>**System capability**: SystemCapability.Global.I18n| | localeMatcher | string | Yes| Yes| Locale matching algorithm. The value can be **lookup** or **best fit**.|
| numeric | string | Yes| Yes| Format of the output message. The value can be **always** or **auto**.<br>**System capability**: SystemCapability.Global.I18n| | numeric | string | Yes| Yes| Format of the output message. The value can be **always** or **auto**.|
| style | string | Yes| Yes| Length of an internationalized message. The value can be **long**, **short**, or **narrow**.<br>**System capability**: SystemCapability.Global.I18n| | style | string | Yes| Yes| Length of an internationalized message. The value can be **long**, **short**, or **narrow**.|
## RelativeTimeFormatResolvedOptions<sup>8+</sup><a name=relativetimeformatresolvedoptions></a> ## RelativeTimeFormatResolvedOptions<sup>8+</sup><a name=relativetimeformatresolvedoptions></a>
Represents the properties of a **RelativeTimeFormat** object. Represents the properties of a **RelativeTimeFormat** object.
**System capability**: SystemCapability.Global.I18n
| Name| Type| Readable| Writable| Description| | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| locale | string | Yes| Yes| A string containing locale information, including the language, optional script, and region.<br>**System capability**: SystemCapability.Global.I18n| | locale | string | Yes| Yes| A string containing locale information, including the language, optional script, and region.|
| numeric | string | Yes| Yes| Format of the output message. The value can be **always** or **auto**.<br>**System capability**: SystemCapability.Global.I18n| | numeric | string | Yes| Yes| Format of the output message. The value can be **always** or **auto**.|
| style | string | Yes| Yes| Length of an internationalized message. The value can be **long**, **short**, or **narrow**.<br>**System capability**: SystemCapability.Global.I18n| | style | string | Yes| Yes| Length of an internationalized message. The value can be **long**, **short**, or **narrow**.|
| numberingSystem | string | Yes| Yes| Numbering system.<br>**System capability**: SystemCapability.Global.I18n| | numberingSystem | string | Yes| Yes| Numbering system.|
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册