diff --git a/api/@ohos.i18n.d.ts b/api/@ohos.i18n.d.ts index 3001b54bd872b1acad1bd2aa1e3103b793207dc4..d783a5f1f7b064878942f323d1139a247e2319b9 100644 --- a/api/@ohos.i18n.d.ts +++ b/api/@ohos.i18n.d.ts @@ -166,6 +166,15 @@ export class PhoneNumberFormat { format(number: string): string; } +/** + * check whether the locale is an RTL locale. + * + * @param locale Indicates the locale to use. + * @return Returns true if the locale is an RTL locale and vice versa. + * @since 8 + */ +export function isRTL(locale: string): boolean; + /** * Get a Calendar instance specified by locale and type. * @@ -175,7 +184,7 @@ export class PhoneNumberFormat { * japanese, persion. * @since 8 */ - export function getCalendar(locale: string, type?: string): Calendar; +export function getCalendar(locale: string, type?: string): Calendar; export class Calendar { /** diff --git a/api/@ohos.intl.d.ts b/api/@ohos.intl.d.ts index 8755ac68148c7ea08999786029045b19224c6fc9..fbd004e586ebd214afe585758ddac0070e152c3b 100755 --- a/api/@ohos.intl.d.ts +++ b/api/@ohos.intl.d.ts @@ -406,5 +406,194 @@ export class NumberFormat { */ resolvedOptions(): NumberOptions; } + +/** + * Provides the options of Collator + */ +export interface CollatorOptions { + /** + * The locale matching algorithm to use. + * Possible values are "lookup" and "best fit"; the default is "best fit". + */ + localeMatcher: string; + + /** + * Whether the comparison is for sorting or for searching for matching strings. + * Possible values are "sort" and "search"; the default is "sort". + */ + usage: string; + + /** + * Which differences in the strings should lead to non-zero result values. + * Possible values are "base", "accent", "case", "variant". + */ + sensitivity: string; + + /** + * Whether punctuation should be ignored. + * Possible values are true and false; the default is false. + */ + ignorePunctuation: boolean; + + /** + * Variant collations for certain locales. + */ + collation: string; + + /** + * Whether numeric collation should be used. + * Possible values are true and false; the default is false. + */ + numeric: boolean; + + /** + * Whether upper case or lower case should sort first. + * Possible values are "upper", "lower", or "false" (use the locale's default). + */ + caseFirst: string; +} + +/** + * Provides the API for collation. + */ +export class Collator { + /** + * A constructor used to create Collator object. + * + * @since 8 + */ + constructor(); + + /** + * A constructor used to create Collator Object; + * + * @param locale Indicates a character string containing the locale information, including + * the language and optionally the script and region, for the Collator object. + * @param options Indicates the options used to initialize Collator object. + * @since 8 + */ + constructor(locale: string, options?: CollatorOptions); + + /** + * A constructor used to create Collator Object; + * + * @param locale Indicates a character string Array containing the locales information, including + * the language and optionally the script and region, for the Collator object. + * @param option Indicates the options used to initialize Collator object. + * @since 8 + */ + constructor(locale: Array, option?: CollatorOptions); + + /** + * compares two strings according to the sort order of this Collator object + * + * @param first The first string to compare. + * @param second The second string to compare. + * @return Returns a number indicating how first compare to second: + * a negative value if string1 comes before string2; + * a positive value if string1 comes after string2; + * 0 if they are considered equal. + * @since 8 + */ + compare(first: string, second: string): number; + + /** + * Returns a new object with properties reflecting the locale and collation options computed + * during initialization of the object. + * + * @return Returns a CollatorOptions object reflecting the properties of this object. + * @since 8 + */ + resolvedOptions(): CollatorOptions; +} + +/** + * Provides the options of PluralRules + */ +export interface PluralRulesOptions { + /** + * The locale matching algorithm to use. + * Possible values are "lookup" and "best fit"; the default is "best fit". + */ + localeMatcher: string; + + /** + * The type to use. Possible values are: "cardinal", "ordinal" + */ + type: string; + + /** + * The minimum number of integer digits to use. + * Possible values are from 1 to 21; the default is 1. + */ + minimumIntegerDigits: number; + + /** + * The minimum number of fraction digits to use. + * Possible values are from 0 to 20; the default for plain number and percent formatting is 0; + */ + minimumFractionDigits: number; + + /** + * The maximum number of fraction digits to use. + * Possible values are from 0 to 20; + * the default for plain number formatting is the larger of minimumFractionDigits and 3; + */ + maximumFractionDigits: number; + + /** + * The minimum number of significant digits to use. + * Possible values are from 1 to 21; the default is 1. + */ + minimumSignificantDigits: number; + + /** + * The maximum number of significant digits to use. + * Possible values are from 1 to 21; the default is 21. + */ + maximumSignificantDigits: number; +} + +/** + * Provides the API for PluralRules. + */ +export class PluralRules { + /** + * A constructor used to create PluralRules object. + * + * @since 8 + */ + constructor(); + + /** + * A constructor used to create PluralRules object. + * + * @param locale Indicates a character string containing the locale information, including + * the language and optionally the script and region, for the PluralRules object. + * @param options Indicates the options used to initialize PluralRules object. + * @since 8 + */ + constructor(locale: string, options?: PluralRulesOptions); + + /** + * A constructor used to create PluralRules object. + * + * @param locale Indicates character strings containing the locales information, including + * the language and optionally the script and region, for the PluralRules object. + * @param options Indicates the options used to initialize PluralRules object. + * @since 8 + */ + constructor(locale: Array, options?: PluralRulesOptions); + + /** + * Returns a string indicating which plural rule to use for locale-aware formatting. + * + * @param number The number to get a plural rule for. + * @return A string representing the pluralization category of the number, + * can be one of zero, one, two, few, many or other. + * @since 8 + */ + select(number: number): string; +} } export default intl; \ No newline at end of file