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

!2703 翻译已完成 2326#I4ZOVF

Merge pull request !2703 from shawn_he/b2326
......@@ -2,7 +2,7 @@
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> - The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
>
> - This module contains enhanced i18n APIs, which are not defined in ECMA 402.
......@@ -21,19 +21,19 @@ Obtains the localized script for the specified language.
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| language | string | Yes| Specified language.|
| locale | string | Yes| Locale ID.|
| sentenceCase | boolean | No| Whether to use sentence case for the localized script.|
**Parameters**
| Name | Type | Mandatory | Description |
| ------------ | ------- | ---- | ---------------- |
| language | string | Yes | Specified language. |
| locale | string | Yes | Locale ID. |
| sentenceCase | boolean | No | Whether to use sentence case for the localized script.|
- Return value
| Type| Description|
| -------- | -------- |
| string | Localized script for the specified language.|
**Return Value**
| Type | Description |
| ------ | ------------- |
| string | Localized script for the specified language.|
- Example
**Example**
```
i18n.getDisplayLanguage("zh", "en-GB", true);
i18n.getDisplayLanguage("zh", "en-GB");
......@@ -48,19 +48,19 @@ Obtains the localized script for the specified country.
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| country | string | Yes| Specified country.|
| locale | string | Yes| Locale ID.|
| sentenceCase | boolean | No| Whether to use sentence case for the localized script.|
**Parameters**
| Name | Type | Mandatory | Description |
| ------------ | ------- | ---- | ---------------- |
| country | string | Yes | Specified country. |
| locale | string | Yes | Locale ID. |
| sentenceCase | boolean | No | Whether to use sentence case for the localized script.|
- Return value
| Type| Description|
| -------- | -------- |
| string | Localized script for the specified country.|
**Return Value**
| Type | Description |
| ------ | ------------- |
| string | Localized script for the specified country.|
- Example
**Example**
```
i18n.getDisplayCountry("zh-CN", "en-GB", true);
i18n.getDisplayCountry("zh-CN", "en-GB");
......@@ -75,17 +75,17 @@ Checks whether the localized script for the specified language is displayed from
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Description|
| -------- | -------- | -------- |
| locale | string | Locale ID.|
**Parameters**
| Name | Type | Description |
| ------ | ------ | ------- |
| locale | string | Locale ID.|
- Return value
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the localized script is displayed from right to left; returns **false** otherwise.|
**Return Value**
| Type | Description |
| ------- | ---------------------------------------- |
| boolean | Returns **true** if the localized script is displayed from right to left; returns **false** otherwise.|
- Example
**Example**
```
i18n.isRTL("zh-CN");// Since Chinese is not written from right to left, false is returned.
i18n.isRTL("ar-EG");// Since Arabic is written from right to left, true is returned.
......@@ -100,12 +100,12 @@ Obtains the system language.
**System capability**: SystemCapability.Global.I18n
- Return value
| Type| Description|
| -------- | -------- |
| string | System language ID.|
**Return Value**
| Type | Description |
| ------ | ------- |
| string | System language ID.|
- Example
**Example**
```
i18n.getSystemLanguage();
```
......@@ -117,19 +117,21 @@ setSystemLanguage(language: string): boolean
Sets the system language.
**Required permission**: ohos.permission.UPDATE_CONFIGURATION
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Description|
| -------- | -------- | -------- |
| language | string | Language ID.|
**Parameters**
| Name | Type | Description |
| -------- | ------ | ----- |
| language | string | Language ID.|
- Return value
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Return Value**
| Type | Description |
| ------- | ------------------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example
**Example**
```
i18n.setSystemLanguage('zh');
```
......@@ -137,18 +139,18 @@ Sets the system language.
## i18n.getSystemLanguages
getSystemLanguages(): Array<string>
getSystemLanguages(): Array&lt;string&gt;
Obtains the list of system languages.
**System capability**: SystemCapability.Global.I18n
- Return value
| Type| Description|
| -------- | -------- |
| Array<string> | List of the IDs of system languages.|
**Return Value**
| Type | Description |
| ------------------- | ------------ |
| Array&lt;string&gt; | List of the IDs of system languages.|
- Example
**Example**
```
i18n.getSystemLanguages();
```
......@@ -156,23 +158,23 @@ Obtains the list of system languages.
## i18n.getSystemCountries
getSystemCountries(language: string): Array<string>
getSystemCountries(language: string): Array&lt;string&gt;
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.|
**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.|
**Return Value**
| Type | Description |
| ------------------- | ------------ |
| Array&lt;string&gt; | List of the IDs of the countries and regions supported for the specified language.|
- Example
**Example**
```
i18n.getSystemCountries('zh');
```
......@@ -186,12 +188,12 @@ Obtains the system region.
**System capability**: SystemCapability.Global.I18n
- Return value
| Type| Description|
| -------- | -------- |
| string | System region ID.|
**Return Value**
| Type | Description |
| ------ | ------- |
| string | System region ID.|
- Example
**Example**
```
i18n.getSystemRegion();
```
......@@ -203,19 +205,21 @@ setSystemRegion(region: string): boolean
Sets the system region.
**Required permission**: ohos.permission.UPDATE_CONFIGURATION
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Description|
| -------- | -------- | -------- |
| region | string | Region ID.|
**Parameters**
| Name | Type | Description |
| ------ | ------ | ----- |
| region | string | Region ID.|
- Return value
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Return Value**
| Type | Description |
| ------- | ------------------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example
**Example**
```
i18n.setSystemRegion();
```
......@@ -229,12 +233,12 @@ Obtains the system locale.
**System capability**: SystemCapability.Global.I18n
- Return value
| Type| Description|
| -------- | -------- |
| string | System locale ID.|
**Return Value**
| Type | Description |
| ------ | ------- |
| string | System locale ID.|
- Example
**Example**
```
i18n.getSystemLocale();
```
......@@ -246,19 +250,21 @@ setSystemLocale(locale: string): boolean
Sets the system locale.
**Required permission**: ohos.permission.UPDATE_CONFIGURATION
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Description|
| -------- | -------- | -------- |
| locale | string | System locale ID, for example, **zh-CN**.|
**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.|
**Return Value**
| Type | Description |
| ------- | ---------------------------------------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
- Example
**Example**
```
i18n.setSystemLocale('zh-CN');
```
......@@ -272,18 +278,18 @@ 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**.|
**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.|
**Return Value**
| Type | Description |
| ------- | ---------------------------------------- |
| boolean | Returns **true** if the system language matches the specified region; returns **false** otherwise.|
- Example
**Example**
```
i18n.isSuggested('zh', 'CN');
```
......@@ -297,18 +303,18 @@ Obtains a **Calendar** object.
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| 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.|
**Parameters**
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | ---------------------------------------- |
| 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.|
- Return value
| Type| Description|
| -------- | -------- |
| [Calendar](#calendar8) | **Calendar** object.|
**Return Value**
| Type | Description |
| ---------------------- | ----- |
| [Calendar](#calendar8) | **Calendar** object.|
- Example
**Example**
```
i18n.getCalendar("zh-Hans", "gregory");
```
......@@ -325,12 +331,12 @@ Sets the date for this **Calendar** object.
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| date | Date | Yes| Date to be set for the **Calendar** object.|
**Parameters**
| Name | Type | Mandatory | Description |
| ---- | ---- | ---- | ----------------- |
| date | Date | Yes | Date to be set for the **Calendar** object.|
- Example
**Example**
```
var calendar = I18n.getCalendar("en-US", "gregory");
var date = new Date(2021, 10, 7, 8, 0, 0, 0);
......@@ -346,12 +352,12 @@ Sets the date and time for this **Calendar** object. The value is represented by
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| time | number | Yes| Number of milliseconds that have elapsed since the Unix epoch.|
**Parameters**
| Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ---------------------------------------- |
| time | number | Yes | Number of milliseconds that have elapsed since the Unix epoch.|
- Example
**Example**
```
var calendar = I18n.getCalendar("en-US", "gregory");
calendar.setTime(10540800000);
......@@ -366,17 +372,17 @@ Sets the year, month, day, hour, minute, and second for this **Calendar** object
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| year | number | Yes| Year to set.|
| month | number | Yes| Month to set.|
| date | number | Yes| Day to set.|
| hour | number | No| Hour to set.|
| minute | number | No| Minute to set.|
| second | number | No| Second to set.|
**Parameters**
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | ------ |
| year | number | Yes | Year to set. |
| month | number | Yes | Month to set. |
| date | number | Yes | Day to set. |
| hour | number | No | Hour to set.|
| minute | number | No | Minute to set.|
| second | number | No | Second to set. |
- Example
**Example**
```
var calendar = i18n.getCalendar("zh-Hans");
calendar.setTime(2021, 10, 1, 8, 0, 0); // set time to 2021.10.1 08:00:00
......@@ -391,12 +397,12 @@ Sets the time zone of this **Calendar** object.
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| timezone | string | Yes| Time zone, for example, **Asia/Shanghai**.|
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ------ | ---- | ------------------------- |
| timezone | string | Yes | Time zone, for example, **Asia/Shanghai**.|
- Example
**Example**
```
var calendar = i18n.getCalendar("zh-Hans");
calendar.setTimeZone("Asia/Shanghai");
......@@ -411,12 +417,12 @@ Obtains the time zone of this **Calendar** object.
**System capability**: SystemCapability.Global.I18n
- Return value
| Type| Description|
| -------- | -------- |
| string | Time zone of the **Calendar** object.|
**Return Value**
| Type | Description |
| ------ | ---------- |
| string | Time zone of the **Calendar** object.|
- Example
**Example**
```
var calendar = i18n.getCalendar("zh-Hans");
calendar.setTimeZone("Asia/Shanghai");
......@@ -432,12 +438,12 @@ Obtains the start day of a week for this **Calendar** object.
**System capability**: SystemCapability.Global.I18n
- Return value
| Type| Description|
| -------- | -------- |
| number | Start day of a week. The value **1** indicates Sunday, and the value **7** indicates Saturday.|
**Return Value**
| Type | Description |
| ------ | --------------------- |
| number | Start day of a week. The value **1** indicates Sunday, and the value **7** indicates Saturday.|
- Example
**Example**
```
var calendar = I18n.getCalendar("en-US", "gregory");
calendar.getFirstDayOfWeek();
......@@ -452,12 +458,12 @@ Sets the start day of a week for this **Calendar** object.
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | number | No| Start day of a week. The value **1** indicates Sunday, and the value **7** indicates Saturday.|
**Parameters**
| Name | Type | Mandatory | Description |
| ----- | ------ | ---- | --------------------- |
| value | number | No | Start day of a week. The value **1** indicates Sunday, and the value **7** indicates Saturday.|
- Example
**Example**
```
var calendar = i18n.getCalendar("zh-Hans");
calendar.setFirstDayOfWeek(0);
......@@ -472,12 +478,12 @@ Obtains the minimum number of days in the first week of a year.
**System capability**: SystemCapability.Global.I18n
- Return value
| Type| Description|
| -------- | -------- |
| number | Minimum number of days in the first week of a year.|
**Return Value**
| Type | Description |
| ------ | ------------ |
| number | Minimum number of days in the first week of a year.|
- Example
**Example**
```
var calendar = i18n.getCalendar("zh-Hans");
calendar.getMinimalDaysInFirstWeek();
......@@ -492,12 +498,12 @@ Sets the minimum number of days in the first week of a year.
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| value | number | No| Minimum number of days in the first week of a year.|
**Parameters**
| Name | Type | Mandatory | Description |
| ----- | ------ | ---- | ------------ |
| value | number | No | Minimum number of days in the first week of a year.|
- Example
**Example**
```
var calendar = i18n.getCalendar("zh-Hans");
calendar.setMinimalDaysInFirstWeek(3);
......@@ -512,17 +518,17 @@ Obtains the value of the specified field in the **Calendar** object.
**System capability**: SystemCapability.Global.I18n
- Parameters
| 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**.|
**Parameters**
| 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**.|
- Return value
| Type| Description|
| -------- | -------- |
| number | Value of the specified field. For example, if the year in the internal date of this **Calendar** object is **1990**, the **get("year")** function will return **1990**.|
**Return Value**
| Type | Description |
| ------ | ---------------------------------------- |
| number | Value of the specified field. For example, if the year in the internal date of this **Calendar** object is **1990**, the **get("year")** function will return **1990**.|
- Example
**Example**
```
var calendar = i18n.getCalendar("zh-Hans");
calendar.setTime(2021, 10, 1, 8, 0, 0); // set time to 2021.10.1 08:00:00
......@@ -538,17 +544,17 @@ Obtains the name of the **Calendar** object displayed for the specified locale.
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| locale | string | Yes| Locale for which the name of the **Calendar** object is displayed. For example, if **locale** is **en-US**, the name of the Buddhist calendar will be **Buddhist Calendar**.|
**Parameters**
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | ---------------------------------------- |
| locale | string | Yes | Locale for which the name of the **Calendar** object is displayed. For example, if **locale** is **en-US**, the name of the Buddhist calendar will be **Buddhist Calendar**.|
- Return value
| Type| Description|
| -------- | -------- |
| string | Name of the **Calendar** object displayed for the specified locale.|
**Return Value**
| Type | Description |
| ------ | ------------------- |
| string | Name of the **Calendar** object displayed for the specified locale.|
- Example
**Example**
```
var calendar = i18n.getCalendar("en-US", "buddhist");
calendar.getDisplayName("zh"); // Obtain the name of the Buddhist calendar in zh.
......@@ -563,17 +569,17 @@ Checks whether the specified date in this **Calendar** object is a weekend.
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| date | Date | No| Specified date in this **Calendar** object. If this parameter is left unspecified, the system checks whether the current date in the **Calendar** object is a weekend.|
**Parameters**
| Name | Type | Mandatory | Description |
| ---- | ---- | ---- | ---------------------------------------- |
| date | Date | No | Specified date in this **Calendar** object. If this parameter is left unspecified, the system checks whether the current date in the **Calendar** object is a weekend.|
- Return value
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the date is a weekend; returns **false** if the date is a weekday.|
**Return Value**
| Type | Description |
| ------- | ----------------------------------- |
| boolean | Returns **true** if the date is a weekend; returns **false** if the date is a weekday.|
- Example
**Example**
```
var calendar = i18n.getCalendar("zh-Hans");
calendar.setTime(2021, 11, 11, 8, 0, 0); // set time to 2021.11.11 08:00:00
......@@ -595,12 +601,12 @@ Creates a **PhoneNumberFormat** object.
**System capability**: SystemCapability.Global.I18n
Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| country | string | Yes| Country or region to which the phone number to be formatted belongs.|
| options | [PhoneNumberFormatOptions](#phonenumberformatoptions8) | No| Options of the **PhoneNumberFormat** object.|
| Name | Type | Mandatory | Description |
| ------- | ---------------------------------------- | ---- | ---------------- |
| country | string | Yes | Country or region to which the phone number to be formatted belongs.|
| options | [PhoneNumberFormatOptions](#phonenumberformatoptions8) | No | Options of the **PhoneNumberFormat** object. |
- Example
**Example**
```
var phoneNumberFormat= new i18n.PhoneNumberFormat("CN", {"type": "E164"});
```
......@@ -614,17 +620,17 @@ Checks whether the format of the specified phone number is valid.
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| number | string | Yes| Phone number to be checked.|
**Parameters**
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | --------- |
| number | string | Yes | Phone number to be checked.|
- Return value
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the phone number format is valid; returns **false** otherwise.|
**Return Value**
| Type | Description |
| ------- | ------------------------------------- |
| boolean | Returns **true** if the phone number format is valid; returns **false** otherwise.|
- Example
**Example**
```
var phonenumberfmt = new i18n.PhoneNumberFormat("CN");
phonenumberfmt.isValidNumber("15812312312");
......@@ -639,17 +645,17 @@ Formats a phone number.
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| number | string | Yes| Phone number to be formatted.|
**Parameters**
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | ---------- |
| number | string | Yes | Phone number to be formatted.|
- Return value
| Type| Description|
| -------- | -------- |
| string | Formatted phone number.|
**Return Value**
| Type | Description |
| ------ | ---------- |
| string | Formatted phone number.|
- Example
**Example**
```
var phonenumberfmt = new i18n.PhoneNumberFormat("CN");
phonenumberfmt.format("15812312312");
......@@ -662,9 +668,9 @@ Defines the options for this PhoneNumberFormat object.
**System capability**: SystemCapability.Global.I18n
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| type | string | Yes| Yes| Format type of a phone number. The value can be **E164**, **INTERNATIONAL**, **NATIONAL**, or **RFC3966**.|
| Name | Type | Readable | Writable | Description |
| ---- | ------ | ---- | ---- | ---------------------------------------- |
| type | string | Yes | Yes | Format type of a phone number. The value can be **E164**, **INTERNATIONAL**, **NATIONAL**, or **RFC3966**.|
## UnitInfo<sup>8+</sup>
......@@ -673,10 +679,10 @@ Defines the measurement unit information.
**System capability**: SystemCapability.Global.I18n
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| 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**.|
| Name | Type | Readable | Writable | Description |
| ------------- | ------ | ---- | ---- | ---------------------------------------- |
| 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**.|
## Util<sup>8+</sup>
......@@ -690,21 +696,21 @@ Converts one measurement unit into another and formats the unit based on the spe
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| fromUnit | [UnitInfo](#unitinfo8) | Yes| Measurement unit to be converted.|
| toUnit | [UnitInfo](#unitinfo8) | Yes| Measurement unit to be converted to.|
| value | number | Yes| Value of the measurement unit to be converted.|
| locale | string | Yes| Locale used for formatting, for example, **zh-Hans-CN**.|
| style | string | No| Style used for formatting. The value can be **long**, **short**, or **medium**.|
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ---------------------- | ---- | ---------------------------------------- |
| fromUnit | [UnitInfo](#unitinfo8) | Yes | Measurement unit to be converted. |
| toUnit | [UnitInfo](#unitinfo8) | Yes | Measurement unit to be converted to. |
| value | number | Yes | Value of the measurement unit to be converted. |
| locale | string | Yes | Locale used for formatting, for example, **zh-Hans-CN**. |
| style | string | No | Style used for formatting. The value can be **long**, **short**, or **medium**.|
- Return value
| Type| Description|
| -------- | -------- |
| string | Character string obtained after formatting based on the measurement unit specified by **toUnit**.|
**Return Value**
| Type | Description |
| ------ | ----------------------- |
| string | Character string obtained after formatting based on the measurement unit specified by **toUnit**.|
- Example
**Example**
```
I18n.Util.unitConvert({unit: "cup", measureSystem: "US"}, {unit: "liter", measureSystem: "SI"}, 1000, "en-US", "long");
```
......@@ -718,17 +724,17 @@ Creates an **IndexUtil** object.
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| locale | string | No| A string containing locale information, including the language, optional script, and region.|
**Parameters**
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | ---------------------------- |
| locale | string | No | A string containing locale information, including the language, optional script, and region.|
- Return value
| Type| Description|
| -------- | -------- |
| [IndexUtil](#indexutil8) | **IndexUtil** object mapping to the specified locale.|
**Return Value**
| Type | Description |
| ------------------------ | --------------------- |
| [IndexUtil](#indexutil8) | **IndexUtil** object mapping to the specified locale.|
- Example
**Example**
```
var indexUtil= i18n.IndexUtil.getInstance("zh-CN");
```
......@@ -745,12 +751,12 @@ Obtains the index list for this **locale** object.
**System capability**: SystemCapability.Global.I18n
- Return value
| Type| Description|
| -------- | -------- |
| Array&lt;string&gt; | Index list for this **locale** object.|
**Return Value**
| Type | Description |
| ------------------- | ------------------ |
| Array&lt;string&gt; | Index list for this **locale** object.|
- Example
**Example**
```
var indexUtil = i18n.getInstance("zh-CN");
var indexList = indexUtil.getIndexList();
......@@ -765,12 +771,12 @@ Adds the index of the new **locale** object to the index list.
**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.|
**Parameters**
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | ---------------------------- |
| locale | string | Yes | A string containing locale information, including the language, optional script, and region.|
- Example
**Example**
```
var indexUtil = i18n.getInstance("zh-CN");
indexUtil.addLocale("en-US");
......@@ -785,17 +791,17 @@ Obtains the index of a text object.
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| text | string | Yes| **text** object whose index is to be obtained.|
**Parameters**
| Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ------------ |
| text | string | Yes | **text** object whose index is to be obtained.|
- Return value
| Type| Description|
| -------- | -------- |
| string | Index of the **text** object.|
**Return Value**
| Type | Description |
| ------ | ----------- |
| string | Index of the **text** object.|
- Example
**Example**
```
var indexUtil= i18n.getInstance("zh-CN");
indexUtil.getIndex("hi"); // Return h.
......@@ -813,17 +819,17 @@ Checks whether the input character string is composed of digits.
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| char | string | Yes| Input character.|
**Parameters**
| Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ----- |
| char | string | Yes | Input character.|
- Return value
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input character is a digit; returns **false** otherwise.|
**Return Value**
| Type | Description |
| ------- | ------------------------------------ |
| boolean | Returns **true** if the input character is a digit; returns **false** otherwise.|
- Example
**Example**
```
var isdigit = Character.isDigit("1"); // Return true.
```
......@@ -837,17 +843,17 @@ Checks whether the input character is a space.
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| char | string | Yes| Input character.|
**Parameters**
| Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ----- |
| char | string | Yes | Input character.|
- Return value
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input character is a space; returns **false** otherwise.|
**Return Value**
| Type | Description |
| ------- | -------------------------------------- |
| boolean | Returns **true** if the input character is a space; returns **false** otherwise.|
- Example
**Example**
```
var isspacechar = Character.isSpaceChar("a"); // Return false.
```
......@@ -861,17 +867,17 @@ Checks whether the input character is a white space.
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| char | string | Yes| Input character.|
**Parameters**
| Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ----- |
| char | string | Yes | Input character.|
- Return value
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input character is a white space; returns **false** otherwise.|
**Return Value**
| Type | Description |
| ------- | -------------------------------------- |
| boolean | Returns **true** if the input character is a white space; returns **false** otherwise.|
- Example
**Example**
```
var iswhitespace = Character.isWhitespace("a"); // Return false.
```
......@@ -885,17 +891,17 @@ Checks whether the input character is of the right to left (RTL) language.
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| char | string | Yes| Input character.|
**Parameters**
| Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ----- |
| char | string | Yes | Input character.|
- Return value
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input character is of the RTL language; returns **false** otherwise.|
**Return Value**
| Type | Description |
| ------- | ---------------------------------------- |
| boolean | Returns **true** if the input character is of the RTL language; returns **false** otherwise.|
- Example
**Example**
```
var isrtl = Character.isRTL("a"); // Return false.
```
......@@ -909,17 +915,17 @@ Checks whether the input character is an ideographic character.
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| char | string | Yes| Input character.|
**Parameters**
| Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ----- |
| char | string | Yes | Input character.|
- Return value
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input character is an ideographic character; returns **false** otherwise.|
**Return Value**
| Type | Description |
| ------- | ---------------------------------------- |
| boolean | Returns **true** if the input character is an ideographic character; returns **false** otherwise.|
- Example
**Example**
```
var isideograph = Character.isIdeograph("a"); // Return false.
```
......@@ -933,17 +939,17 @@ Checks whether the input character is a letter.
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| char | string | Yes| Input character.|
**Parameters**
| Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ----- |
| char | string | Yes | Input character.|
- Return value
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input character is a letter; returns **false** otherwise.|
**Return Value**
| Type | Description |
| ------- | ------------------------------------ |
| boolean | Returns **true** if the input character is a letter; returns **false** otherwise.|
- Example
**Example**
```
var isletter = Character.isLetter("a"); // Return true.
```
......@@ -957,17 +963,17 @@ Checks whether the input character is a lowercase letter.
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| char | string | Yes| Input character.|
**Parameters**
| Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ----- |
| char | string | Yes | Input character.|
- Return value
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input character is a lowercase letter; returns **false** otherwise.|
**Return Value**
| Type | Description |
| ------- | ---------------------------------------- |
| boolean | Returns **true** if the input character is a lowercase letter; returns **false** otherwise.|
- Example
**Example**
```
var islowercase = Character.isLowerCase("a"); // Return true.
```
......@@ -981,17 +987,17 @@ Checks whether the input character is an uppercase letter.
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| char | string | Yes| Input character.|
**Parameters**
| Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ----- |
| char | string | Yes | Input character.|
- Return value
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the input character is an uppercase letter; returns **false** otherwise.|
**Return Value**
| Type | Description |
| ------- | ---------------------------------------- |
| boolean | Returns **true** if the input character is an uppercase letter; returns **false** otherwise.|
- Example
**Example**
```
var isuppercase = Character.isUpperCase("a"); // Return false.
```
......@@ -1005,17 +1011,17 @@ Obtains the type of the input character string.
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| char | string | Yes| Input character.|
**Parameters**
| Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ----- |
| char | string | Yes | Input character.|
- Return value
| Type| Description|
| -------- | -------- |
| string | Type of the input character.|
**Return Value**
| Type | Description |
| ------ | ----------- |
| string | Type of the input character.|
- Example
**Example**
```
var type = Character.getType("a");
```
......@@ -1029,17 +1035,17 @@ Obtains a [BreakIterator](#breakiterator8) object for text segmentation.
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| locale | string | Yes| Valid locale value, for example, **zh-Hans-CN**. The [BreakIterator](#breakiterator8) object segments text according to the rules of the specified locale.|
**Parameters**
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | ---------------------------------------- |
| locale | string | Yes | Valid locale value, for example, **zh-Hans-CN**. The [BreakIterator](#breakiterator8) object segments text according to the rules of the specified locale.|
- Return value
| Type| Description|
| -------- | -------- |
| [BreakIterator](#breakiterator8) | [BreakIterator](#breakiterator8) object used for text segmentation.|
**Return Value**
| Type | Description |
| -------------------------------- | ----------- |
| [BreakIterator](#breakiterator8) | [BreakIterator](#breakiterator8) object used for text segmentation.|
- Example
**Example**
```
i18n.getLineInstance("en");
```
......@@ -1056,12 +1062,12 @@ Sets the text to be processed by the [BreakIterator](#breakiterator8) object.
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| text | string | Yes| Text to be processed by the **BreakIterator** object.|
**Parameters**
| Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ----------------------- |
| text | string | Yes | Text to be processed by the **BreakIterator** object.|
- Example
**Example**
```
iterator = I18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit.");
......@@ -1076,12 +1082,12 @@ Obtains the text being processed by the [BreakIterator](#breakiterator8) object.
**System capability**: SystemCapability.Global.I18n
- Return value
| Type| Description|
| -------- | -------- |
| string | Text being processed by the **BreakIterator** object.|
**Return Value**
| Type | Description |
| ------ | ---------------------- |
| string | Text being processed by the **BreakIterator** object.|
- Example
**Example**
```
iterator = I18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit.");
......@@ -1097,12 +1103,12 @@ Obtains the position of the [BreakIterator](#breakiterator8) object in the text
**System capability**: SystemCapability.Global.I18n
- Return value
| Type| Description|
| -------- | -------- |
| number | Position of the **BreakIterator** object in the text being processed.|
**Return Value**
| Type | Description |
| ------ | --------------------------- |
| number | Position of the **BreakIterator** object in the text being processed.|
- Example
**Example**
```
iterator = I18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit.");
......@@ -1118,12 +1124,12 @@ Puts the [BreakIterator](#breakiterator8) object to the first text boundary, whi
**System capability**: SystemCapability.Global.I18n
- Return value
| Type| Description|
| -------- | -------- |
| number | Offset to the first text boundary of the processed text.|
**Return Value**
| Type | Description |
| ------ | ----------------- |
| number | Offset to the first text boundary of the processed text.|
- Example
**Example**
```
iterator = I18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit.");
......@@ -1139,12 +1145,12 @@ Puts the [BreakIterator](#breakiterator8) object to the last text boundary, whic
**System capability**: SystemCapability.Global.I18n
- Return value
| Type| Description|
| -------- | -------- |
| number | Offset of the last text boundary of the processed text.|
**Return Value**
| Type | Description |
| ------ | ------------------ |
| number | Offset of the last text boundary of the processed text.|
- Example
**Example**
```
iterator = I18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit.");
......@@ -1160,17 +1166,17 @@ Moves the [BreakIterator](#breakiterator8) object backward by the specified numb
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| index | number | No| Number of text boundaries by which the [BreakIterator](#breakiterator8) object is moved. A positive value indicates that the text boundary is moved backward, and a negative value indicates the opposite. If no index is specified, the index will be treated as **1**.|
**Parameters**
| Name | Type | Mandatory | Description |
| ----- | ------ | ---- | ---------------------------------------- |
| index | number | No | Number of text boundaries by which the [BreakIterator](#breakiterator8) object is moved. A positive value indicates that the text boundary is moved backward, and a negative value indicates the opposite. If no index is specified, the index will be treated as **1**.|
- Return value
| Type| Description|
| -------- | -------- |
| number | Position of the [BreakIterator](#breakiterator8) object in the text after it is moved by the specified number of text boundaries. The value **-1** is returned if the position of the [BreakIterator](#breakiterator8) object is outside of the processed text after it is moved by the specified number of text boundaries.|
**Return Value**
| Type | Description |
| ------ | ---------------------------------------- |
| number | Position of the [BreakIterator](#breakiterator8) object in the text after it is moved by the specified number of text boundaries. The value **-1** is returned if the position of the [BreakIterator](#breakiterator8) object is outside of the processed text after it is moved by the specified number of text boundaries.|
- Example
**Example**
```
iterator = I18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit.");
......@@ -1188,12 +1194,12 @@ Moves the [BreakIterator](#breakiterator8) object to the previous text boundary.
**System capability**: SystemCapability.Global.I18n
- Return value
| Type| Description|
| -------- | -------- |
| number | Position of the [BreakIterator](#breakiterator8) object in the text after it is moved to the previous text boundary. The value **-1** is returned if the position of the [BreakIterator](#breakiterator8) object is outside of the processed text after it is moved by the specified number of text boundaries.|
**Return Value**
| Type | Description |
| ------ | ---------------------------------------- |
| number | Position of the [BreakIterator](#breakiterator8) object in the text after it is moved to the previous text boundary. The value **-1** is returned if the position of the [BreakIterator](#breakiterator8) object is outside of the processed text after it is moved by the specified number of text boundaries.|
- Example
**Example**
```
iterator = I18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit.");
......@@ -1211,17 +1217,17 @@ Moves the [BreakIterator](#breakiterator8) object to the text boundary after the
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| offset | number | Yes| Offset to the position before the text boundary to which the [BreakIterator](#breakiterator8) object is moved.|
**Parameters**
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | ---------------------------------------- |
| offset | number | Yes | Offset to the position before the text boundary to which the [BreakIterator](#breakiterator8) object is moved.|
- Return value
| Type| Description|
| -------- | -------- |
| number | The value **-1** is returned if the text boundary to which the [BreakIterator](#breakiterator8) object is moved is outside of the processed text.|
**Return Value**
| Type | Description |
| ------ | ---------------------------------------- |
| number | The value **-1** is returned if the text boundary to which the [BreakIterator](#breakiterator8) object is moved is outside of the processed text.|
- Example
**Example**
```
iterator = I18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit.");
......@@ -1239,17 +1245,17 @@ Checks whether the position specified by the offset is a text boundary. If **tru
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| offset | number | Yes| Position to check.|
**Parameters**
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | ----------- |
| offset | number | Yes | Position to check.|
- Return value
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the position specified by the offset is a text boundary; returns **false** otherwise.|
**Return Value**
| Type | Description |
| ------- | ------------------------------- |
| boolean | Returns **true** if the position specified by the offset is a text boundary; returns **false** otherwise.|
- Example
**Example**
```
iterator = I18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit.");
......@@ -1266,12 +1272,12 @@ Checks whether the 24-hour clock is used.
**System capability**: SystemCapability.Global.I18n
- Return value
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the 24-hour clock is used; returns **false** otherwise.|
**Return Value**
| Type | Description |
| ------- | ---------------------------------------- |
| boolean | Returns **true** if the 24-hour clock is used; returns **false** otherwise.|
- Example
**Example**
```
var is24HourClock = i18n.is24HourClock();
```
......@@ -1283,19 +1289,21 @@ set24HourClock(option: boolean): boolean
Sets the 24-hour clock.
**Required permission**: ohos.permission.UPDATE_CONFIGURATION
**System capability**: SystemCapability.Global.I18n
- Parameters
| 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 the value **false** means the opposite.|
**Parameters**
| 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 the value **false** means the opposite.|
- Return value
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the 24-hour clock is enabled; returns **false** otherwise.|
**Return Value**
| Type | Description |
| ------- | ----------------------------- |
| boolean | Returns **true** if the 24-hour clock is enabled; returns **false** otherwise.|
- Example
**Example**
```
// Set the system time to the 24-hour clock.
var success = I18n.set24HourClock(true);
......@@ -1308,20 +1316,22 @@ addPreferredLanguage(language: string, index?: number): boolean
Adds a preferred language to the specified position on the preferred language list.
**Required permission**: ohos.permission.UPDATE_CONFIGURATION
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| language | string | Yes| Preferred language to add.|
| index | number | No| Position to which the preferred language is added.|
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ------ | ---- | ---------- |
| language | string | Yes | Preferred language to add. |
| index | number | No | Position to which the preferred language is added.|
- Return value
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the preferred language is successfully added; returns **false** otherwise.|
**Return Value**
| Type | Description |
| ------- | ----------------------------- |
| boolean | Returns **true** if the preferred language is successfully added; returns **false** otherwise.|
- Example
**Example**
```
// Add zh-CN to the preferred language list.
var language = 'zh-CN';
......@@ -1336,19 +1346,21 @@ removePreferredLanguage(index: number): boolean
Deletes a preferred language from the specified position on the preferred language list.
**Required permission**: ohos.permission.UPDATE_CONFIGURATION
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| index | number | Yes| Position of the preferred language to delete.|
**Parameters**
| Name | Type | Mandatory | Description |
| ----- | ------ | ---- | --------------------- |
| index | number | Yes | Position of the preferred language to delete.|
- Return value
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the preferred language is deleted; returns **false** otherwise.|
**Return Value**
| Type | Description |
| ------- | ----------------------------- |
| boolean | Returns **true** if the preferred language is deleted; returns **false** otherwise.|
- Example
**Example**
```
// Delete the first preferred language from the preferred language list.
var index = 0;
......@@ -1358,18 +1370,18 @@ Deletes a preferred language from the specified position on the preferred langua
## i18n.getPreferredLanguageList<sup>8+</sup>
getPreferredLanguageList(): Array<string>
getPreferredLanguageList(): Array&lt;string&gt;
Obtains the list of preferred languages.
**System capability**: SystemCapability.Global.I18n
- Return value
| Type| Description|
| -------- | -------- |
| Array<string> | List of preferred languages.|
**Return Value**
| Type | Description |
| ------------------- | --------- |
| Array&lt;string&gt; | List of preferred languages.|
- Example
**Example**
```
var preferredLanguageList = i18n.getPreferredLanguageList();
```
......@@ -1383,12 +1395,12 @@ Obtains the first language in the preferred language list.
**System capability**: SystemCapability.Global.I18n
- Return value
| Type| Description|
| -------- | -------- |
| string | First language in the preferred language list.|
**Return Value**
| Type | Description |
| ------ | -------------- |
| string | First language in the preferred language list.|
- Example
**Example**
```
var firstPreferredLanguage = i18n.getFirstPreferredLanguage();
```
......@@ -1402,17 +1414,17 @@ 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.|
**Parameters**
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | ----- |
| zondID | string | No | Time zone ID.|
- Return value
| Type| Description|
| -------- | -------- |
| TimeZone | **TimeZone** object corresponding to the time zone ID.|
**Return Value**
| Type | Description |
| -------- | ------------ |
| TimeZone | **TimeZone** object corresponding to the time zone ID.|
- Example
**Example**
```
var timezone = i18n.getTimeZone();
```
......@@ -1429,12 +1441,12 @@ 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.|
**Return Value**
| Type | Description |
| ------ | ------------ |
| string | Time zone ID corresponding to the **TimeZone** object.|
- Example
**Example**
```
var timezone = i18n.getTimeZone();
timezone.getID();
......@@ -1449,18 +1461,18 @@ 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.|
**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.|
**Return Value**
| Type | Description |
| ------ | ------------- |
| string | Representation of the **TimeZone** object in the specified locale.|
- Example
**Example**
```
var timezone = i18n.getTimeZone();
timezone.getDisplayName("zh-CN", false);
......@@ -1475,12 +1487,12 @@ Obtains the offset between the time zone represented by a **TimeZone** object an
**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.|
**Return Value**
| Type | Description |
| ------ | ------------------- |
| number | Offset between the time zone represented by the **TimeZone** object and the UTC time zone.|
- Example
**Example**
```
var timezone = i18n.getTimeZone();
timezone.getRawOffset();
......@@ -1495,12 +1507,12 @@ Obtains the offset between the time zone represented by a **TimeZone** object an
**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.|
**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
**Example**
```
var timezone = i18n.getTimeZone();
timezone.getOffset(1234567890);
......
......@@ -2,7 +2,7 @@
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> - The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
>
> - This module contains standard i18n APIs, which are defined in ECMA 402.
......@@ -20,18 +20,18 @@ import Intl from '@ohos.intl';
**System capability**: SystemCapability.Global.I18n
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| language | string | Yes| No| Language associated with the locale, for example, **zh**.|
| script | string | Yes| No| Script type of the language, for example, **Hans**.|
| 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**.|
| 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**.|
| 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**, **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**.|
| numeric | boolean | Yes| No| Whether to apply special collation rules for numeric characters.|
| Name | Type | Readable | Writable | Description |
| --------------- | ------- | ---- | ---- | ---------------------------------------- |
| language | string | Yes | No | Language associated with the locale, for example, **zh**. |
| script | string | Yes | No | Script type of the language, for example, **Hans**. |
| 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**. |
| 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**.|
| 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**, **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**.|
| numeric | boolean | Yes | No | Whether to apply special collation rules for numeric characters. |
### constructor<sup>8+</sup>
......@@ -42,7 +42,7 @@ Creates a Locale object.
**System capability**: SystemCapability.Global.I18n
- Example
**Example**
```
var locale = new Intl.Locale();
```
......@@ -56,13 +56,13 @@ Creates a Locale object.
**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 | LocaleOptions | No| Options for creating the **Locale** object.|
**Parameters**
| Name | Type | Mandatory | Description |
| ------- | ------------- | ---- | ---------------------------- |
| locale | string | Yes | A string containing locale information, including the language, optional script, and region.|
| options | LocaleOptions | No | Options for creating the **Locale** object. |
- Example
**Example**
```
var locale = new Intl.Locale("zh-CN");
```
......@@ -76,12 +76,12 @@ Converts locale information to a string.
**System capability**: SystemCapability.Global.I18n
- Return value
| Type| Description|
| -------- | -------- |
| string | String containing locale information.|
**Return Value**
| Type | Description |
| ------ | ----------- |
| string | String containing locale information.|
- Example
**Example**
```
var locale = new Intl.Locale("zh-CN");
locale.toString();
......@@ -96,12 +96,12 @@ Maximizes information of the **Locale** object. If the script and locale informa
**System capability**: SystemCapability.Global.I18n
- Return value
| Type| Description|
| -------- | -------- |
| [Locale](#locale) | **Locale** object with the maximized information.|
**Return Value**
| Type | Description |
| ----------------- | ---------- |
| [Locale](#locale) | **Locale** object with the maximized information.|
- Example
**Example**
```
var locale = new Intl.Locale("zh-CN");
locale.maximize();
......@@ -116,12 +116,12 @@ Minimizes information of the **Locale** object. If the script and locale informa
**System capability**: SystemCapability.Global.I18n
- Return value
| Type| Description|
| -------- | -------- |
| [Locale](#locale) | **Locale** object with the minimized information.|
**Return Value**
| Type | Description |
| ----------------- | ---------- |
| [Locale](#locale) | **Locale** object with the minimized information.|
- Example
**Example**
```
var locale = new Intl.Locale("zh-CN");
locale.minimize();
......@@ -134,14 +134,14 @@ 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**.|
| 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
......@@ -155,7 +155,7 @@ Creates a **DateTimeOptions** object for the specified locale.
**System capability**: SystemCapability.Global.I18n
- Example
**Example**
```
var datefmt= new Intl.DateTimeFormat();
```
......@@ -163,25 +163,25 @@ Creates a **DateTimeOptions** object for the specified locale.
### constructor
constructor(locale: string | Array<string>, options?: DateTimeOptions)
constructor(locale: string | Array&lt;string&gt;, options?: DateTimeOptions)
Creates a **DateTimeOptions** object for the specified locale.
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| 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.|
**Parameters**
| Name | Type | Mandatory | Description |
| ------- | ----------------------------------- | ---- | ---------------------------- |
| locale | string \| Array&lt;string&gt; | 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' });
```
- Example
**Example**
```
var datefmt= new Intl.DateTimeFormat(["ban", "zh"], { dateStyle: 'full', timeStyle: 'medium' });
```
......@@ -195,17 +195,17 @@ Formats the specified date and time.
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| date | Date | Yes| Date and time to be formatted.|
**Parameters**
| Name | Type | Mandatory | Description |
| ---- | ---- | ---- | ------- |
| date | Date | Yes | Date and time to be formatted.|
- Return value
| Type| Description|
| -------- | -------- |
| string | A string containing the formatted date and time.|
**Return Value**
| Type | Description |
| ------ | ------------ |
| string | A string containing the formatted date and time.|
- Example
**Example**
```
var date = new Date(2021, 11, 17, 3, 24, 0);
var datefmt = new Intl.DateTimeFormat("en-GB");
......@@ -221,18 +221,18 @@ Formats the specified date range.
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| startDate | Date | Yes| Start date and time to be formatted.|
| endDate | Date | Yes| End date and time to be formatted.|
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ---- | ---- | -------- |
| startDate | Date | Yes | Start date and time to be formatted.|
| endDate | Date | Yes | End date and time to be formatted.|
- Return value
| Type| Description|
| -------- | -------- |
| string | A string containing the formatted date and time range.|
**Return Value**
| Type | Description |
| ------ | -------------- |
| string | A string containing the formatted date and time range.|
- Example
**Example**
```
var startDate = new Date(2021, 11, 17, 3, 24, 0);
var endDate = new Date(2021, 11, 18, 3, 24, 0);
......@@ -249,12 +249,12 @@ Obtains the formatting options for **DateTimeFormat** object.
**System capability**: SystemCapability.Global.I18n
- Return value
| Type| Description|
| -------- | -------- |
| [DateTimeOptions](#datetimeoptions) | Formatting options for **DateTimeFormat** objects.|
**Return Value**
| Type | Description |
| ----------------------------------- | ----------------------------- |
| [DateTimeOptions](#datetimeoptions) | Formatting options for **DateTimeFormat** objects.|
- Example
**Example**
```
var datefmt = new Intl.DateTimeFormat("en-GB");
datefmt.resolvedOptions();
......@@ -267,27 +267,27 @@ Provides the options for the **DateTimeFormat** object.
**System capability**: SystemCapability.Global.I18n
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| 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**.|
| 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**.|
| 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**.|
| 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**.|
| 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**. |
| 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**.|
| 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**.|
| 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.|
| 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**.|
| formatMatcher | string | Yes| Yes| Format matching algorithm. The value can be **basic** or **best fit**.|
| Name | Type | Readable | Writable | Description |
| --------------- | ------- | ---- | ---- | ---------------------------------------- |
| 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**.|
| 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**.|
| 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**.|
| 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**.|
| 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**. |
| 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**. |
| 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**. |
| 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. |
| 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**.|
| formatMatcher | string | Yes | Yes | Format matching algorithm. The value can be **basic** or **best fit**.|
## NumberFormat
......@@ -301,7 +301,7 @@ Creates a **NumberFormat** object for the specified locale.
**System capability**: SystemCapability.Global.I18n
- Example
**Example**
```
var numfmt = new Intl.NumberFormat();
```
......@@ -309,19 +309,19 @@ Creates a **NumberFormat** object for the specified locale.
### constructor
constructor(locale: string | Array<string>, options?: NumberOptions)
constructor(locale: string | Array&lt;string&gt;, options?: NumberOptions)
Creates a **NumberFormat** object for the specified locale.
**System capability**: SystemCapability.Global.I18n
Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| 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.|
| Name | Type | Mandatory | Description |
| ------- | ------------------------------- | ---- | ---------------------------- |
| locale | string \| Array&lt;string&gt; | 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"});
```
......@@ -335,18 +335,18 @@ Formats a number.
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| number | number | Yes| Number to be formatted.|
**Parameters**
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | ---- |
| number | number | Yes | Number to be formatted.|
- Return value
| Type| Description|
| -------- | -------- |
| string | Formatted number.|
**Return Value**
| Type | Description |
| ------ | ---------- |
| string | Formatted number.|
- Example
**Example**
```
var numfmt = new Intl.NumberFormat(["en-GB", "zh"], {style:'decimal', notation:"scientific"});
numfmt.format(1223);
......@@ -361,13 +361,13 @@ Obtains the options of the **NumberFormat** object.
**System capability**: SystemCapability.Global.I18n
- Return value
| Type| Description|
| -------- | -------- |
| [NumberOptions](#numberoptions) | Formatting options for **NumberFormat** objects.|
**Return Value**
| Type | Description |
| ------------------------------- | --------------------------- |
| [NumberOptions](#numberoptions) | Formatting options for **NumberFormat** objects.|
- Example
**Example**
```
var numfmt = new Intl.NumberFormat(["en-GB", "zh"], {style:'decimal', notation:"scientific"});
numfmt.resolvedOptions();
......@@ -380,27 +380,27 @@ Provides the device capability.
**System capability**: SystemCapability.Global.I18n
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| locale | string | Yes| No| Locale, for example, **zh-Hans-CN**.|
| 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**.|
| 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**.|
| 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**.|
| 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**.|
| 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**.|
| 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**.|
| useGrouping | boolean | Yes| Yes| Whether to use grouping for display.|
| 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**.|
| 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**.|
| maximumSignificantDigits | number | Yes| Yes| Maximum number of the least significant digits. The value ranges from **1** to **21**.|
| Name | Type | Readable | Writable | Description |
| ------------------------ | ------- | ---- | ---- | ---------------------------------------- |
| locale | string | Yes | No | Locale, for example, **zh-Hans-CN**. |
| 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**.|
| 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**. |
| 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**.|
| 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**. |
| 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**.|
| 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**.|
| useGrouping | boolean | Yes | Yes | Whether to use grouping for display. |
| 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**. |
| 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**. |
| maximumSignificantDigits | number | Yes | Yes | Maximum number of the least significant digits. The value ranges from **1** to **21**. |
## Collator<sup>8+</sup>
......@@ -414,7 +414,7 @@ Creates a Collator object.
**System capability**: SystemCapability.Global.I18n
- Example
**Example**
```
var collator = new Intl.Collator();
```
......@@ -422,20 +422,20 @@ Creates a Collator object.
### constructor<sup>8+</sup>
constructor(locale: string | Array<string>, options?: CollatorOptions)
constructor(locale: string | Array&lt;string&gt;, options?: CollatorOptions)
Creates a Collator object.
**System capability**: SystemCapability.Global.I18n
- Parameters
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| 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.|
| Name | Type | Mandatory | Description |
| ------- | ----------------------------------- | ---- | ---------------------------- |
| locale | string \| Array&lt;string&gt; | Yes | A string containing locale information, including the language, optional script, and region.|
| options | [CollatorOptions](#collatoroptions) | No | Options for creating a **Collator** object. |
- Example
**Example**
```
var collator = new Intl.Collator("zh-CN", {localeMatcher: "lookup", usage: "sort"});
```
......@@ -449,18 +449,18 @@ Compares two strings based on the sorting policy of the **Collator** object.
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| first | string | Yes| First string to compare.|
| second | string | Yes| Second string to compare.|
**Parameters**
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | ------------ |
| first | string | Yes | First string to compare. |
| second | string | Yes | Second string to compare.|
- Return value
| Type| Description|
| -------- | -------- |
| number | Comparison result. If the value is a negative number, the first string is before the second string. If the value of number is **0**, the first string is equal to the second string. If the value of number is a positive number, the first string is after the second string.|
**Return Value**
| Type | Description |
| ------ | ---------------------------------------- |
| number | Comparison result. If the value is a negative number, the first string is before the second string. If the value of number is **0**, the first string is equal to the second string. If the value of number is a positive number, the first string is after the second string.|
- Example
**Example**
```
var collator = new Intl.Collator("zh-Hans");
collator.compare("first", "second");
......@@ -475,12 +475,12 @@ Returns properties reflecting the locale and collation options of a **Collator**
**System capability**: SystemCapability.Global.I18n
- Return value
| Type| Description|
| -------- | -------- |
| [CollatorOptions](#collatoroptions) | Properties of the **Collator** object.|
**Return Value**
| Type | Description |
| ----------------------------------- | ----------------- |
| [CollatorOptions](#collatoroptions) | Properties of the **Collator** object.|
- Example
**Example**
```
var collator = new Intl.Collator("zh-Hans");
var options = collator.resolvedOptions();
......@@ -493,15 +493,15 @@ Represents the properties of a **Collator** object.
**System capability**: SystemCapability.Global.I18n
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| 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**.|
| 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**.|
| 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**.|
| caseFirst | string | Yes| Yes| Whether upper case or lower case is sorted first. The value can be **upper**, **lower**, or **false**.|
| Name | Type | Readable | Writable | Description |
| ----------------- | ------- | ---- | ---- | ---------------------------------------- |
| 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**. |
| 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**. |
| 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**. |
| 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>
......@@ -515,7 +515,7 @@ Create a **PluralRules** object.
**System capability**: SystemCapability.Global.I18n
- Example
**Example**
```
var pluralRules = new Intl.PluralRules();
```
......@@ -523,19 +523,19 @@ Create a **PluralRules** object.
### constructor<sup>8+</sup>
constructor(locale: string | Array<string>, options?: PluralRulesOptions)
constructor(locale: string | Array&lt;string&gt;, options?: PluralRulesOptions)
Create a **PluralRules** object.
**System capability**: SystemCapability.Global.I18n
Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| 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.|
| Name | Type | Mandatory | Description |
| ------- | ---------------------------------------- | ---- | ---------------------------- |
| locale | string \| Array&lt;string&gt; | Yes | A string containing locale information, including the language, optional script, and region.|
| options | [PluralRulesOptions](#pluralrulesoptions) | No | Options for creating a **PluralRules** object. |
- Example
**Example**
```
var pluralRules= new Intl.PluraRules("zh-CN", {"localeMatcher": "lookup", "type": "cardinal"});
```
......@@ -549,17 +549,17 @@ Obtains a string that represents the singular-plural type of the specified numbe
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| n | number | Yes| Number for which the singular-plural type is to be obtained.|
**Parameters**
| Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ------------ |
| n | number | Yes | Number for which the singular-plural type is to be obtained.|
- Return value
| Type| Description|
| -------- | -------- |
| string | Singular-plural type. The value can be any of the following: **one**, **two**, **few**, **many**, **others**.|
**Return Value**
| Type | Description |
| ------ | ---------------------------------------- |
| string | Singular-plural type. The value can be any of the following: **one**, **two**, **few**, **many**, **others**.|
- Example
**Example**
```
var pluralRules = new Intl.PluralRules("zh-Hans");
pluralRules.select(1);
......@@ -572,15 +572,15 @@ Represents the properties of a **PluralRules** object.
**System capability**: SystemCapability.Global.I18n
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| 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**.|
| 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**.|
| 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**.|
| maximumSignificantDigits | number | Yes| Yes| Maximum number of the least significant digits. The value ranges from **1** to **21**.|
| Name | Type | Readable | Writable | Description |
| ------------------------ | ------ | ---- | ---- | ---------------------------------------- |
| 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**. |
| 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**. |
| 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**. |
| maximumSignificantDigits | number | Yes | Yes | Maximum number of the least significant digits. The value ranges from **1** to **21**. |
## RelativeTimeFormat<sup>8+</sup>
......@@ -594,7 +594,7 @@ Creates a **RelativeTimeFormat** object.
**System capability**: SystemCapability.Global.I18n
- Example
**Example**
```
var relativetimefmt = new Intl.RelativeTimeFormat();
```
......@@ -602,19 +602,19 @@ Creates a **RelativeTimeFormat** object.
### constructor<sup>8+</sup>
constructor(locale: string | Array<string>, options?: RelativeTimeFormatInputOptions)
constructor(locale: string | Array&lt;string&gt;, options?: RelativeTimeFormatInputOptions)
Creates a **RelativeTimeFormat** object.
**System capability**: SystemCapability.Global.I18n
Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| 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.|
| Name | Type | Mandatory | Description |
| ------- | ---------------------------------------- | ---- | ---------------------------- |
| locale | string \| Array&lt;string&gt; | Yes | A string containing locale information, including the language, optional script, and region.|
| options | [RelativeTimeFormatInputOptions](#relativetimeformatinputoptions) | No | Options for creating a **RelativeTimeFormat** object. |
- Example
**Example**
```
var relativeTimeFormat = new Intl.RelativeTimeFormat("zh-CN", {"localeMatcher": "lookup", "numeric": "always", "style": "long"});
```
......@@ -628,18 +628,18 @@ Formats the value and unit based on the specified locale and formatting options.
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| 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**.|
**Parameters**
| Name | Type | Mandatory | Description |
| ----- | ------ | ---- | ---------------------------------------- |
| 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**.|
- Return value
| Type| Description|
| -------- | -------- |
| string | Relative time after formatting.|
**Return Value**
| Type | Description |
| ------ | ---------- |
| string | Relative time after formatting.|
- Example
**Example**
```
var relativetimefmt = new Intl.RelativeTimeFormat("zh-CN");
relativetimefmt.format(3, "quarter")
......@@ -648,24 +648,24 @@ Formats the value and unit based on the specified locale and formatting options.
### formatToParts<sup>8+</sup>
formatToParts(value: number, unit: string): Array<object>
formatToParts(value: number, unit: string): Array&lt;object&gt;
Returns an array of RelativeTimeFormat objects in parts for locale-aware formatting.
**System capability**: SystemCapability.Global.I18n
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| 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**.|
**Parameters**
| Name | Type | Mandatory | Description |
| ----- | ------ | ---- | ---------------------------------------- |
| 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**.|
- Return value
| Type| Description|
| -------- | -------- |
| Array<object> | An array of **RelativeTimeFormat** objects in parts.|
**Return Value**
| Type | Description |
| ------------------- | --------------------------- |
| Array&lt;object&gt; | An array of **RelativeTimeFormat** objects in parts.|
- Example
**Example**
```
var relativetimefmt = new Intl.RelativeTimeFormat("en", {"numeric": "auto"});
var parts = relativetimefmt.format(10, "seconds");
......@@ -680,12 +680,12 @@ Obtains the formatting options for **RelativeTimeFormat** objects.
**System capability**: SystemCapability.Global.I18n
- Return value
| Type| Description|
| -------- | -------- |
| [RelativeTimeFormatResolvedOptions](#relativetimeformatresolvedoptions) | Formatting options for **RelativeTimeFormat** objects.|
**Return Value**
| Type | Description |
| ---------------------------------------- | --------------------------------- |
| [RelativeTimeFormatResolvedOptions](#relativetimeformatresolvedoptions) | Formatting options for **RelativeTimeFormat** objects.|
- Example
**Example**
```
var relativetimefmt= new Intl.RelativeTimeFormat("en-GB");
relativetimefmt.resolvedOptions();
......@@ -698,11 +698,11 @@ Represents the properties of a **RelativeTimeFormat** object.
**System capability**: SystemCapability.Global.I18n
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| 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**.|
| style | string | Yes| Yes| Length of an internationalized message. The value can be **long**, **short**, or **narrow**.|
| Name | Type | Readable | Writable | Description |
| ------------- | ------ | ---- | ---- | ---------------------------------------- |
| 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**. |
| 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>
......@@ -711,9 +711,9 @@ Represents the properties of a **RelativeTimeFormat** object.
**System capability**: SystemCapability.Global.I18n
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| 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**.|
| style | string | Yes| Yes| Length of an internationalized message. The value can be **long**, **short**, or **narrow**.|
| numberingSystem | string | Yes| Yes| Numbering system.|
| Name | Type | Readable | Writable | Description |
| --------------- | ------ | ---- | ---- | ---------------------------------------- |
| 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**. |
| style | string | Yes | Yes | Length of an internationalized message. The value can be **long**, **short**, or **narrow**.|
| numberingSystem | string | Yes | Yes | Numbering system. |
# Update
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
The Update module applies to updates throughout the entire system, including built-in resources and preset applications, but not third-party applications.
......@@ -30,15 +30,15 @@ Obtains the **Updater** object for local update.
**Parameters**
| Name | Type | Mandatory| Description |
| ----------- | --------------------------- | ---- | -------- |
| upgradeFile | string | Yes | Update file.|
| updateType | [UpdateTypes](#updatetypes) | Yes | Update type.|
| Name | Type | Mandatory | Description |
| ----------- | --------------------------- | ---- | ---- |
| upgradeFile | string | Yes | Update file.|
| updateType | [UpdateTypes](#updatetypes) | Yes | Update type.|
**Return Value**
**Return value**
| Type | Description |
| ------------------- | -------- |
| Type | Description |
| ------------------- | ---- |
| [Updater](#updater) | **Updater** object.|
**Example**
......@@ -61,16 +61,16 @@ Obtains the **Updater** object for the device to be updated.
**Parameters**
| Name | Type | Mandatory| Description |
| ----------- | --------------------------- | ---- | ---------- |
| upgradeFile | string | Yes | Update file. |
| device | string | Yes | Device to be updated.|
| updateType | [UpdateTypes](#updatetypes) | Yes | Update type. |
| Name | Type | Mandatory | Description |
| ----------- | --------------------------- | ---- | ----- |
| upgradeFile | string | Yes | Update file. |
| device | string | Yes | Device to be updated.|
| updateType | [UpdateTypes](#updatetypes) | Yes | Update type. |
**Return Value**
**Return value**
| Type | Description |
| ------------------- | -------- |
| Type | Description |
| ------------------- | ---- |
| [Updater](#updater) | **Updater** object.|
**Example**
......@@ -93,16 +93,16 @@ Obtains the **Updater** object from another device for the device to be updated.
**Parameters**
| Name | Type | Mandatory| Description |
| ----------- | --------------------------- | ---- | ---------- |
| upgradeFile | string | Yes | Update file. |
| device | string | Yes | Device to be updated.|
| updateType | [UpdateTypes](#updatetypes) | Yes | Update type. |
| Name | Type | Mandatory | Description |
| ----------- | --------------------------- | ---- | ----- |
| upgradeFile | string | Yes | Update file. |
| device | string | Yes | Device to be updated.|
| updateType | [UpdateTypes](#updatetypes) | Yes | Update type. |
**Return Value**
**Return value**
| Type | Description |
| ------------------- | -------- |
| Type | Description |
| ------------------- | ---- |
| [Updater](#updater) | **Updater** object.|
**Example**
......@@ -121,15 +121,15 @@ try {
getNewVersionInfo(callback: AsyncCallback\<NewVersionInfo>): void
Obtains the new version information. This API uses an asynchronous callback to return the result.
Obtains the new version information. This function uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Update.UpdateService
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------ | ---- | ------------------ |
| callback | AsyncCallback<[NewVersionInfo](#newversioninfo)> | No | Callback used to return the result.|
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | --------- |
| callback | AsyncCallback<[NewVersionInfo](#newversioninfo)> | No | Callback used to return the new version information.|
**Example**
......@@ -146,15 +146,15 @@ update.getNewVersionInfo(info => {
getNewVersionInfo(): Promise\<NewVersionInfo>
Obtains the new version information. This API uses a promise to return the result.
Obtains the new version information. This function uses a promise to return the result.
**System capability**: SystemCapability.Update.UpdateService
**Return Value**
**Return value**
| Type | Description |
| ------------------------------------------- | ------------------------- |
| Promise\<[NewVersionInfo](#newversioninfo)> | Promise used to return the result.|
| Type | Description |
| ---------------------------------------- | ---------------- |
| Promise\<[NewVersionInfo](#newversioninfo)> | Promise used to return the new version information.|
**Example**
......@@ -172,15 +172,15 @@ updater.getNewVersionInfo().then(value => {
checkNewVersion(callback: AsyncCallback\<NewVersionInfo>): void
Checks whether the current version is the latest. This API uses an asynchronous callback to return the result.
Checks whether the current version is the latest. This function uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Update.UpdateService
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------- | ---- | ------------------ |
| callback | AsyncCallback\<[NewVersionInfo](#newversioninfo)> | No | Callback used to return the result.|
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | --------- |
| callback | AsyncCallback\<[NewVersionInfo](#newversioninfo)> | No | Callback used to return the new version information.|
**Example**
......@@ -197,15 +197,15 @@ update.checkNewVersion(info => {
checkNewVersion(): Promise\<NewVersionInfo>
Checks whether the current version is the latest. This API uses a promise to return the result.
Checks whether the current version is the latest. This function uses a promise to return the result.
**System capability**: SystemCapability.Update.UpdateService
**Return Value**
**Return value**
| Type | Description |
| ------------------------------------------- | ------------------------- |
| Promise\<[NewVersionInfo](#newversioninfo)> | Promise used to return the result.|
| Type | Description |
| ---------------------------------------- | ---------------- |
| Promise\<[NewVersionInfo](#newversioninfo)> | Promise used to return the new version information.|
**Example**
......@@ -229,10 +229,10 @@ Verifies whether the update package is valid.
**Parameters**
| Name | Type | Mandatory| Description |
| ----------- | ------ | ---- | ------------------ |
| upgradeFile | string | Yes | Path of the update package to be verified.|
| certsFile | string | Yes | Certificate path. |
| Name | Type | Mandatory | Description |
| ----------- | ------ | ---- | --------- |
| upgradeFile | string | Yes | Path of the update package to be verified.|
| certsFile | string | Yes | Certificate path. |
**Example**
......@@ -247,15 +247,15 @@ update.verifyUpdatePackage("XXX", "XXX");
rebootAndCleanUserData(): Promise\<number>
Reboots the device and clears the user partition data. This API uses a promise to return the result.
Reboots the device and clears the user partition data. This function uses a promise to return the result.
**System capability**: SystemCapability.Update.UpdateService
**Return Value**
**Return value**
| Type | Description |
| ---------------- | ------------------------------- |
| Promise\<number> | Promise used to return the result.|
| Type | Description |
| ---------------- | ------------------- |
| Promise\<number> | Promise used to return the execution result.|
**Example**
......@@ -271,15 +271,15 @@ update.rebootAndCleanUserData().then(result => {
rebootAndCleanUserData(callback: AsyncCallback\<number>): void
Reboots the device and clears the user partition data. This API uses an asynchronous callback to return the result.
Reboots the device and clears the user partition data. This function uses a promise to return the result.
**System capability**: SystemCapability.Update.UpdateService
**Parameters**
| Name | Type | Mandatory| Description |
| Name | Type | Mandatory | Description |
| -------- | -------- | ---- | ---------------------- |
| callback | AsyncCallback\<number>| Yes | Callback used to return the result.|
| callback | AsyncCallback\<number>| Yes | Callback used to return the execution result.|
**Example**
......@@ -293,15 +293,15 @@ update.rebootAndCleanUserData(result => {
applyNewVersion(): Promise\<number>
Installs the update package. This API uses a promise to return the result.
Installs the update package. This function uses a promise to return the result.
**System capability**: SystemCapability.Update.UpdateService
**Return Value**
**Return value**
| Type | Description |
| ---------------- | ------------------------------- |
| Promise\<number> | Promise used to return the result.|
| Type | Description |
| ---------------- | ------------------- |
| Promise\<number> | Promise used to return the execution result.|
**Example**
......@@ -317,15 +317,15 @@ update.applyNewVersion().then(result => {
applyNewVersion(callback: AsyncCallback\<number>): void
Installs the update package. This API uses an asynchronous callback to return the result.
Installs the update package. This function uses a promise to return the result.
**System capability**: SystemCapability.Update.UpdateService
**Parameters**
| Name | Type | Mandatory| Description |
| Name | Type | Mandatory | Description |
| -------- | -------- | ---- | ---------------------- |
| callback | AsyncCallback\<number>| Yes | Callback used to return the result.|
| callback | AsyncCallback\<number>| Yes | Callback used to return the execution result.|
**Example**
......@@ -356,7 +356,7 @@ updater.download();
### upgrade
updater.upgrade():void
upgrade():void
Starts an update.
......@@ -377,16 +377,16 @@ updater.upgrade();
setUpdatePolicy(policy: UpdatePolicy, callback: AsyncCallback\<number>): void
Sets the update policy. This API uses an asynchronous callback to return the result.
Sets the update policy. This function uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Update.UpdateService
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------------- | ---- | ------------ |
| policy | [UpdatePolicy](#updatepolicy) | Yes | Update policy to set.|
| callback | AsyncCallback\<number> | Yes | Callback used to return the result.|
| Name | Type | Mandatory | Description |
| -------- | ----------------------------- | ---- | ------ |
| policy | [UpdatePolicy](#updatepolicy) | Yes | Update policy to set.|
| callback | Callback used to return the execution result. | Yes | Callback used to return the execution result.|
**Example**
......@@ -408,21 +408,21 @@ update.setUpdatePolicy(policy, result => {
setUpdatePolicy(policy: UpdatePolicy): Promise\<number>
Sets the update policy. This API uses a promise to return the result.
Sets the update policy. This function uses a promise to return the result.
**System capability**: SystemCapability.Update.UpdateService
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ----------------------------- | ---- | ------------ |
| policy | [UpdatePolicy](#updatepolicy) | Yes | Update policy to set.|
| Name | Type | Mandatory | Description |
| ------ | ----------------------------- | ---- | ------ |
| policy | [UpdatePolicy](#updatepolicy) | Yes | Update policy to set.|
**Return Value**
**Return value**
| Type | Description |
| ---------------- | ----------------------- |
| Promise\<number> | Promise used to return the result.|
| Type | Description |
| ---------------- | --------------- |
| Promise\<number> | Promise used to return the execution result.|
**Example**
......@@ -445,15 +445,15 @@ update.setUpdatePolicy(policy).then(result =>
getUpdatePolicy(callback: AsyncCallback\<UpdatePolicy>): void
Obtains the update policy. This API uses an asynchronous callback to return the result.
Obtains the update policy. This function uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Update.UpdateService
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------------------------------- | ---- | -------------------- |
| callback | AsyncCallback\<[UpdatePolicy](#updatepolicy)> | No | Callback used to return the result.|
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ---------- |
| callback | AsyncCallback\<[UpdatePolicy](#updatepolicy)> | No | Callback used to return the update policy.|
**Example**
......@@ -470,15 +470,15 @@ update.getUpdatePolicy(policy => {
getUpdatePolicy(): Promise\<UpdatePolicy>
Obtains the update policy. This API uses a promise to return the result.
Obtains the update policy. This function uses a promise to return the result.
**System capability**: SystemCapability.Update.UpdateService
**Return Value**
**Return value**
| Type | Description |
| --------------------------------------- | --------------------------- |
| Promise\<[UpdatePolicy](#updatepolicy)> | Promise used to return the result.|
| Type | Description |
| --------------------------------------- | ----------------- |
| Promise\<[UpdatePolicy](#updatepolicy)> | Promise used to return the update policy.|
**Example**
......@@ -498,10 +498,10 @@ Enumerates update types.
**System capability**: SystemCapability.Update.UpdateService
| Name| Description |
| ------ | -------- |
| OTA | OTA update. |
| patch | Patch update.|
| Name | Description |
| ----- | ----- |
| OTA | OTA update.|
| patch | Patch update. |
## PackageTypes
......@@ -509,15 +509,15 @@ Enumerates update package types.
**System capability**: SystemCapability.Update.UpdateService
| Name | Default Value| Description |
| -------------------- | ------ | -------------- |
| PACKAGE_TYPE_NORMAL | 1 | Common update package. |
| PACKAGE_TYPE_BASE | 2 | Basic update package. |
| PACKAGE_TYPE_CUST | 3 | Custom update package. |
| PACKAGE_TYPE_PRELOAD | 4 | Preinstalled update package. |
| PACKAGE_TYPE_COTA | 5 | Parameter configuration update package.|
| PACKAGE_TYPE_VERSION | 6 | Version update package. |
| PACKAGE_TYPE_PATCH | 7 | Patch packages |
| Name | Default Value | Description |
| -------------------- | ---- | ------- |
| PACKAGE_TYPE_NORMAL | 1 | Common update package. |
| PACKAGE_TYPE_BASE | 2 | Basic update package. |
| PACKAGE_TYPE_CUST | 3 | Custom update package. |
| PACKAGE_TYPE_PRELOAD | 4 | Preinstalled update package. |
| PACKAGE_TYPE_COTA | 5 | Parameter configuration update package.|
| PACKAGE_TYPE_VERSION | 6 | Version update package. |
| PACKAGE_TYPE_PATCH | 7 | Patch package. |
## InstallMode
......@@ -525,11 +525,11 @@ Enumerates update modes.
**System capability**: SystemCapability.Update.UpdateService
| Name | Default Value| Description |
| ------------------- | ------ | -------- |
| INSTALL_MODE_NORMAL | 0 | Normal update.|
| INSTALL_MODE_NIGHT | 1 | Update at night.|
| INSTALL_MODE_AUTO | 2 | Automatic update.|
| Name | Default Value | Description |
| ------------------- | ---- | ---- |
| INSTALL_MODE_NORMAL | 0 | Normal update.|
| INSTALL_MODE_NIGHT | 1 | Update at night.|
| INSTALL_MODE_AUTO | 2 | Automatic update.|
## NewVersionStatus
......@@ -537,12 +537,12 @@ Enumerates new version check results.
**System capability**: SystemCapability.Update.UpdateService
| Name | Default Value| Description |
| ------------------- | ------ | ---------------- |
| VERSION_STATUS_ERR | -1 | System error while checking for the new version. |
| VERSION_STATUS_NEW | 0 | New version detected. |
| VERSION_STATUS_NONE | 1 | No new version detected.|
| VERSION_STATUS_BUSY | 2 | System busy while checking for the new version. |
| Name | Default Value | Description |
| ------------------- | ---- | -------- |
| VERSION_STATUS_ERR | -1 | System error while checking for the new version. |
| VERSION_STATUS_NEW | 0 | New version detected. |
| VERSION_STATUS_NONE | 1 | No new version detected.|
| VERSION_STATUS_BUSY | 2 | System busy while checking for the new version. |
## UpdatePolicy
......@@ -550,11 +550,11 @@ Defines the update policy.
**System capability**: SystemCapability.Update.UpdateService
| Name | Type | Mandatory| Description |
| ------------------- | --------------------------- | ---- | -------------- |
| autoDownload | bool | Yes | Automatic update switch. |
| installMode | [InstallMode](#installmode) | Yes | Installation mode. |
| autoUpgradeInterval | Array\<number> | Yes | Period of time for automatic update.|
| Name | Type | Mandatory | Description |
| ------------------- | --------------------------- | ---- | ------- |
| autoDownload | bool | Yes | Automatic update switch. |
| installMode | [InstallMode](#installmode) | Yes | Update mode. |
| autoUpgradeInterval | Array\<number> | Yes | Period of time for automatic update.|
## NewVersionInfo
......@@ -562,12 +562,12 @@ Defines the new version information.
**System capability**: SystemCapability.Update.UpdateService
| Name | Type | Mandatory| Description |
| --------------- | ------------------------------------------- | ---- | -------- |
| status | [NewVersionStatus](#newversionstatus) | Yes | Update status.|
| errMsg | string | Yes | Error message.|
| checkResults | Array<[CheckResult](#checkresult)> | Yes | Version check result.|
| descriptionInfo | Array\<[DescriptionInfo](#descriptioninfo)> | Yes | Version description information.|
| Name | Type | Mandatory | Description |
| --------------- | ---------------------------------------- | ---- | ---- |
| status | [NewVersionStatus](#newversionstatus) | Yes | Update status.|
| errMsg | string | Yes | Error message.|
| checkResults | Array<[CheckResult](#checkresult)> | Yes | Version check result.|
| descriptionInfo | Array\<[DescriptionInfo](#descriptioninfo)> | Yes | Version description information.|
## CheckResult
......@@ -575,14 +575,14 @@ Defines the version check result.
**System capability**: SystemCapability.Update.UpdateService
| Name | Type | Mandatory| Description |
| ------------- | ----------------------------- | ---- | ------------ |
| versionName | string | Yes | Version name. |
| versionCode | number | Yes | Version code. |
| size | number | Yes | Version size. |
| verifyInfo | string | Yes | Version verification information.|
| packageType | [PackageTypes](#packagetypes) | Yes | Version type. |
| descriptionId | string | Yes | Version description information.|
| Name | Type | Mandatory | Description |
| ------------- | ----------------------------- | ---- | ------ |
| versionName | string | Yes | Version name. |
| versionCode | number | Yes | Version code. |
| size | number | Yes | Version size. |
| verifyInfo | string | Yes | Version verification information.|
| packageType | [PackageTypes](#packagetypes) | Yes | Version type. |
| descriptionId | string | Yes | Version description information.|
## DescriptionInfo
......@@ -590,7 +590,7 @@ Defines the version description information.
**System capability**: SystemCapability.Update.UpdateService
| Name | Type| Mandatory| Description |
| ------------- | -------- | ---- | ----------------- |
| descriptionId | string | Yes | Version ID information.|
| content | string | Yes | Version changelog information.|
| Name | Type | Mandatory | Description |
| ------------- | ------ | ---- | ------------- |
| descriptionId | string | Yes | Version ID information.|
| content | string | Yes | Version changelog information.|
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册