提交 66aa8c15 编写于 作者: S shawn_he

update docs

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