diff --git a/api/@ohos.i18n.d.ts b/api/@ohos.i18n.d.ts index 53ebb62f927b3cd9045f7c23b8bb0bdf1e157ee2..7de84c3ce6f70809d26306761d5668d93f15c9eb 100644 --- a/api/@ohos.i18n.d.ts +++ b/api/@ohos.i18n.d.ts @@ -17,7 +17,7 @@ * Provides international settings related APIs. * * @since 7 - * @devices phone, table, tv, wearable, car + * @devices phone, tablet, tv, wearable, car */ declare namespace i18n { /** @@ -43,7 +43,7 @@ export function getDisplayCountry(country: string, locale: string, sentenceCase? export function getDisplayLanguage(language: string, locale: string, sentenceCase?: boolean): string; /** - * Obtain all regions supported by the system. + * Obtain all languages supported by the system. * * @return Returns all languages supported by the system. * @since 7 diff --git a/api/@ohos.intl.d.ts b/api/@ohos.intl.d.ts index 04ac9877a68fb6ae18b911d611f92bddbfc669ed..8755ac68148c7ea08999786029045b19224c6fc9 100755 --- a/api/@ohos.intl.d.ts +++ b/api/@ohos.intl.d.ts @@ -63,6 +63,157 @@ export class Locale { * @since 6 */ baseName: string + + /** + * Indicates the case first style of the locale. + */ + caseFirst: string + + /** + * Indicates the calendar. + */ + calendar: string + + /** + * Indicates the collation. + */ + collation: string + + /** + * Indicates the hour cycle. + */ + hourCycle: string + + /** + * Indicates the numbering system. + */ + numberingSystem: string + + /** + * Indicates whether it is numeric. + */ + numeric: boolean + + /** + * Convert the locale information to string. + * + * @return Returns locale information in string form. + */ + toString(): string; + + /** + * Maximize the locale's base information. + * + * @return Returns maximized locale. + */ + maximize(): Locale; + + /** + * Minimize the locale's base information. + * + * @return Returns minimized locale. + */ + minimize(): Locale; +} + +/** + * Provides the options of date time format. + */ +export interface DateTimeOptions { + /** + * Indicates the locale. + */ + locale: string + + /** + * Indicates the date style. + */ + dateStyle: string + + /** + * Indicates the time style. + */ + timeStyle: string + + /** + * Indicates the hour cycle. + */ + hourCycle: string + + /** + * Indicates the timezone. + */ + timeZone: string + + /** + * Indicates the numbering system. + */ + numberingSystem: string + + /** + * Indicates whether is 12 hour or not. + */ + hour12: boolean + + /** + * Indicates the weekday style. + */ + weekday: string + + /** + * Indicates the era style. + */ + era: string + + /** + * Indicates the year style. + */ + year: string + + /** + * Indicates the month style. + */ + month: string + + /** + * Indicates the day style. + */ + day: string + + /** + * Indicates the hour style. + */ + hour: string + + /** + * Indicates the minute style. + */ + minute: string + + /** + * Indicates the second style. + */ + second: string + + /** + * Indicates the timezone name. + */ + timeZoneName: string + + /** + * Indicates the day period format. + */ + dayPeriod: string + + /** + * Indicates the locale matching algorithm. + */ + localeMatcher: string + + /** + * Indicates the format matching algorithm. + */ + formatMatcher: string } /** @@ -76,9 +227,20 @@ export class DateTimeFormat { * * @param locale Indicates a character string containing the locale information, including * the language and optionally the script and region, for the DateTimeFormat object. + * @param options Indicates the options used to format the date. * @since 6 */ - constructor(locale?: string); + constructor(locale: string, options?: DateTimeOptions); + + /** + * A constructor used to create a DateTimeFormat object. + * + * @param locale Indicates an array of character string containing the locale information, including + * the language and optionally the script and region, for the DateTimeFormat object. + * @param options Indicates the options used to format the date. + * @since 6 + */ + constructor(locale: Array, options?: DateTimeOptions); /** * Obtains the formatted date strings. @@ -88,6 +250,161 @@ export class DateTimeFormat { * @since 6 */ format(date: Date): string; + + /** + * Obtains the formatted date strings of a date range. + * + * @param startDate Indicates the start date of the date range. + * @param endDate Indicates the end date of the date range. + * @return Returns a date string formatted based on the specified locale. + * @since 6 + */ + formatRange(startDate: Date, endDate: Date): string; + + /** + * Obtains the options of the DateTimeFormat object. + * + * @return Returns the options of the DateTimeFormat object. + * @since 6 + */ + resolvedOptions(): DateTimeOptions; +} + +/** + * Provides the options of number format. + */ +export interface NumberOptions { + /** + * Indicates the locale. + */ + locale: string + + /** + * Indicates the currency. + */ + currency: string + + /** + * Indicates the currency sign. + */ + currencySign: string + + /** + * Indicates the currency display format. + */ + currencyDisplay: string + + /** + * Indicates the unit. + */ + unit: string + + /** + * Indicates the unit display format. + */ + unitDisplay: string + + /** + * Indicates the sign display format. + */ + signDisplay: string + + /** + * Indicates the compact display format. + */ + compactDisplay: string + + /** + * Indicates the notation. + */ + notation: string + + /** + * Indicates the locale matching algorithm. + */ + localeMatcher: string + + /** + * Indicates the style. + */ + style: string + + /** + * Indicates the numbering system. + */ + numberingSystem: string + + /** + * Indicates whether using grouping or not. + */ + useGrouping: boolean + + /** + * Indicates the minimum integer digits. + */ + minimumIntegerDigits: number + + /** + * Indicates the minimum fraction digits. + */ + minimumFractionDigits: number + + /** + * Indicates the maximum fraction digits. + */ + maximumFractionDigits: number + + /** + * Indicates the minimum significant digits. + */ + minimumSignificantDigits: number + + /** + * Indicates the maximum significant digits. + */ + maximumSignificantDigits: number +} + +/** + * Provides the API for formatting number strings. + */ +export class NumberFormat { + /** + * A constructor used to create a NumberFormat object. + * + * @param locale Indicates a character string containing the locale information, including + * the language and optionally the script and region, for the NumberFormat object. + * @param options Indicates the options used to format the number. + * @since 6 + */ + constructor(locale: string, options?: NumberOptions); + + /** + * A constructor used to create a NumberFormat object. + * + * @param locale Indicates an array of character string containing the locale information, including + * the language and optionally the script and region, for the NumberFormat object. + * @param options Indicates the options used to format the number. + * @since 6 + */ + constructor(locale: Array, options?: NumberOptions); + + /** + * Obtains the formatted number string. + * + * @param number Indicates the number to be formatted. + * @return Returns a number string formatted based on the specified locale. + * @since 6 + */ + format(number: number): string; + + /** + * Obtains the options of the NumberFormat object. + * + * @return Returns the options of the NumberFormat object. + * @since 6 + */ + resolvedOptions(): NumberOptions; } } export default intl; \ No newline at end of file