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