diff --git a/zh-cn/application-dev/reference/apis/js-apis-i18n.md b/zh-cn/application-dev/reference/apis/js-apis-i18n.md index a94ee3e1b547077d9afe05de635abf37d3802df1..9526ca700eff8b2620b1534285cc9fc65e94a337 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-i18n.md +++ b/zh-cn/application-dev/reference/apis/js-apis-i18n.md @@ -113,12 +113,17 @@ getSystemLanguage(): string ## i18n.setSystemLanguage -setSystemLanguage(): boolean +setSystemLanguage(language: string): boolean 设置系统语言。 **系统能力**:SystemCapability.Global.I18n +- 参数: + | 参数名 | 类型 | 说明 | + | -------- | -------- | -------- | + | language | string | 语言ID。 | + - 返回值: | 类型 | 说明 | | -------- | -------- | @@ -126,7 +131,7 @@ setSystemLanguage(): boolean - 示例: ``` - i18n.setSystemLanguage(); + i18n.setSystemLanguage('zh'); ``` @@ -151,12 +156,17 @@ getSystemLanguages(): Array ## i18n.getSystemCountries -getSystemCountries(): Array +getSystemCountries(language: string): Array -获取系统支持的区域列表。 +获取针对输入语言系统支持的区域列表。 **系统能力**:SystemCapability.Global.I18n +- 参数: + | 参数名 | 类型 | 说明 | + | -------- | -------- | -------- | + | language | string | 语言ID。 | + - 返回值: | 类型 | 说明 | | -------- | -------- | @@ -164,7 +174,7 @@ getSystemCountries(): Array - 示例: ``` - i18n.getSystemCountries(); + i18n.getSystemCountries('zh'); ``` @@ -189,12 +199,17 @@ getSystemRegion(): string ## i18n.setSystemRegion -setSystemRegion(): boolean +setSystemRegion(region: string): boolean 设置系统区域。 **系统能力**:SystemCapability.Global.I18n +- 参数: + | 参数名 | 类型 | 说明 | + | -------- | -------- | -------- | + | region | string | 地区ID。 | + - 返回值: | 类型 | 说明 | | -------- | -------- | @@ -645,21 +660,23 @@ format(number: string): string 表示电话号码格式化对象可设置的属性。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.Global.I18n | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | -| type | string | 是 | 是 | 表示对电话号码格式化的类型,取值范围:"E164", "INTERNATIONAL", "NATIONAL", "RFC3966"。
**系统能力**:SystemCapability.Global.I18n | +| type | string | 是 | 是 | 表示对电话号码格式化的类型,取值范围:"E164", "INTERNATIONAL", "NATIONAL", "RFC3966"。 | ## UnitInfo8+ 度量衡单位信息。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.Global.I18n | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | | unit | string | 是 | 是 | 单位的名称,如:"meter", "inch", "cup"等。 | -| measureSystem | string | 是 | 是 | 单位的度量体系,取值包括:"SI", "US", "UK"。
**系统能力**:SystemCapability.Global.I18n | +| measureSystem | string | 是 | 是 | 单位的度量体系,取值包括:"SI", "US", "UK"。 | ## Util8+ @@ -695,7 +712,7 @@ unitConvert(fromUnit: UnitInfo, toUnit: UnitInfo, value: number, locale: string, ## getInstance8+ -getInstance(): IndexUtil +getInstance(locale?:string): IndexUtil 创建并返回IndexUtil对象。 @@ -742,7 +759,7 @@ getIndexList(): Array<string> ### addLocale8+ -addLocale(locale: string) +addLocale(locale: string): void 将新的locale对应的索引加入当前索引列表。 @@ -1374,4 +1391,117 @@ getFirstPreferredLanguage(): string - 示例: ``` var firstPreferredLanguage = i18n.getFirstPreferredLanguage(); + ``` + + +## i18n.getTimeZone8+ + +getTimeZone(zoneID?: string): TimeZone + +获取时区ID对应的时区对象。 + +**系统能力**:SystemCapability.Global.I18n + +- 参数: + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | zondID | string | 否 | 时区ID。 | + +- 返回值: + | 类型 | 说明 | + | -------- | -------- | + | TimeZone | 时区ID对应的时区对象。 | + +- 示例: + ``` + var timezone = i18n.getTimeZone(); + ``` + + +## RelativeTimeFormat8+ + + +### getID8+ + +getID(): string + +获取时区对象的ID。 + +**系统能力**:SystemCapability.Global.I18n + +- 返回值: + | 类型 | 说明 | + | -------- | -------- | + | string | 时区对象对应的时区ID。 | + +- 示例: + ``` + var timezone = i18n.getTimeZone(); + timezone.getID(); + ``` + + +### getDisplayName8+ + +getDisplayName(locale?: string, isDST?: boolean): string + +获取时区对象在指定区域的表示。 + +**系统能力**:SystemCapability.Global.I18n + +- 参数: + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | locale | string | 否 | 区域ID。 | + | isDST | boolean | 否 | 表示获取时区对象的表示时是否考虑夏令时。 | + +- 返回值: + | 类型 | 说明 | + | -------- | -------- | + | string | 时区对象在指定区域的表示。 | + +- 示例: + ``` + var timezone = i18n.getTimeZone(); + timezone.getDisplayName("zh-CN", false); + ``` + + +### getRawOffset8+ + +getRawOffset(): number + +获取时区对象表示的时区与UTC时区的偏差。 + +**系统能力**:SystemCapability.Global.I18n + +- 返回值: + | 类型 | 说明 | + | -------- | -------- | + | number | 时区对象表示的时区与UTC时区的偏差。 | + +- 示例: + ``` + var timezone = i18n.getTimeZone(); + timezone.getRawOffset(); + ``` + + +### getOffset8+ + +getOffset(date?: number): number + +获取某一时刻时区对象表示的时区与UTC时区的偏差。 + +**系统能力**:SystemCapability.Global.I18n + +- 返回值: + | 类型 | 说明 | + | -------- | -------- | + | number | 某一时刻时区对象表示的时区与UTC时区的偏差。 | + +- 示例: + ``` + var timezone = i18n.getTimeZone(); + timezone.getOffset(1234567890); ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-intl.md b/zh-cn/application-dev/reference/apis/js-apis-intl.md index 9d847a9f13111ef1b14e128f185eb1519f268831..811318e13a89e9503d27eec24cababc55f67d5ad 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-intl.md +++ b/zh-cn/application-dev/reference/apis/js-apis-intl.md @@ -18,21 +18,23 @@ import Intl from '@ohos.intl'; ### 属性 +**系统能力**:以下各项对应的系统能力均为SystemCapability.Global.I18n + | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | -| language | string | 是 | 否 | 与区域设置关联的语, 如:zh。
**系统能力**:SystemCapability.Global.I18n | -| script | string | 是 | 否 | 语言的书写方式,如:Hans。
**系统能力**:SystemCapability.Global.I18n | -| region | string | 是 | 否 | 与区域设置相关的地区,如:CN。
**系统能力**:SystemCapability.Global.I18n | -| baseName | string | 是 | 否 | Locale的基本核心信息(由语言脚本与地区组成),如:zh-Hans-CN。
**系统能力**:SystemCapability.Global.I18n | -| caseFirst | string | 是 | 否 | 区域的整理规则是否考虑大小写,取值包括:"upper", "lower", "false"。
**系统能力**:SystemCapability.Global.I18n | -| calendar | string | 是 | 否 | 区域的日历信息,取值包括:"buddhist", "chinese", "coptic","dangi", "ethioaa", "ethiopic", "gregory", "hebrew", "indian", "islamic", "islamic-umalqura", "islamic-tbla", "islamic-civil", "islamic-rgsa", "iso8601", "japanese", "persian", "roc", "islamicc"。
**系统能力**:SystemCapability.Global.I18n | -| collation | string | 是 | 否 | 区域的排序规则,取值包括:"big5han", "compat", "dict", "direct", "ducet", "eor", "gb2312", "phonebk", "phonetic", "pinyin", "reformed", "searchjl", "stroke", "trad", "unihan", "zhuyin"。
**系统能力**:SystemCapability.Global.I18n | -| hourCycle | string | 是 | 否 | 区域的时制信息,取值包括:"h12", "h23", "h11", "h24"。
**系统能力**:SystemCapability.Global.I18n | -| numberingSystem | string | 是 | 否 | 区域使用的数字系统,取值包括:"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"。
**系统能力**:SystemCapability.Global.I18n | -| numeric | boolean | 是 | 否 | 是否对数字字符具有特殊的排序规则处理。
**系统能力**:SystemCapability.Global.I18n | +| language | string | 是 | 否 | 与区域设置关联的语, 如:zh。 | +| script | string | 是 | 否 | 语言的书写方式,如:Hans。 | +| region | string | 是 | 否 | 与区域设置相关的地区,如:CN。 | +| baseName | string | 是 | 否 | Locale的基本核心信息(由语言脚本与地区组成),如:zh-Hans-CN。 | +| caseFirst | string | 是 | 否 | 区域的整理规则是否考虑大小写,取值包括:"upper", "lower", "false"。 | +| calendar | string | 是 | 否 | 区域的日历信息,取值包括:"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 | 是 | 否 | 区域的排序规则,取值包括:"big5han", "compat", "dict", "direct", "ducet", "eor", "gb2312", "phonebk", "phonetic", "pinyin", "reformed", "searchjl", "stroke", "trad", "unihan", "zhuyin"。 | +| hourCycle | string | 是 | 否 | 区域的时制信息,取值包括:"h12", "h23", "h11", "h24"。 | +| numberingSystem | string | 是 | 否 | 区域使用的数字系统,取值包括:"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 | 是 | 否 | 是否对数字字符具有特殊的排序规则处理。 | -### constructor +### constructor8+ constructor() @@ -48,7 +50,7 @@ constructor() ### constructor -constructor(locale: string, options?: options) +constructor(locale: string, options?: LocaleOptions) 创建区域对象 @@ -58,7 +60,7 @@ constructor(locale: string, options?: options) | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | locale | string | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | - | options | options | 否 | 用于创建区域对象的选项。 | + | options | LocaleOptions | 否 | 用于创建区域对象的选项。 | - 示例: ``` @@ -126,10 +128,26 @@ minimize(): Locale ``` +## LocaleOptions + +表示区域初始化选项。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.Global.I18n + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| -------- | -------- | -------- | -------- | -------- | +| calendar | string | 是 | 是 | 日历参数,如:"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 | 是 | 是 | 排序参数,取值包括:"big5han", "compat", "dict", "direct", "ducet", "emoji", "eor", "gb2312", "phonebk", "phonetic", "pinyin", "reformed ", "search", "searchjl", "standard", "stroke", "trad", "unihan", "zhuyin"。 | +| hourCycle | string | 是 | 是 | 时制格式,取值包括:"h11", "h12", "h23", "h24"。 | +| numberingSystem | string | 是 | 是 | 数字系统,取值包括:"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 | 是 | 是 | 是否使用12小时制。 | +| caseFirst | string | 是 | 是 | 表示大写、小写的排序顺序,取值范围:"upper", "lower", "false"。 | + + ## DateTimeFormat -### constructor +### constructor8+ constructor() @@ -145,7 +163,7 @@ constructor() ### constructor -constructor(locale: string, options?: DateTimeOptions) +constructor(locale: string | Array, options?: DateTimeOptions) 创建时间日期格式化对象。 @@ -154,7 +172,7 @@ constructor(locale: string, options?: DateTimeOptions) - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | locale | string | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | + | locale | string \| Array | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | | options | [DateTimeOptions](#datetimeoptions) | 否 | 用于创建时间日期格式化的选项。 | - 示例: @@ -163,20 +181,6 @@ constructor(locale: string, options?: DateTimeOptions) ``` -### constructor - -constructor(locales: Array<string>, options?: DateTimeOptions) - -创建时间日期格式化对象。 - -**系统能力**:SystemCapability.Global.I18n - -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | locales | Array<string> | 是 | 包含区域设置信息的字符串的数组。 | - | options | [DateTimeOptions](#datetimeoptions) | 否 | 用于创建时间日期格式化的选项。 | - - 示例: ``` var datefmt= new Intl.DateTimeFormat(["ban", "zh"], { dateStyle: 'full', timeStyle: 'medium' }); @@ -211,7 +215,7 @@ format(date: Date): string ### formatRange -formatRange(fromDate: Date, toDate: Date): string +formatRange(startDate: Date, endDate: Date): string 格式化时间日期段字符串。 @@ -261,33 +265,35 @@ resolvedOptions(): DateTimeOptions 表示时间日期格式化选项。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.Global.I18n + | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | -| locale | string | 是 | 否 | 区域参数, 如:zh-Hans-CN。
**系统能力**:SystemCapability.Global.I18n | -| dateStyle | string | 是 | 是 | 日期显示格式,取值包括:"long", "short", "medium", "full"。
**系统能力**:SystemCapability.Global.I18n | -| timeStyle | string | 是 | 是 | 时间显示格式,取值包括:"long", "short", "medium", "full"。
**系统能力**:SystemCapability.Global.I18n | -| hourCycle | string | 是 | 是 | 时制格式,取值包括:"h11", "h12", "h23", "h24"。
**系统能力**:SystemCapability.Global.I18n | -| timeZone | string | 是 | 是 | 使用的时区(合法的IANA时区ID)。
**系统能力**:SystemCapability.Global.I18n | -| numberingSystem | string | 是 | 是 | 数字系统,取值包括:"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"。
**系统能力**:SystemCapability.Global.I18n | -| hour12 | boolean | 是 | 是 | 是否使用12小时制。
**系统能力**:SystemCapability.Global.I18n | -| weekday | string | 是 | 是 | 工作日的显示格式,取值包括:"long", "short", "narrow"。
**系统能力**:SystemCapability.Global.I18n | -| era | string | 是 | 是 | 时代的显示格式,取值包括:"long", "short", "narrow"。
**系统能力**:SystemCapability.Global.I18n | -| year | string | 是 | 是 | 年份的显示格式,取值包括:"numeric", "2-digit"。
**系统能力**:SystemCapability.Global.I18n | -| month | string | 是 | 是 | 月份的显示格式,取值包括:"numeric", "2-digit", "long", "short", "narrow"。
**系统能力**:SystemCapability.Global.I18n | -| day | string | 是 | 是 | 日期的显示格式,取值包括:"numeric", "2-digit"。
**系统能力**:SystemCapability.Global.I18n | -| hour | string | 是 | 是 | 小时的显示格式,取值包括:"numeric", "2-digit"。
**系统能力**:SystemCapability.Global.I18n | -| minute | string | 是 | 是 | 分钟的显示格式,取值包括:"numeric", "2-digit"。
**系统能力**:SystemCapability.Global.I18n | -| second | string | 是 | 是 | 秒钟的显示格式,取值包括:"numeric", "2-digit"。
**系统能力**:SystemCapability.Global.I18n | -| timeZoneName | string | 是 | 是 | 时区名称的本地化表示。
**系统能力**:SystemCapability.Global.I18n | -| dayPeriod | string | 是 | 是 | 时段的显示格式,取值包括:"long", "short", "narrow"。
**系统能力**:SystemCapability.Global.I18n | -| localeMatcher | string | 是 | 是 | 要使用的区域匹配算法,取值包括:"lookup", "best fit"。
**系统能力**:SystemCapability.Global.I18n | -| formatMatcher | string | 是 | 是 | 要使用的格式匹配算法,取值包括:"basic", "best fit"。
**系统能力**:SystemCapability.Global.I18n | +| locale | string | 是 | 否 | 区域参数, 如:zh-Hans-CN。 | +| dateStyle | string | 是 | 是 | 日期显示格式,取值包括:"long", "short", "medium", "full"。 | +| timeStyle | string | 是 | 是 | 时间显示格式,取值包括:"long", "short", "medium", "full"。 | +| hourCycle | string | 是 | 是 | 时制格式,取值包括:"h11", "h12", "h23", "h24"。 | +| timeZone | string | 是 | 是 | 使用的时区(合法的IANA时区ID)。 | +| numberingSystem | string | 是 | 是 | 数字系统,取值包括:"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 | 是 | 是 | 是否使用12小时制。 | +| weekday | string | 是 | 是 | 工作日的显示格式,取值包括:"long", "short", "narrow"。 | +| era | string | 是 | 是 | 时代的显示格式,取值包括:"long", "short", "narrow"。 | +| year | string | 是 | 是 | 年份的显示格式,取值包括:"numeric", "2-digit"。 | +| month | string | 是 | 是 | 月份的显示格式,取值包括:"numeric", "2-digit", "long", "short", "narrow"。 | +| day | string | 是 | 是 | 日期的显示格式,取值包括:"numeric", "2-digit"。 | +| hour | string | 是 | 是 | 小时的显示格式,取值包括:"numeric", "2-digit"。 | +| minute | string | 是 | 是 | 分钟的显示格式,取值包括:"numeric", "2-digit"。 | +| second | string | 是 | 是 | 秒钟的显示格式,取值包括:"numeric", "2-digit"。 | +| timeZoneName | string | 是 | 是 | 时区名称的本地化表示。 | +| dayPeriod | string | 是 | 是 | 时段的显示格式,取值包括:"long", "short", "narrow"。 | +| localeMatcher | string | 是 | 是 | 要使用的区域匹配算法,取值包括:"lookup", "best fit"。 | +| formatMatcher | string | 是 | 是 | 要使用的格式匹配算法,取值包括:"basic", "best fit"。 | ## NumberFormat -### constructor +### constructor8+ constructor() @@ -303,7 +309,7 @@ constructor() ### constructor -constructor(locale: string, options?: NumberOptions) +constructor(locale: string | Array, options?: NumberOptions) 创建数字格式化对象。 @@ -312,7 +318,7 @@ constructor(locale: string, options?: NumberOptions) 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| locale | string | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | +| locale | string \| Array | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | | options | [NumberOptions](#numberoptions) | 否 | 用于创建数字格式化的选项。 | - 示例: @@ -321,26 +327,6 @@ constructor(locale: string, options?: NumberOptions) ``` -### constructor - -constructor(locales: Array<string>, options?: NumberOptions) - -创建数字格式化对象。 - -**系统能力**:SystemCapability.Global.I18n - -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | locales | Array<string> | 是 | 包含区域设置信息的字符串的数组。 | - | options | [NumberOptions](#numberoptions) | 否 | 用于创建数字格式化的选项。 | - -- 示例: - ``` - var numfmt = new Intl.NumberFormat(["en-GB", "zh"], {style:'decimal', notation:"scientific"}); - ``` - - ### format format(number: number): string; @@ -392,27 +378,29 @@ resolvedOptions(): NumberOptions 表示设备支持的能力。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.Global.I18n + | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | -| locale | string | 是 | 否 | 区域参数, 如:"zh-Hans-CN"。
**系统能力**:SystemCapability.Global.I18n | -| currency | string | 是 | 是 | 货币单位, 如:"EUR","CNY","USD"等。
**系统能力**:SystemCapability.Global.I18n | -| currencySign | string | 是 | 是 | 货币单位的符号显示,取值包括: "symbol","narrowSymbol","code","name" 。
**系统能力**:SystemCapability.Global.I18n | -| currencyDisplay | string | 是 | 是 | 货币的显示方式,取值包括:"symbol", "narrowSymbol", "code", "name"。
**系统能力**:SystemCapability.Global.I18n | -| unit | string | 是 | 是 | 单位名称,如:"meter","inch",“hectare”等。
**系统能力**:SystemCapability.Global.I18n | -| unitDisplay | string | 是 | 是 | 单位的显示格式,取值包括:"long", "short", "medium"。
**系统能力**:SystemCapability.Global.I18n | -| unitUsage | string | 是 | 是 | 单位的使用场景,取值包括:"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"。
**系统能力**:SystemCapability.Global.I18n | -| signDisplay | string | 是 | 是 | 数字符号的显示格式,取值包括:"auto", "never", "always", "expectZero"。
**系统能力**:SystemCapability.Global.I18n | -| compactDisplay | string | 是 | 是 | 紧凑型的显示格式,取值包括:"long", "short"。
**系统能力**:SystemCapability.Global.I18n | -| notation | string | 是 | 是 | 数字的格式化规格,取值包括:"standard", "scientific", "engineering", "compact"。
**系统能力**:SystemCapability.Global.I18n | -| localeMatcher | string | 是 | 是 | 要使用的区域匹配算法,取值包括:"lookup", "best fit"。
**系统能力**:SystemCapability.Global.I18n | -| style | string | 是 | 是 | 数字的显示格式,取值包括:"decimal", "currency", "percent", "unit"。
**系统能力**:SystemCapability.Global.I18n | -| numberingSystem | string | 是 | 是 | 数字系统,取值包括:"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"。
**系统能力**:SystemCapability.Global.I18n | -| useGrouping | boolean | 是 | 是 | 是否分组显示。
**系统能力**:SystemCapability.Global.I18n | -| miniumumIntegerDigits | number | 是 | 是 | 表示要使用的最小整数位数,取值范围:1~21。
**系统能力**:SystemCapability.Global.I18n | -| miniumumFractionDigits | number | 是 | 是 | 表示要使用的最小分数位数,取值范围:0~20。
**系统能力**:SystemCapability.Global.I18n | -| maxiumumFractionDigits | number | 是 | 是 | 表示要使用的最大分数位数,取值范围:1~21。
**系统能力**:SystemCapability.Global.I18n | -| miniumumSignificantDigits | number | 是 | 是 | 表示要使用的最低有效位数,取值范围:1~21。
**系统能力**:SystemCapability.Global.I18n | -| maxiumumSignificantDigits | number | 是 | 是 | 表示要使用的最大有效位数,取值范围:1~21。
**系统能力**:SystemCapability.Global.I18n | +| locale | string | 是 | 否 | 区域参数, 如:"zh-Hans-CN"。 | +| currency | string | 是 | 是 | 货币单位, 如:"EUR","CNY","USD"等。 | +| currencySign | string | 是 | 是 | 货币单位的符号显示,取值包括: "symbol","narrowSymbol","code","name" 。 | +| currencyDisplay | string | 是 | 是 | 货币的显示方式,取值包括:"symbol", "narrowSymbol", "code", "name"。 | +| unit | string | 是 | 是 | 单位名称,如:"meter","inch",“hectare”等。 | +| unitDisplay | string | 是 | 是 | 单位的显示格式,取值包括:"long", "short", "medium"。 | +| unitUsage | string | 是 | 是 | 单位的使用场景,取值包括:"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 | 是 | 是 | 数字符号的显示格式,取值包括:"auto", "never", "always", "expectZero"。 | +| compactDisplay | string | 是 | 是 | 紧凑型的显示格式,取值包括:"long", "short"。 | +| notation | string | 是 | 是 | 数字的格式化规格,取值包括:"standard", "scientific", "engineering", "compact"。 | +| localeMatcher | string | 是 | 是 | 要使用的区域匹配算法,取值包括:"lookup", "best fit"。 | +| style | string | 是 | 是 | 数字的显示格式,取值包括:"decimal", "currency", "percent", "unit"。 | +| numberingSystem | string | 是 | 是 | 数字系统,取值包括:"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 | 是 | 是 | 是否分组显示。 | +| minimumIntegerDigits | number | 是 | 是 | 表示要使用的最小整数位数,取值范围:1~21。 | +| minimumFractionDigits | number | 是 | 是 | 表示要使用的最小分数位数,取值范围:0~20。 | +| maximumFractionDigits | number | 是 | 是 | 表示要使用的最大分数位数,取值范围:1~21。 | +| minimumSignificantDigits | number | 是 | 是 | 表示要使用的最低有效位数,取值范围:1~21。 | +| maximumSignificantDigits | number | 是 | 是 | 表示要使用的最大有效位数,取值范围:1~21。 | ## Collator8+ @@ -434,7 +422,7 @@ constructor() ### constructor8+ -constructor(locale: string | Array<string>, options?: CollatorOptions) +constructor(locale: string | Array, options?: CollatorOptions) 创建排序对象。 @@ -444,12 +432,12 @@ constructor(locale: string | Array<string>, options?: CollatorOptions) | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | locale | string\|Array<string> | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | + | locale | string \| Array | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | | options | [CollatorOptions](#collatoroptions) | 否 | 用于创建排序对象的选项。 | - 示例: ``` - var collator = new Intl.Collator("zh-CN", {"localeMatcher": "lookup", "usage": "sort"}); + var collator = new Intl.Collator("zh-CN", {localeMatcher: "lookup", usage: "sort"}); ``` @@ -503,15 +491,17 @@ resolvedOptions(): CollatorOptions 表示Collator可设置的属性。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.Global.I18n + | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | -| localeMatcher | string | 是 | 是 | locale匹配算法,取值范围:"best fit", "lookup"。
**系统能力**:SystemCapability.Global.I18n | -| usage | string | 是 | 是 | 比较的用途,取值范围:"sort", "search"。
**系统能力**:SystemCapability.Global.I18n | -| sensitivity | string | 是 | 是 | 表示字符串中的哪些差异会导致非零结果值,取值范围:"base", "accent", "case", "variant"。
**系统能力**:SystemCapability.Global.I18n | -| ignorePunctuation | boolean | 是 | 是 | 表示是否忽略标点符号,取值范围:true, false。
**系统能力**:SystemCapability.Global.I18n | -| collation | string | 是 | 是 | 排序规则,取值范围:"big5han", "compat", "dict", "direct", "ducet", "eor", "gb2312", "phonebk", "phonetic", "pinyin", "reformed", "searchjl", "stroke", "trad", "unihan", "zhuyin"。
**系统能力**:SystemCapability.Global.I18n | -| numeric | boolean | 是 | 是 | 是否使用数字排序,取值范围:true, false。
**系统能力**:SystemCapability.Global.I18n | -| caseFirst | string | 是 | 是 | 表示大写、小写的排序顺序,取值范围:"upper", "lower", "false"。
**系统能力**:SystemCapability.Global.I18n | +| localeMatcher | string | 是 | 是 | locale匹配算法,取值范围:"best fit", "lookup"。 | +| usage | string | 是 | 是 | 比较的用途,取值范围:"sort", "search"。 | +| sensitivity | string | 是 | 是 | 表示字符串中的哪些差异会导致非零结果值,取值范围:"base", "accent", "case", "variant"。 | +| ignorePunctuation | boolean | 是 | 是 | 表示是否忽略标点符号,取值范围:true, false。 | +| collation | string | 是 | 是 | 排序规则,取值范围:"big5han", "compat", "dict", "direct", "ducet", "eor", "gb2312", "phonebk", "phonetic", "pinyin", "reformed", "searchjl", "stroke", "trad", "unihan", "zhuyin"。 | +| numeric | boolean | 是 | 是 | 是否使用数字排序,取值范围:true, false。 | +| caseFirst | string | 是 | 是 | 表示大写、小写的排序顺序,取值范围:"upper", "lower", "false"。 | ## PluralRules8+ @@ -533,7 +523,7 @@ constructor() ### constructor8+ -constructor(locale: string | Array<string>, options?: PluralRulesOptions) +constructor(locale: string | Array, options?: PluralRulesOptions) 创建PluralRules对象。 @@ -542,7 +532,7 @@ constructor(locale: string | Array<string>, options?: PluralRulesOptions) 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| locale | string\|Array<string> | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | +| locale | string \| Array | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | | options | [PluralRulesOptions](#pluralrulesoptions) | 否 | 用于创建单复数对象的选项。 | - 示例: @@ -580,15 +570,17 @@ select(n: number): string 表示PluralRules对象可设置的属性。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.Global.I18n + | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | -| localeMatcher | string | 是 | 是 | locale匹配算法,取值包括:"best fit", "lookup"。
**系统能力**:SystemCapability.Global.I18n | -| type | string | 是 | 是 | 排序的类型,取值包括:"cardinal", "ordinal"。
**系统能力**:SystemCapability.Global.I18n | -| minimumIntegerDigits | number | 是 | 是 | 表示要使用的最小整数位数,取值范围:1~21。
**系统能力**:SystemCapability.Global.I18n | -| minimumFractionDigits | number | 是 | 是 | 表示要使用的最小分数位数,取值范围:0~20。
**系统能力**:SystemCapability.Global.I18n | -| maximumFractionDigits | number | 是 | 是 | 表示要使用的最大分数位数,取值范围:1~21。
**系统能力**:SystemCapability.Global.I18n | -| minimumSignificantDigits | number | 是 | 是 | 表示要使用的最低有效位数,取值范围:1~21。
**系统能力**:SystemCapability.Global.I18n | -| maximumSignificantDigits | number | 是 | 是 | 表示要使用的最大有效位数,取值范围:1~21。
**系统能力**:SystemCapability.Global.I18n | +| localeMatcher | string | 是 | 是 | locale匹配算法,取值包括:"best fit", "lookup"。 | +| type | string | 是 | 是 | 排序的类型,取值包括:"cardinal", "ordinal"。 | +| minimumIntegerDigits | number | 是 | 是 | 表示要使用的最小整数位数,取值范围:1~21。 | +| minimumFractionDigits | number | 是 | 是 | 表示要使用的最小分数位数,取值范围:0~20。 | +| maximumFractionDigits | number | 是 | 是 | 表示要使用的最大分数位数,取值范围:1~21。 | +| minimumSignificantDigits | number | 是 | 是 | 表示要使用的最低有效位数,取值范围:1~21。 | +| maximumSignificantDigits | number | 是 | 是 | 表示要使用的最大有效位数,取值范围:1~21。 | ## RelativeTimeFormat8+ @@ -610,7 +602,7 @@ constructor() ### constructor8+ -constructor(locale: string | Array<string>, options?: RelativeTimeFormatInputOptions) +constructor(locale: string | Array, options?: RelativeTimeFormatInputOptions) 创建相对时间格式化对象。 @@ -619,7 +611,7 @@ constructor(locale: string | Array<string>, options?: RelativeTimeFormatIn 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| locale | string\|Array<string> | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | +| locale | string \| Array | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | | options | [RelativeTimeFormatInputOptions](#relativetimeformatinputoptions) | 否 | 用于创建相对时间格式化对象的选项。 | - 示例: @@ -630,7 +622,7 @@ constructor(locale: string | Array<string>, options?: RelativeTimeFormatIn ### format8+ -format(value: numeric, unit: string): string +format(value: number, unit: string): string 依据locale和格式化选项,对value和unit进行格式化。 @@ -639,7 +631,7 @@ format(value: numeric, unit: string): string - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | value | numeric | 是 | 相对时间格式化的数值。 | + | value | number | 是 | 相对时间格式化的数值。 | | unit | string | 是 | 相对时间格式化的单位,取值包括:"year", "quarter", "month", "week", "day", "hour", "minute", "second"。 | - 返回值: @@ -656,7 +648,7 @@ format(value: numeric, unit: string): string ### formatToParts8+ -formatToParts(value: numeric, unit: string): Array<Object> +formatToParts(value: number, unit: string): Array 返回一个对象数组,表示可用于自定义区域设置格式的相对时间格式。 @@ -665,13 +657,13 @@ formatToParts(value: numeric, unit: string): Array<Object> - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | - | value | numeric | 是 | 相对时间格式化的数值。 | + | value | number | 是 | 相对时间格式化的数值。 | | unit | string | 是 | 相对时间格式化的单位,取值包括:"year", "quarter", "month", "week", "day", "hour", "minute", "second"。 | - 返回值: | 类型 | 说明 | | -------- | -------- | - | Array<Object> | 返回可用于自定义区域设置格式的相对时间格式的对象数组。 | + | Array | 返回可用于自定义区域设置格式的相对时间格式的对象数组。 | - 示例: ``` @@ -704,20 +696,24 @@ resolvedOptions(): RelativeTimeFormatResolvedOptions 表示RelativeTimeFormat对象可设置的属性。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.Global.I18n + | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | -| localeMatcher | string | 是 | 是 | locale匹配算法,取值包括:"best fit", "lookup"。
**系统能力**:SystemCapability.Global.I18n | -| numeric | string | 是 | 是 | 输出消息的格式,取值包括:"always", "auto"。
**系统能力**:SystemCapability.Global.I18n | -| style | string | 是 | 是 | 国际化消息的长度,取值包括:"long", "short", "narrow"。
**系统能力**:SystemCapability.Global.I18n | +| localeMatcher | string | 是 | 是 | locale匹配算法,取值包括:"best fit", "lookup"。 | +| numeric | string | 是 | 是 | 输出消息的格式,取值包括:"always", "auto"。 | +| style | string | 是 | 是 | 国际化消息的长度,取值包括:"long", "short", "narrow"。 | ## RelativeTimeFormatResolvedOptions8+ 表示RelativeTimeFormat对象可设置的属性。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.Global.I18n + | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | -| locale | string | 是 | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。
**系统能力**:SystemCapability.Global.I18n | -| numeric | string | 是 | 是 | 输出消息的格式,取值包括:"always", "auto"。
**系统能力**:SystemCapability.Global.I18n | -| style | string | 是 | 是 | 国际化消息的长度,取值包括:"long", "short", "narrow"。
**系统能力**:SystemCapability.Global.I18n | -| numberingSystem | string | 是 | 是 | 使用的数字系统。
**系统能力**:SystemCapability.Global.I18n | +| locale | string | 是 | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | +| numeric | string | 是 | 是 | 输出消息的格式,取值包括:"always", "auto"。 | +| style | string | 是 | 是 | 国际化消息的长度,取值包括:"long", "short", "narrow"。 | +| numberingSystem | string | 是 | 是 | 使用的数字系统。 |