From d95ed9517c27bade43dc7a0b6de1c0f0df214a6a Mon Sep 17 00:00:00 2001 From: sunyaozu Date: Mon, 13 Dec 2021 10:04:05 +0800 Subject: [PATCH 1/2] add character, index_util, character to i18n Signed-off-by: sunyaozu --- api/@ohos.i18n.d.ts | 125 +++++++++++++++++++++++++++++++++++++++++++- api/@ohos.intl.d.ts | 111 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 234 insertions(+), 2 deletions(-) diff --git a/api/@ohos.i18n.d.ts b/api/@ohos.i18n.d.ts index 5e4d1f1276..339f5d0c52 100644 --- a/api/@ohos.i18n.d.ts +++ b/api/@ohos.i18n.d.ts @@ -305,7 +305,7 @@ export class Calendar { * Get calendar's name localized for display in the given locale. * * @param locale Locale used to get the localized name for this calendar. - * @return Retuns the localized name of this calendar. + * @return Returns the localized name of this calendar. * @since 8 */ getDisplayName(locale: string): string; @@ -315,7 +315,7 @@ export class Calendar { * the date object of this calendar is used. * * @param date Date object whose attribute is desired. - * @return Retuns whether the date is a weekend day. + * @return Returns whether the date is a weekend day. * @since 8 */ isWeekend(date?: Date): boolean; @@ -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 58f7d28ece..1f53ea0e4b 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 -- Gitee From 20ec3a0f9a82ca2fda8b249938bead59869dc034 Mon Sep 17 00:00:00 2001 From: sunyaozu Date: Tue, 14 Dec 2021 09:35:37 +0000 Subject: [PATCH 2/2] update api/@ohos.i18n.d.ts. --- api/@ohos.i18n.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/@ohos.i18n.d.ts b/api/@ohos.i18n.d.ts index 339f5d0c52..6ce0043e15 100644 --- a/api/@ohos.i18n.d.ts +++ b/api/@ohos.i18n.d.ts @@ -305,7 +305,7 @@ export class Calendar { * Get calendar's name localized for display in the given locale. * * @param locale Locale used to get the localized name for this calendar. - * @return Returns the localized name of this calendar. + * @return Retuns the localized name of this calendar. * @since 8 */ getDisplayName(locale: string): string; @@ -315,7 +315,7 @@ export class Calendar { * the date object of this calendar is used. * * @param date Date object whose attribute is desired. - * @return Returns whether the date is a weekend day. + * @return Retuns whether the date is a weekend day. * @since 8 */ isWeekend(date?: Date): boolean; -- Gitee