提交 eab5ab00 编写于 作者: S shawn_he

update doc

Signed-off-by: Nshawn_he <shawn.he@huawei.com>
上级 e30a368e
...@@ -26,6 +26,7 @@ Obtains the localized script for the specified language. ...@@ -26,6 +26,7 @@ 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. |
...@@ -33,6 +34,7 @@ Obtains the localized script for the specified language. ...@@ -33,6 +34,7 @@ Obtains the localized script for the specified language.
| 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.|
...@@ -53,6 +55,7 @@ Obtains the localized script for the specified country. ...@@ -53,6 +55,7 @@ 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. |
...@@ -60,6 +63,7 @@ Obtains the localized script for the specified country. ...@@ -60,6 +63,7 @@ Obtains the localized script for the specified country.
| 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.|
...@@ -80,11 +84,13 @@ Checks whether the localized script for the specified language is displayed from ...@@ -80,11 +84,13 @@ 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.|
...@@ -105,6 +111,7 @@ Obtains the system language. ...@@ -105,6 +111,7 @@ 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.|
...@@ -128,11 +135,13 @@ This is a system API. ...@@ -128,11 +135,13 @@ This is a system API.
**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.|
...@@ -143,7 +152,7 @@ This is a system API. ...@@ -143,7 +152,7 @@ This is a system API.
``` ```
## i18n.getSystemLanguages ## i18n.getSystemLanguages<sup>9+</sup>
getSystemLanguages(): Array&lt;string&gt; getSystemLanguages(): Array&lt;string&gt;
...@@ -154,6 +163,7 @@ Obtains the list of system languages. ...@@ -154,6 +163,7 @@ Obtains the list of system languages.
**System API**: This is a system API and cannot be called by third-party applications. **System API**: This is a system API and cannot be called by third-party applications.
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------------- | ------------ | | ------------------- | ------------ |
| Array&lt;string&gt; | List of the IDs of system languages.| | Array&lt;string&gt; | List of the IDs of system languages.|
...@@ -164,7 +174,7 @@ Obtains the list of system languages. ...@@ -164,7 +174,7 @@ Obtains the list of system languages.
``` ```
## i18n.getSystemCountries ## i18n.getSystemCountries<sup>9+</sup>
getSystemCountries(language: string): Array&lt;string&gt; getSystemCountries(language: string): Array&lt;string&gt;
...@@ -175,11 +185,13 @@ Obtains the list of countries and regions supported for the specified language. ...@@ -175,11 +185,13 @@ Obtains the list of countries and regions supported for the specified language.
**System API**: This is a system API and cannot be called by third-party applications. **System API**: This is a system API and cannot be called by third-party applications.
**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&lt;string&gt; | 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.|
...@@ -199,6 +211,7 @@ Obtains the system region. ...@@ -199,6 +211,7 @@ 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.|
...@@ -222,11 +235,13 @@ This is a system API. ...@@ -222,11 +235,13 @@ This is a system API.
**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.|
...@@ -246,6 +261,7 @@ Obtains the system locale. ...@@ -246,6 +261,7 @@ 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.|
...@@ -269,11 +285,13 @@ This is a system API. ...@@ -269,11 +285,13 @@ This is a system API.
**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.|
...@@ -284,7 +302,7 @@ This is a system API. ...@@ -284,7 +302,7 @@ This is a system API.
``` ```
## i18n.isSuggested ## i18n.isSuggested<sup>9+</sup>
isSuggested(language: string, region?: string): boolean isSuggested(language: string, region?: string): boolean
...@@ -295,12 +313,14 @@ Checks whether the system language matches the specified region. ...@@ -295,12 +313,14 @@ Checks whether the system language matches the specified region.
**System API**: This is a system API and cannot be called by third-party applications. **System API**: This is a system API and cannot be called by third-party applications.
**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.|
...@@ -320,12 +340,14 @@ Obtains a **Calendar** object. ...@@ -320,12 +340,14 @@ 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.|
...@@ -348,6 +370,7 @@ Sets the date for this **Calendar** object. ...@@ -348,6 +370,7 @@ 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.|
...@@ -369,6 +392,7 @@ Sets the date and time for this **Calendar** object. The value is represented by ...@@ -369,6 +392,7 @@ 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.|
...@@ -389,6 +413,7 @@ Sets the year, month, day, hour, minute, and second for this **Calendar** object ...@@ -389,6 +413,7 @@ 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. |
...@@ -414,6 +439,7 @@ Sets the time zone of this **Calendar** object. ...@@ -414,6 +439,7 @@ 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**.|
...@@ -434,6 +460,7 @@ Obtains the time zone of this **Calendar** object. ...@@ -434,6 +460,7 @@ 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.|
...@@ -455,6 +482,7 @@ Obtains the start day of a week for this **Calendar** object. ...@@ -455,6 +482,7 @@ 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.|
...@@ -475,6 +503,7 @@ Sets the start day of a week for this **Calendar** object. ...@@ -475,6 +503,7 @@ 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.|
...@@ -495,6 +524,7 @@ Obtains the minimum number of days in the first week of a year. ...@@ -495,6 +524,7 @@ 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.|
...@@ -515,6 +545,7 @@ Sets the minimum number of days in the first week of a year. ...@@ -515,6 +545,7 @@ 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.|
...@@ -535,11 +566,13 @@ Obtains the value of the specified field in the **Calendar** object. ...@@ -535,11 +566,13 @@ 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**.|
...@@ -561,11 +594,13 @@ Obtains the name of the **Calendar** object displayed for the specified locale. ...@@ -561,11 +594,13 @@ 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.|
...@@ -586,11 +621,13 @@ Checks whether the specified date in this **Calendar** object is a weekend. ...@@ -586,11 +621,13 @@ 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.|
...@@ -620,7 +657,7 @@ Parameters ...@@ -620,7 +657,7 @@ 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](#phonenumberformatoptions9) | No | Options of the **PhoneNumberFormat** object. |
**Example** **Example**
```js ```js
...@@ -637,11 +674,13 @@ Checks whether the format of the specified phone number is valid. ...@@ -637,11 +674,13 @@ 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.|
...@@ -662,11 +701,13 @@ Formats a phone number. ...@@ -662,11 +701,13 @@ 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.|
...@@ -686,12 +727,14 @@ Obtains the home location of a phone number. ...@@ -686,12 +727,14 @@ Obtains the home location of 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.| | number | string | Yes | Phone number.|
| locale | string | Yes | Locale ID.| | locale | string | Yes | Locale ID.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | ---------- | | ------ | ---------- |
| string | Home location of the phone number.| | string | Home location of the phone number.|
...@@ -703,7 +746,7 @@ Obtains the home location of a phone number. ...@@ -703,7 +746,7 @@ Obtains the home location of a phone number.
``` ```
## PhoneNumberFormatOptions<sup>8+</sup> ## PhoneNumberFormatOptions<sup>9+</sup>
Defines the options for this PhoneNumberFormat object. Defines the options for this PhoneNumberFormat object.
...@@ -726,18 +769,24 @@ Defines the measurement unit information. ...@@ -726,18 +769,24 @@ Defines the measurement unit information.
| measureSystem | string | Yes | Yes | Measurement system. The value can be **SI**,&nbsp;**US**, or&nbsp;**UK**.| | measureSystem | string | Yes | Yes | Measurement system. The value can be **SI**,&nbsp;**US**, or&nbsp;**UK**.|
## Util<sup>8+</sup> ## Util<sup>(deprecated)</sup>
### unitConvert<sup>8+</sup> ### unitConvert<sup>(deprecated)</sup>
static unitConvert(fromUnit: UnitInfo, toUnit: UnitInfo, value: number, locale: string, style?: string): string static unitConvert(fromUnit: UnitInfo, toUnit: UnitInfo, value: number, locale: string, style?: string): string
Converts one measurement unit into another and formats the unit based on the specified locale and style. Converts one measurement unit into another and formats the unit based on the specified locale and style.
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [unitConvert](#unitconvert9) instead.
>
> This API is supported since API version 8.
**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. |
...@@ -747,37 +796,10 @@ Converts one measurement unit into another and formats the unit based on the spe ...@@ -747,37 +796,10 @@ Converts one measurement unit into another and formats the unit based on the spe
| style | string | No | Style used for formatting. The value can be **long**, **short**, or **narrow**.| | style | string | No | Style used for formatting. The value can be **long**, **short**, or **narrow**.|
**Return value** **Return value**
| Type | Description |
| ------ | ----------------------- |
| string | Character string obtained after formatting based on the measurement unit specified by **toUnit**.|
**Example**
```js
i18n.Util.unitConvert({unit: "cup", measureSystem: "US"}, {unit: "liter", measureSystem: "SI"}, 1000, "en-US", "long");
```
### getDateOrder<sup>9+</sup>
static getDateOrder(locale: string): string
Obtains the sequence of the year, month, and day in the specified locale.
**System capability**: SystemCapability.Global.I18n
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ---------------------- | ---- | ---------------------------------------- |
| locale | string | Yes | Locale used for formatting, for example, **zh-Hans-CN**. |
**Return value**
| Type | Description | | Type | Description |
| ------ | ----------------------- | | ------ | ----------------------- |
| string | Sequence of the year, month, and day.| | string | Character string obtained after formatting based on the measurement unit specified by **toUnit**.|
**Example**
```
i18n.Util.getDateOrder("zh-CN");
```
## getInstance<sup>8+</sup> ## getInstance<sup>8+</sup>
...@@ -789,11 +811,13 @@ Creates an **IndexUtil** object. ...@@ -789,11 +811,13 @@ 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.|
...@@ -816,6 +840,7 @@ Obtains the index list for this **locale** object. ...@@ -816,6 +840,7 @@ 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.|
...@@ -836,6 +861,7 @@ Adds the index of the new **locale** object to the index list. ...@@ -836,6 +861,7 @@ 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.|
...@@ -856,11 +882,13 @@ Obtains the index of a text object. ...@@ -856,11 +882,13 @@ 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.|
...@@ -872,223 +900,250 @@ Obtains the index of a text object. ...@@ -872,223 +900,250 @@ Obtains the index of a text object.
``` ```
## Character<sup>8+</sup> ## Character<sup>(deprecated)</sup>
### isDigit<sup>8+</sup> ### isDigit<sup>(deprecated)</sup>
static isDigit(char: string): boolean static isDigit(char: string): boolean
Checks whether the input character string is composed of digits. Checks whether the input character string is composed of digits.
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [isDigit](#isdigit9) instead.
>
> This API is supported since API version 8.
**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**
```js
var isdigit = i18n.Character.isDigit("1"); // Return true.
```
### isSpaceChar<sup>8+</sup> ### isSpaceChar<sup>(deprecated)</sup>
static isSpaceChar(char: string): boolean static isSpaceChar(char: string): boolean
Checks whether the input character is a space. Checks whether the input character is a space.
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [isSpaceChar](#isspacechar9) instead.
>
> This API is supported since API version 8.
**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**
```js
var isspacechar = i18n.Character.isSpaceChar("a"); // Return false.
```
### isWhitespace<sup>8+</sup> ### isWhitespace<sup>(deprecated)</sup>
static isWhitespace(char: string): boolean static isWhitespace(char: string): boolean
Checks whether the input character is a white space. Checks whether the input character is a white space.
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [isWhitespace](#iswhitespace9) instead.
>
> This API is supported since API version 8.
**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**
```js
var isspacechar = i18n.Character.isSpaceChar("a"); // Return false.
```
### isRTL<sup>8+</sup> ### isRTL<sup>(deprecated)</sup>
static isRTL(char: string): boolean static isRTL(char: string): boolean
Checks whether the input character is of the right to left (RTL) language. Checks whether the input character is of the right to left (RTL) language.
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [isRTL](#isrtl9) instead.
>
> This API is supported since API version 8.
**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**
```js
var isrtl = i18n.Character.isRTL("a"); // Return false.
```
### isIdeograph<sup>8+</sup> ### isIdeograph<sup>(deprecated)</sup>
static isIdeograph(char: string): boolean static isIdeograph(char: string): boolean
Checks whether the input character is an ideographic character. Checks whether the input character is an ideographic character.
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [isIdeograph](#isideograph9) instead.
>
> This API is supported since API version 8.
**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**
```js
var isideograph = i18n.Character.isIdeograph("a"); // Return false.
```
### isLetter<sup>8+</sup> ### isLetter<sup>(deprecated)</sup>
static isLetter(char: string): boolean static isLetter(char: string): boolean
Checks whether the input character is a letter. Checks whether the input character is a letter.
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [isLetter](#isletter9) instead.
>
> This API is supported since API version 8.
**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**
```js
var isletter = i18n.Character.isLetter("a"); // Return true.
```
### isLowerCase<sup>8+</sup> ### isLowerCase<sup>(deprecated)</sup>
static isLowerCase(char: string): boolean static isLowerCase(char: string): boolean
Checks whether the input character is a lowercase letter. Checks whether the input character is a lowercase letter.
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [isLowerCase](#islowercase9) instead.
>
> This API is supported since API version 8.
**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**
```js
var islowercase = i18n.Character.isLowerCase("a"); // Return true.
```
### isUpperCase<sup>8+</sup> ### isUpperCase<sup>(deprecated)</sup>
static isUpperCase(char: string): boolean static isUpperCase(char: string): boolean
Checks whether the input character is an uppercase letter. Checks whether the input character is an uppercase letter.
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [isUpperCase](#isuppercase9) instead.
>
> This API is supported since API version 8.
**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**
```js
var isuppercase = i18n.Character.isUpperCase("a"); // Return false.
```
### getType<sup>8+</sup> ### getType<sup>(deprecated)</sup>
static getType(char: string): string static getType(char: string): string
Obtains the type of the input character string. Obtains the type of the input character string.
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [getType](#gettype9) instead.
>
> This API is supported since API version 8.
**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**
```js
var type = i18n.Character.getType("a");
```
## i18n.getLineInstance<sup>8+</sup> ## i18n.getLineInstance<sup>8+</sup>
...@@ -1100,11 +1155,13 @@ Obtains a [BreakIterator](#breakiterator8) object for text segmentation. ...@@ -1100,11 +1155,13 @@ 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.|
...@@ -1127,6 +1184,7 @@ Sets the text to be processed by the [BreakIterator](#breakiterator8) object. ...@@ -1127,6 +1184,7 @@ 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.|
...@@ -1147,6 +1205,7 @@ Obtains the text being processed by the [BreakIterator](#breakiterator8) object. ...@@ -1147,6 +1205,7 @@ 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.|
...@@ -1168,6 +1227,7 @@ Obtains the position of the [BreakIterator](#breakiterator8) object in the text ...@@ -1168,6 +1227,7 @@ 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.|
...@@ -1189,6 +1249,7 @@ Puts the [BreakIterator](#breakiterator8) object to the first text boundary, whi ...@@ -1189,6 +1249,7 @@ 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.|
...@@ -1210,6 +1271,7 @@ Puts the [BreakIterator](#breakiterator8) object to the last text boundary, whic ...@@ -1210,6 +1271,7 @@ 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.|
...@@ -1231,11 +1293,13 @@ Moves the [BreakIterator](#breakiterator8) object backward by the specified numb ...@@ -1231,11 +1293,13 @@ 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.|
...@@ -1259,6 +1323,7 @@ Moves the [BreakIterator](#breakiterator8) object to the previous text boundary. ...@@ -1259,6 +1323,7 @@ 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.|
...@@ -1282,11 +1347,13 @@ Moves the [BreakIterator](#breakiterator8) object to the text boundary after the ...@@ -1282,11 +1347,13 @@ 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.|
...@@ -1310,11 +1377,13 @@ Checks whether the position specified by the offset is a text boundary. If **tru ...@@ -1310,11 +1377,13 @@ 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.|
...@@ -1337,6 +1406,7 @@ Checks whether the 24-hour clock is used. ...@@ -1337,6 +1406,7 @@ 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.|
...@@ -1358,11 +1428,13 @@ Sets the 24-hour clock. ...@@ -1358,11 +1428,13 @@ Sets the 24-hour clock.
**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.|
...@@ -1385,12 +1457,14 @@ Adds a preferred language to the specified position on the preferred language li ...@@ -1385,12 +1457,14 @@ Adds a preferred language to the specified position on the preferred language li
**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.|
...@@ -1415,11 +1489,13 @@ Deletes a preferred language from the specified position on the preferred langua ...@@ -1415,11 +1489,13 @@ Deletes a preferred language from the specified position on the preferred langua
**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.|
...@@ -1441,6 +1517,7 @@ Obtains the list of preferred languages. ...@@ -1441,6 +1517,7 @@ 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&lt;string&gt; | List of preferred languages.| | Array&lt;string&gt; | List of preferred languages.|
...@@ -1460,6 +1537,7 @@ Obtains the first language in the preferred language list. ...@@ -1460,6 +1537,7 @@ 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.|
...@@ -1479,6 +1557,7 @@ Obtains the preferred language of an application. ...@@ -1479,6 +1557,7 @@ Obtains the preferred language of an application.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | -------------- | | ------ | -------------- |
| string | Preferred language of the application.| | string | Preferred language of the application.|
...@@ -1498,11 +1577,13 @@ Obtains the **TimeZone** object corresponding to the specified time zone ID. ...@@ -1498,11 +1577,13 @@ 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.|
...@@ -1525,6 +1606,7 @@ Obtains the ID of the specified **TimeZone** object. ...@@ -1525,6 +1606,7 @@ 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.|
...@@ -1545,12 +1627,14 @@ Obtains the representation of a **TimeZone** object in the specified locale. ...@@ -1545,12 +1627,14 @@ 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.|
...@@ -1571,6 +1655,7 @@ Obtains the offset between the time zone represented by a **TimeZone** object an ...@@ -1571,6 +1655,7 @@ 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.|
...@@ -1591,6 +1676,7 @@ Obtains the offset between the time zone represented by a **TimeZone** object an ...@@ -1591,6 +1676,7 @@ 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.|
...@@ -1610,6 +1696,7 @@ Obtains the list of time zone IDs supported by the system. ...@@ -1610,6 +1696,7 @@ Obtains the list of time zone IDs supported by the system.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | ----------------------- | | ------ | ----------------------- |
| Array&lt;string&gt; | List of time zone IDs supported by the system.| | Array&lt;string&gt; | List of time zone IDs supported by the system.|
...@@ -1629,6 +1716,7 @@ Obtains the list of time zone city IDs supported by the system. ...@@ -1629,6 +1716,7 @@ Obtains the list of time zone city IDs supported by the system.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | ----------------------- | | ------ | ----------------------- |
| Array&lt;string&gt; | List of time zone city IDs supported by the system.| | Array&lt;string&gt; | List of time zone city IDs supported by the system.|
...@@ -1648,12 +1736,14 @@ Obtains the localized display of a time zone city in the specified locale. ...@@ -1648,12 +1736,14 @@ Obtains the localized display of a time zone city in the specified locale.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | ---- | ----- | | ------ | ------ | ---- | ----- |
| cityID | string | Yes | Time zone city ID.| | cityID | string | Yes | Time zone city ID.|
| locale | string | Yes | Locale ID.| | locale | string | Yes | Locale ID.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | ----------------------- | | ------ | ----------------------- |
| string | Localized display of the time zone city in the specified locale.| | string | Localized display of the time zone city in the specified locale.|
...@@ -1673,11 +1763,13 @@ Obtains the **TimeZone** object corresponding to the specified time zone city ID ...@@ -1673,11 +1763,13 @@ Obtains the **TimeZone** object corresponding to the specified time zone city ID
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | ---- | ----- | | ------ | ------ | ---- | ----- |
| cityID | string | Yes | Time zone city ID.| | cityID | string | Yes | Time zone city ID.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | ----------------------- | | ------ | ----------------------- |
| TimeZone | **TimeZone** object corresponding to the specified time zone city ID.| | TimeZone | **TimeZone** object corresponding to the specified time zone city ID.|
...@@ -1700,11 +1792,13 @@ This is a system API. ...@@ -1700,11 +1792,13 @@ This is a system API.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | ------ | ---- | ----- | | ------ | ------ | ---- | ----- |
| flag | boolean | Yes | Whether to turn on the local digit switch. The value **true** means to turn on the local digit switch, and the value **false** indicates the opposite.| | flag | boolean | Yes | Whether to turn on the local digit switch. The value **true** means to turn on the local digit switch, and the value **false** indicates the opposite.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| -------- | ------------ | | -------- | ------------ |
| boolean | Result indicating whether the local digit switch is successfully set. The value **true** indicates that the local digit switch is successfully set, and the value **false** indicates the opposite.| | boolean | Result indicating whether the local digit switch is successfully set. The value **true** indicates that the local digit switch is successfully set, and the value **false** indicates the opposite.|
...@@ -1724,6 +1818,7 @@ Checks whether the local digit switch is turned on. ...@@ -1724,6 +1818,7 @@ Checks whether the local digit switch is turned on.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
**Return value** **Return value**
| Type | Description | | Type | Description |
| -------- | ------------ | | -------- | ------------ |
| boolean | Result indicating whether the local digit switch is turned on. The value **true** indicates that the local digit switch is turned on, and the value **false** indicates the opposite.| | boolean | Result indicating whether the local digit switch is turned on. The value **true** indicates that the local digit switch is turned on, and the value **false** indicates the opposite.|
...@@ -1745,6 +1840,7 @@ Obtains a list of IDs supported by the **Transliterator** object. ...@@ -1745,6 +1840,7 @@ Obtains a list of IDs supported by the **Transliterator** object.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | ------------ | | ------ | ------------ |
| string[] | List of IDs supported by the **Transliterator** object.| | string[] | List of IDs supported by the **Transliterator** object.|
...@@ -1764,11 +1860,13 @@ Creates a **Transliterator** object. ...@@ -1764,11 +1860,13 @@ Creates a **Transliterator** object.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | ------- | ---- | -------------------- | | ------ | ------- | ---- | -------------------- |
| id | string | Yes | ID supported by the **Transliterator** object. | | id | string | Yes | ID supported by the **Transliterator** object. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | ------------- | | ------ | ------------- |
| [Transliterator](#transliterator9) | **Transliterator** object.| | [Transliterator](#transliterator9) | **Transliterator** object.|
...@@ -1788,11 +1886,13 @@ Converts the input string from the source format to the target format. ...@@ -1788,11 +1886,13 @@ Converts the input string from the source format to the target format.
**System capability**: SystemCapability.Global.I18n **System capability**: SystemCapability.Global.I18n
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------ | ------- | ---- | -------------------- | | ------ | ------- | ---- | -------------------- |
| text | string | Yes | Input string. | | text | string | Yes | Input string. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | ------------- | | ------ | ------------- |
| string | Target string.| | string | Target string.|
...@@ -1802,3 +1902,298 @@ Converts the input string from the source format to the target format. ...@@ -1802,3 +1902,298 @@ Converts the input string from the source format to the target format.
var transliterator = i18n.Transliterator.getInstance("Any-Latn"); var transliterator = i18n.Transliterator.getInstance("Any-Latn");
transliterator.transform ("China"); transliterator.transform ("China");
``` ```
## Unicode<sup>9+</sup>
### isDigit<sup>9+</sup>
static isDigit(char: string): boolean
Checks whether the input character string is composed of digits.
**System capability**: SystemCapability.Global.I18n
**Parameters**
| Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ----- |
| char | string | Yes | Input character.|
**Return value**
| Type | Description |
| ------- | ------------------------------------ |
| boolean | Returns **true** if the input character is a digit; returns **false** otherwise.|
**Example**
```js
var isdigit = i18n.Unicode.isDigit("1"); // Return true.
```
### isSpaceChar<sup>9+</sup>
static isSpaceChar(char: string): boolean
Checks whether the input character is a space.
**System capability**: SystemCapability.Global.I18n
**Parameters**
| Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ----- |
| char | string | Yes | Input character.|
**Return value**
| Type | Description |
| ------- | -------------------------------------- |
| boolean | Returns **true** if the input character is a space; returns **false** otherwise.|
**Example**
```js
var isspacechar = i18n.Unicode.isSpaceChar("a"); // Return false.
```
### isWhitespace<sup>9+</sup>
static isWhitespace(char: string): boolean
Checks whether the input character is a white space.
**System capability**: SystemCapability.Global.I18n
**Parameters**
| Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ----- |
| char | string | Yes | Input character.|
**Return value**
| Type | Description |
| ------- | -------------------------------------- |
| boolean | Returns **true** if the input character is a white space; returns **false** otherwise.|
**Example**
```js
var iswhitespace = i18n.Unicode.isWhitespace("a"); // Return false.
```
### isRTL<sup>9+</sup>
static isRTL(char: string): boolean
Checks whether the input character is of the right to left (RTL) language.
**System capability**: SystemCapability.Global.I18n
**Parameters**
| Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ----- |
| char | string | Yes | Input character.|
**Return value**
| Type | Description |
| ------- | ---------------------------------------- |
| boolean | Returns **true** if the input character is of the RTL language; returns **false** otherwise.|
**Example**
```js
var isrtl = i18n.Unicode.isRTL("a"); // Return false.
```
### isIdeograph<sup>9+</sup>
static isIdeograph(char: string): boolean
Checks whether the input character is an ideographic character.
**System capability**: SystemCapability.Global.I18n
**Parameters**
| Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ----- |
| char | string | Yes | Input character.|
**Return value**
| Type | Description |
| ------- | ---------------------------------------- |
| boolean | Returns **true** if the input character is an ideographic character; returns **false** otherwise.|
**Example**
```js
var isideograph = i18n.Unicode.isIdeograph("a"); // Return false.
```
### isLetter<sup>9+</sup>
static isLetter(char: string): boolean
Checks whether the input character is a letter.
**System capability**: SystemCapability.Global.I18n
**Parameters**
| Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ----- |
| char | string | Yes | Input character.|
**Return value**
| Type | Description |
| ------- | ------------------------------------ |
| boolean | Returns **true** if the input character is a letter; returns **false** otherwise.|
**Example**
```js
var isletter = i18n.Unicode.isLetter("a"); // Return true.
```
### isLowerCase<sup>9+</sup>
static isLowerCase(char: string): boolean
Checks whether the input character is a lowercase letter.
**System capability**: SystemCapability.Global.I18n
**Parameters**
| Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ----- |
| char | string | Yes | Input character.|
**Return value**
| Type | Description |
| ------- | ---------------------------------------- |
| boolean | Returns **true** if the input character is a lowercase letter; returns **false** otherwise.|
**Example**
```js
var islowercase = i18n.Unicode.isLowerCase("a"); // Return true.
```
### isUpperCase<sup>9+</sup>
static isUpperCase(char: string): boolean
Checks whether the input character is an uppercase letter.
**System capability**: SystemCapability.Global.I18n
**Parameters**
| Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ----- |
| char | string | Yes | Input character.|
**Return value**
| Type | Description |
| ------- | ---------------------------------------- |
| boolean | Returns **true** if the input character is an uppercase letter; returns **false** otherwise.|
**Example**
```js
var isuppercase = i18n.Unicode.isUpperCase("a"); // Return false.
```
### getType<sup>9+</sup>
static getType(char: string): string
Obtains the type of the input character string.
**System capability**: SystemCapability.Global.I18n
**Parameters**
| Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ----- |
| char | string | Yes | Input character.|
**Return value**
| Type | Description |
| ------ | ----------- |
| string | Type of the input character.|
**Example**
```js
var type = i18n.Unicode.getType("a");
```
## I18NUtil<sup>9+</sup>
### unitConvert<sup>9+</sup>
static unitConvert(fromUnit: UnitInfo, toUnit: UnitInfo, value: number, locale: string, style?: string): string
Converts one measurement unit into another and formats the unit based on the specified locale and style.
**System capability**: SystemCapability.Global.I18n
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ---------------------- | ---- | ---------------------------------------- |
| fromUnit | [UnitInfo](#unitinfo8) | Yes | Measurement unit to be converted. |
| toUnit | [UnitInfo](#unitinfo8) | Yes | Measurement unit to be converted to. |
| value | number | Yes | Value of the measurement unit to be converted. |
| locale | string | Yes | Locale used for formatting, for example, **zh-Hans-CN**. |
| style | string | No | Style used for formatting. The value can be **long**, **short**, or **narrow**.|
**Return value**
| Type | Description |
| ------ | ----------------------- |
| string | Character string obtained after formatting based on the measurement unit specified by **toUnit**.|
**Example**
```js
i18n.I18NUtil.unitConvert({unit: "cup", measureSystem: "US"}, {unit: "liter", measureSystem: "SI"}, 1000, "en-US", "long");
```
### getDateOrder<sup>9+</sup>
static getDateOrder(locale: string): string
Obtains the sequence of the year, month, and day in the specified locale.
**System capability**: SystemCapability.Global.I18n
**Parameters**
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | ------------------------- |
| locale | string | Yes | Locale used for formatting, for example, **zh-Hans-CN**.|
**Return value**
| Type | Description |
| ------ | ------------------- |
| string | Sequence of the year, month, and day.|
**Example**
```js
i18n.I18NUtil.getDateOrder("zh-CN");
```
...@@ -60,6 +60,7 @@ Creates a Locale object. ...@@ -60,6 +60,7 @@ 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.|
...@@ -80,6 +81,7 @@ Converts locale information to a string. ...@@ -80,6 +81,7 @@ 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.|
...@@ -100,6 +102,7 @@ Maximizes information of the **Locale** object. If the script and locale informa ...@@ -100,6 +102,7 @@ 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.|
...@@ -120,6 +123,7 @@ Minimizes information of the **Locale** object. If the script and locale informa ...@@ -120,6 +123,7 @@ 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.|
...@@ -131,7 +135,7 @@ Minimizes information of the **Locale** object. If the script and locale informa ...@@ -131,7 +135,7 @@ Minimizes information of the **Locale** object. If the script and locale informa
``` ```
## LocaleOptions ## LocaleOptions<sup>9+</sup>
Represents the locale options. Represents the locale options.
...@@ -173,6 +177,7 @@ Creates a **DateTimeOptions** object for the specified locale. ...@@ -173,6 +177,7 @@ 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&lt;string&gt; | 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.|
...@@ -199,11 +204,13 @@ Formats the specified date and time. ...@@ -199,11 +204,13 @@ 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.|
...@@ -225,12 +232,14 @@ Formats the specified date range. ...@@ -225,12 +232,14 @@ 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.|
...@@ -253,6 +262,7 @@ Obtains the formatting options for **DateTimeFormat** object. ...@@ -253,6 +262,7 @@ 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.|
...@@ -264,7 +274,7 @@ Obtains the formatting options for **DateTimeFormat** object. ...@@ -264,7 +274,7 @@ Obtains the formatting options for **DateTimeFormat** object.
``` ```
## DateTimeOptions ## DateTimeOptions<sup>9+</sup>
Provides the options for the **DateTimeFormat** object. Provides the options for the **DateTimeFormat** object.
...@@ -339,11 +349,13 @@ Formats a number. ...@@ -339,11 +349,13 @@ 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.|
...@@ -365,6 +377,7 @@ Obtains the options of the **NumberFormat** object. ...@@ -365,6 +377,7 @@ 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.|
...@@ -377,7 +390,7 @@ Obtains the options of the **NumberFormat** object. ...@@ -377,7 +390,7 @@ Obtains the options of the **NumberFormat** object.
``` ```
## NumberOptions ## NumberOptions<sup>9+</sup>
Provides the device capability. Provides the device capability.
...@@ -453,12 +466,14 @@ Compares two strings based on the sorting policy of the **Collator** object. ...@@ -453,12 +466,14 @@ 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.|
...@@ -479,6 +494,7 @@ Returns properties reflecting the locale and collation options of a **Collator** ...@@ -479,6 +494,7 @@ 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.|
...@@ -490,7 +506,7 @@ Returns properties reflecting the locale and collation options of a **Collator** ...@@ -490,7 +506,7 @@ Returns properties reflecting the locale and collation options of a **Collator**
``` ```
## CollatorOptions<sup>8+</sup><a name=collatoroptions></a> ## CollatorOptions<sup>9+</sup>
Represents the properties of a **Collator** object. Represents the properties of a **Collator** object.
...@@ -553,11 +569,13 @@ Obtains a string that represents the singular-plural type of the specified numbe ...@@ -553,11 +569,13 @@ 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**.|
...@@ -569,7 +587,7 @@ Obtains a string that represents the singular-plural type of the specified numbe ...@@ -569,7 +587,7 @@ Obtains a string that represents the singular-plural type of the specified numbe
``` ```
## PluralRulesOptions<sup>8+</sup><a name=pluralrulesoptions></a> ## PluralRulesOptions<sup>9+</sup>
Represents the properties of a **PluralRules** object. Represents the properties of a **PluralRules** object.
...@@ -611,7 +629,8 @@ Creates a **RelativeTimeFormat** object. ...@@ -611,7 +629,8 @@ 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&lt;string&gt; | 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.|
...@@ -632,12 +651,14 @@ Formats the value and unit based on the specified locale and formatting options. ...@@ -632,12 +651,14 @@ 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.|
...@@ -658,12 +679,14 @@ Returns an array of RelativeTimeFormat objects in parts for locale-aware formatt ...@@ -658,12 +679,14 @@ Returns an array of RelativeTimeFormat objects in parts for locale-aware formatt
**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&lt;object&gt; | An array of **RelativeTimeFormat** objects in parts.| | Array&lt;object&gt; | An array of **RelativeTimeFormat** objects in parts.|
...@@ -684,6 +707,7 @@ Obtains the formatting options for **RelativeTimeFormat** objects. ...@@ -684,6 +707,7 @@ 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.|
...@@ -695,7 +719,7 @@ Obtains the formatting options for **RelativeTimeFormat** objects. ...@@ -695,7 +719,7 @@ Obtains the formatting options for **RelativeTimeFormat** objects.
``` ```
## RelativeTimeFormatInputOptions<sup>8+</sup><a name=relativetimeformatinputoptions></a> ## RelativeTimeFormatInputOptions<sup>9+</sup>
Represents the properties of a **RelativeTimeFormat** object. Represents the properties of a **RelativeTimeFormat** object.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册