diff --git a/api/@ohos.i18n.d.ts b/api/@ohos.i18n.d.ts index 79c4ac7738123dc0693d23febcfbed1b563543eb..339f5d0c52e37911d4140ecc78b995fed527a16d 100644 --- a/api/@ohos.i18n.d.ts +++ b/api/@ohos.i18n.d.ts @@ -330,4 +330,125 @@ export class Calendar { * @since 8 */ export function isRTL(locale: string): boolean; + +/** + * Sequence text can be grouped under the specified area, + * and grouping index with different lengths can be specified. + * @sysCap null + * @since 8 + */ +export class IndexUtil { + /** + * Get IndexUtil object. + * @sysCap null + * @param locale Indicates a character string containing the locale information, including + * the language and optionally the script and region, for the NumberFormat object. + * @return Returns IndexUtil object. + * @since 8 + */ + getInstance(locale?:string): IndexUtil; + + /** + * Get a list of labels for use as a UI index + * @sysCap null + * @return Returns a list of labels + * @since 8 + */ + getIndexList(): Array; + + /** + * Add the index characters from a Locale to the index. + * @sysCap null + * @param locale The locale whose index characters are to be added. + * @since 8 + */ + addLocale(locale: string); + + /** + * Get corresponding index of the input text. + * @sysCap null + * @param text input text + * @since 8 + */ + getIndex(text: string): string; +} + +/** + * Provides the API for accessing unicode character properties, sunch as whether a character is a digit. + * @sysCap null + * @since 8 + */ +export class Character { + /** + * Determines whether the specified code point is a digit character + * @sysCap null + * @param char the character to be tested + * @return Returns true if the character is a digit character + */ + isDigit(char: string): boolean; + + /** + * Determines if the specified character is a space character or not. + * @sysCap null + * @param char the character to be tested + * @return Returns true if the character is a space character + */ + isSpaceChar(char: string): boolean; + + /** + * Determines if the specified character is a whitespace character + * @sysCap null + * @param char the character to be tested + * @return Returns true if the character is a whitespace character + */ + isWhitespace(char: string): boolean; + + /** + * Determines if the specified character is a RTL character or not. + * @sysCap null + * @param char the character to be tested + * @return Returns true if the character is a RTL character + */ + isRTL(char: string): boolean; + + /** + * Determines if the specified character is a Ideographic character or not. + * @sysCap null + * @param char the character to be tested + * @return Returns true if the character is a Ideographic character + */ + isIdeograph(char: string): boolean; + + /** + * Determines if the specified character is a Letter or not. + * @sysCap null + * @param char the character to be tested + * @return Returns true if the character is a Letter + */ + isLetter(char: string): boolean; + + /** + * Determines if the specified character is a LowerCase character or not. + * @sysCap null + * @param char the character to be tested + * @return Returns true if the character is a LowerCase character + */ + isLowerCase(char: string): boolean; + + /** + * Determines if the specified character is a UpperCase character or not. + * @sysCap null + * @param char the character to be tested + * @return Returns true if the character is a UpperCase character + */ + isUpperCase(char: string): boolean; + + /** + * Get the general category value of the specified character. + * @sysCap null + * @param char the character to be tested + * @return Returns the general category of the specified character. + */ + getType(char: string): string; +} } \ No newline at end of file diff --git a/api/@ohos.intl.d.ts b/api/@ohos.intl.d.ts index 58f7d28ece511e19785cf640f65997c73872353e..1f53ea0e4b31a154a76a003c8ca67f21be604f89 100755 --- a/api/@ohos.intl.d.ts +++ b/api/@ohos.intl.d.ts @@ -581,5 +581,116 @@ export class PluralRules { */ select(n: number): string; } + +/** + * Provides the input options of RelativeTimeFormat. + * @sysCap null + * @since 8 + */ + export interface RelativeTimeFormatInputOptions { + /** + * The locale matching algorithm to use. + * Possible values are: lookup, best fit + */ + localeMatcher: string; + + /** + * The format of output message. + * Possible values are: always, auto + */ + numeric: string; + + /** + * The length of the internationalized message. + * Possible values are: long, short, narrow + */ + style: string; +} + +/** + * Provides the resolved options of RelativeTimeFormat. + * @sysCap null + * @since 8 + */ +export interface RelativeTimeFormatResolvedOptions { + /** + * The BCP 47 language tag for the locale actually used. + */ + locale: string; + + /** + * The length of the internationalized message. + * Possible values are: long, short, narrow + */ + style: string; + + /** + * The format of output message. + * Possible values are: always, auto + */ + numeric: string; + + /** + * The value requested using the Unicode extension key "nu" or filled in as a default. + */ + numberingSystem: string; +} + +/** + * Given a Time period length value and a unit, RelativeTimeFormat object enables + * language-sensitive relative time formatting. + * @sysCap null + * @since 8 + */ +export class RelativeTimeFormat { + /** + * A constructor used to create RelativeTimeFormat object. + * @sysCap null + * @since 8 + */ + constructor(); + + /** + * A constructor used to create RelativeTimeFormat object. + * @sysCap null + * @param locale Indicates a character string containing the locale information, including + * the language and optionally the script and region, for the RelativeTimeFormat object. + * @param options Indicates the options used to initialize RelativeTimeFormat object. + * @since 8 + */ + constructor(locale: string | Array, options?: RelativeTimeFormatInputOptions); + + /** + * formats a value and unit according to the locale and formatting options of this object. + * @sysCap null + * @param value Numeric value to use in the internationalized relative time message. + * @param unit Unit to use in the relative time internationalized message. + * Possible values are: year, quarter, month, week, day, hour, minute, second. + * @returns formatted language-sensitive relative time. + * @since 8 + */ + format(value: number, unit: string): string; + + /** + * returns an Array of objects representing the relative time format in parts that can be used for + * custom locale-aware formatting + * @sysCap null + * @param value Numeric value to use in the internationalized relative time message. + * @param unit to use in the relative time internationalized message. + * Possible values are: year, quarter, month, week, day, hour, minute, second. + * @returns an Array of objects representing the relative time format in parts + * @since 8 + */ + formatToParts(value: number, unit: string): Array; + + /** + * Returns a new object with properties reflecting the locale and formatting options computed during + * initialization of the object. + * @sysCap null + * @returns RelativeTimeFormatOptions which reflecting the locale and formatting options of the object. + * @since 8 + */ + resolvedOptions(): RelativeTimeFormatResolvedOptions; +} } export default intl; \ No newline at end of file