1/* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15import {BusinessError} from "./basic"; 16 17/** 18 * Provides international settings related APIs. 19 * 20 * @syscap SystemCapability.Global.I18n 21 * @since 7 22 */ 23declare namespace i18n { 24/** 25 * Obtains the country or region name localized for display on a given locale. 26 * 27 * @syscap SystemCapability.Global.I18n 28 * @param country The locale whose country or region name will be displayed. 29 * @param locale The locale used to display the country or region. 30 * @param sentenceCase Specifies whether the country or region name is displayed in sentence case. 31 * @returns Returns the country or region name localized for display on a given locale. 32 * @since 7 33 * @deprecated since 9 34 * @useinstead ohos.System.getDisplayCountry 35 */ 36export function getDisplayCountry(country: string, locale: string, sentenceCase?: boolean): string; 37 38/** 39 * Obtains the language name localized for display on a given locale. 40 * 41 * @syscap SystemCapability.Global.I18n 42 * @param language The locale whose language name will be displayed. 43 * @param locale The locale used to display the language. 44 * @param sentenceCase Specifies whether the language name is displayed in sentence case. 45 * @returns Returns the language name localized for display on a given locale. 46 * @since 7 47 * @deprecated since 9 48 * @useinstead ohos.System.getDisplayLanguage 49 */ 50export function getDisplayLanguage(language: string, locale: string, sentenceCase?: boolean): string; 51 52/** 53 * Obtains the language currently used by the system. 54 * 55 * @syscap SystemCapability.Global.I18n 56 * @returns Returns the language currently used by the system. 57 * @since 7 58 * @deprecated since 9 59 * @useinstead ohos.System.getSystemLanguage 60 */ 61export function getSystemLanguage(): string; 62 63/** 64 * Obtains the region currently used by the system. 65 * 66 * @syscap SystemCapability.Global.I18n 67 * @returns Returns the region currently used by the system. 68 * @since 7 69 * @deprecated since 9 70 * @useinstead ohos.System.getSystemRegion 71 */ 72export function getSystemRegion(): string; 73 74/** 75 * Obtains the locale currently used by the system. 76 * 77 * @syscap SystemCapability.Global.I18n 78 * @returns Returns the locale currently used by the system. 79 * @since 7 80 * @deprecated since 9 81 * @useinstead ohos.System.getSystemLocale 82 */ 83export function getSystemLocale(): string; 84 85/** 86 * Provides system functions. 87 * 88 * @syscap SystemCapability.Global.I18n 89 * @since 9 90 */ 91export class System { 92 /** 93 * Obtains the country or region name localized for display on a given locale. 94 * 95 * @syscap SystemCapability.Global.I18n 96 * @param country The locale whose country or region name will be displayed. 97 * @param locale The locale used to display the country or region. 98 * @param sentenceCase Specifies whether the country or region name is displayed in sentence case. 99 * @throws {BusinessError} 401 - check param failed 100 * @throws {BusinessError} 890001 - param value not valid 101 * @returns Returns the country or region name localized for display on a given locale. 102 * @since 9 103 */ 104 static getDisplayCountry(country: string, locale: string, sentenceCase?: boolean): string; 105 106 /** 107 * Obtains the language name localized for display on a given locale. 108 * 109 * @syscap SystemCapability.Global.I18n 110 * @param language The locale whose language name will be displayed. 111 * @param locale The locale used to display the language. 112 * @param sentenceCase Specifies whether the language name is displayed in sentence case. 113 * @throws {BusinessError} 401 - check param failed 114 * @throws {BusinessError} 890001 - param value not valid 115 * @returns Returns the language name localized for display on a given locale. 116 * @since 9 117 */ 118 static getDisplayLanguage(language: string, locale: string, sentenceCase?: boolean): string; 119 120 /** 121 * Obtains all languages supported by the system. 122 * 123 * @syscap SystemCapability.Global.I18n 124 * @returns Returns all languages supported by the system. 125 * @since 9 126 */ 127 static getSystemLanguages(): Array<string>; 128 129 /** 130 * Obtains all regions supported by the system in the language. 131 * 132 * @syscap SystemCapability.Global.I18n 133 * @param language The language used to get the list of regions. 134 * @throws {BusinessError} 401 - check param failed 135 * @throws {BusinessError} 890001 - param value not valid 136 * @returns Returns all countries or regions supported by the system in the language. 137 * @since 9 138 */ 139 static getSystemCountries(language: string): Array<string>; 140 141 /** 142 * Determine whether the current language or region is recommended. 143 * 144 * @syscap SystemCapability.Global.I18n 145 * @param language The language code. 146 * @param region The region code. 147 * @throws {BusinessError} 401 - check param failed 148 * @throws {BusinessError} 890001 - param value not valid 149 * @returns Returns whether the current language or region is recommended. 150 * @since 9 151 */ 152 static isSuggested(language: string, region?: string): boolean; 153 154 /** 155 * Obtains the language currently used by the system. 156 * 157 * @syscap SystemCapability.Global.I18n 158 * @returns Returns the language currently used by the system. 159 * @since 9 160 */ 161 static getSystemLanguage(): string; 162 163 /** 164 * Set the language currently used by the system. 165 * 166 * @permission ohos.permission.UPDATE_CONFIGURATION 167 * @syscap SystemCapability.Global.I18n 168 * @param language The language to be used. 169 * @throws {BusinessError} 201 - the application does not have permission to call this function 170 * @throws {BusinessError} 401 - check param failed 171 * @throws {BusinessError} 890001 - param value not valid 172 * @systemapi Hide this for inner system use. 173 */ 174 static setSystemLanguage(language: string): void; 175 176 /** 177 * Obtains the region currently used by the system. 178 * 179 * @syscap SystemCapability.Global.I18n 180 * @returns Returns the region currently used by the system. 181 * @since 9 182 */ 183 static getSystemRegion(): string; 184 185 /** 186 * Set the region currently used by the system. 187 * 188 * @permission ohos.permission.UPDATE_CONFIGURATION 189 * @syscap SystemCapability.Global.I18n 190 * @param region The region to be used. 191 * @throws {BusinessError} 201 - the application does not have permission to call this function 192 * @throws {BusinessError} 401 - check param failed 193 * @throws {BusinessError} 890001 - param value not valid 194 * @since 9 195 * @systemapi Hide this for inner system use. 196 */ 197 static setSystemRegion(region: string): void; 198 199 /** 200 * Obtains the locale currently used by the system. 201 * 202 * @syscap SystemCapability.Global.I18n 203 * @returns Returns the locale currently used by the system. 204 * @since 9 205 */ 206 static getSystemLocale(): string; 207 208 /** 209 * Set the locale currently used by the system. 210 * 211 * @permission ohos.permission.UPDATE_CONFIGURATION 212 * @syscap SystemCapability.Global.I18n 213 * @param locale The locale to be used. 214 * @throws {BusinessError} 201 - the application does not have permission to call this function 215 * @throws {BusinessError} 401 - check param failed 216 * @throws {BusinessError} 890001 - param value not valid 217 * @since 9 218 * @systemapi Hide this for inner system use. 219 */ 220 static setSystemLocale(locale: string): void; 221 222 /** 223 * Check out whether system is 24-hour system. 224 * 225 * @syscap SystemCapability.Global.I18n 226 * @returns Returns a boolean represent whether system is 24-hour system. 227 * @since 9 228 */ 229 static is24HourClock(): boolean; 230 231 /** 232 * Set 24-hour system. 233 * 234 * @permission ohos.permission.UPDATE_CONFIGURATION 235 * @syscap SystemCapability.Global.I18n 236 * @param option represent the boolean to be set. 237 * @throws {BusinessError} 201 - the application does not have permission to call this function 238 * @throws {BusinessError} 401 - check param failed 239 * @throws {BusinessError} 890001 - param value not valid 240 * @since 9 241 * @systemapi Hide this for inner system use. 242 */ 243 static set24HourClock(option: boolean): void; 244 245 /** 246 * Add one language to preferred language List. 247 * 248 * @permission ohos.permission.UPDATE_CONFIGURATION 249 * @syscap SystemCapability.Global.I18n 250 * @param language the language to be added. 251 * @param index the position of preferred language list to be inserted. 252 * @throws {BusinessError} 201 - the application does not have permission to call this function 253 * @throws {BusinessError} 401 - check param failed 254 * @throws {BusinessError} 890001 - param value not valid 255 * @since 9 256 * @systemapi Hide this for inner system use. 257 */ 258 static addPreferredLanguage(language: string, index?: number): void; 259 260 /** 261 * Remove one language from preferred language list. 262 * 263 * @permission ohos.permission.UPDATE_CONFIGURATION 264 * @syscap SystemCapability.Global.I18n 265 * @param index the position of removed language in preferred language list. 266 * @throws {BusinessError} 201 - the application does not have permission to call this function 267 * @throws {BusinessError} 401 - check param failed 268 * @throws {BusinessError} 890001 - param value not valid 269 * @since 9 270 * @systemapi Hide this for inner system use. 271 */ 272 static removePreferredLanguage(index: number): void; 273 274 /** 275 * Access the system preferred language list. 276 * 277 * @syscap SystemCapability.Global.I18n 278 * @returns Returns a string Array represent the preferred language list. 279 * @since 9 280 */ 281 static getPreferredLanguageList(): Array<string>; 282 283 /** 284 * Get the first preferred language of system. 285 * 286 * @syscap SystemCapability.Global.I18n 287 * @returns Returns a string represent the first preferred language of system. 288 * @since 9 289 */ 290 static getFirstPreferredLanguage(): string; 291 292 /** 293 * Get the preferred language of App. 294 * 295 * @syscap SystemCapability.Global.I18n 296 * @returns Returns a string represent the preferred language of App. 297 * @since 9 298 */ 299 static getAppPreferredLanguage(): string; 300 301 /** 302 * Set whether to use local digit. 303 * 304 * @permission ohos.permission.UPDATE_CONFIGURATION 305 * @syscap SystemCapability.Global.I18n 306 * @param flag a boolean variable represents whether to use local digit 307 * @throws {BusinessError} 201 - the application does not have permission to call this function 308 * @throws {BusinessError} 401 - check param failed 309 * @throws {BusinessError} 890001 - param value not valid 310 * @since 9 311 * @systemapi Hide this for inner system use. 312 */ 313 static setUsingLocalDigit(flag: boolean): void; 314 315 /** 316 * Get whether to use local digit. 317 * 318 * @syscap SystemCapability.Global.I18n 319 * @returns Returns a boolean represents whether to use local digit. 320 * @since 9 321 */ 322 static getUsingLocalDigit(): boolean; 323} 324 325/** 326 * Provides util functions. 327 * 328 * @syscap SystemCapability.Global.I18n 329 * @since 8 330 * @deprecated since 9 331 * @useinstead I18NUtil 332 */ 333export interface Util { 334 /** 335 * Convert from unit to unit and format according to the locale. 336 * 337 * @syscap SystemCapability.Global.I18n 338 * @param fromUnit Information of the unit to be converted. 339 * @param toUnit Information about the unit to be converted to. 340 * @param value Indicates the number to be formatted. 341 * @param locale The locale to be used. 342 * @param style The style of format. 343 * @since 8 344 * @deprecated since 9 345 * @useinstead I18NUtil.unitConvert 346 */ 347 unitConvert(fromUnit: UnitInfo, toUnit: UnitInfo, value: number, locale: string, style?: string): string; 348} 349 350/** 351 * Provides util functions. 352 * 353 * @syscap SystemCapability.Global.I18n 354 * @since 9 355 */ 356 export class I18NUtil { 357 /** 358 * Convert from unit to unit and format according to the locale. 359 * 360 * @syscap SystemCapability.Global.I18n 361 * @param { UnitInfo } fromUnit - Information of the unit to be converted. 362 * @param { UnitInfo } toUnit - Information about the unit to be converted to. 363 * @param { number } value - Indicates the number to be formatted. 364 * @param { string } locale - The locale to be used. 365 * @param { string } [ style ] - The style of format. 366 * @since 9 367 */ 368 static unitConvert(fromUnit: UnitInfo, toUnit: UnitInfo, value: number, locale: string, style?: string): string; 369 370 /** 371 * Get the order of year, month, day in the specified locale. Year, month, day are separated by '-'. 372 * 'y' stands for year, 'L' stands for month, d stands for day. 373 * 374 * @syscap SystemCapability.Global.I18n 375 * @param { string } locale - Information of the locale 376 * @returns Returns the string of 'y', 'L', 'd' joined by '-'. 377 * @since 9 378 */ 379 static getDateOrder(locale: string): string; 380} 381 382/** 383 * Provides the options of unit. 384 * 385 * @syscap SystemCapability.Global.I18n 386 * @since 8 387 */ 388export interface UnitInfo { 389 /** 390 * Unit name. 391 */ 392 unit: string 393 394 /** 395 * The measurement system of the unit. 396 */ 397 measureSystem: string 398} 399 400/** 401 * Provides the options of PhoneNumberFormat. 402 * 403 * @syscap SystemCapability.Global.I18n 404 * @since 8 405 */ 406export interface PhoneNumberFormatOptions { 407 /** 408 * Indicates the type to format phone number. 409 * 410 * @type { string } type 411 * @since 8 412 */ 413 /** 414 * Indicates the type to format phone number. 415 * 416 * @type { string } [ type ] 417 * @since 9 418 */ 419 type?: string; 420} 421 422/** 423 * Provides the API for formatting phone number strings 424 * 425 * @syscap SystemCapability.Global.I18n 426 * @since 8 427 */ 428export class PhoneNumberFormat { 429 /** 430 * A constructor used to create a PhoneNumberFormat object. 431 * 432 * @syscap SystemCapability.Global.I18n 433 * @param country Indicates a character string containing the country information for the PhoneNumberFormat object. 434 * @param type Indicates the type used to format the phone number, includes: "E164", "RFC3966", "INTERNATIONAL", "NATIONAL". 435 * @since 8 436 */ 437 constructor(country: string, options?: PhoneNumberFormatOptions); 438 439 /** 440 * Judge whether phone number is valid. 441 * 442 * @syscap SystemCapability.Global.I18n 443 * @param number Indicates the input phone number. 444 * @returns Returns a boolean indicates whether the input phone number is valid. 445 * @since 8 446 */ 447 isValidNumber(number: string): boolean; 448 449 /** 450 * Obtains the formatted phone number strings of number. 451 * 452 * @syscap SystemCapability.Global.I18n 453 * @param number Indicates the input phone number to be formatted. 454 * @returns Returns the formatted phone number. 455 * @since 8 456 */ 457 format(number: string): string; 458 459 /** 460 * Determine the location by phone number, and return it according to the specified regional language. 461 * 462 * @syscap SystemCapability.Global.I18n 463 * @param number input phone number. 464 * @param locale locale ID. 465 * @returns Returns a string represents phone number's location. 466 * @since 9 467 */ 468 getLocationName(number: string, locale: string): string; 469} 470 471/** 472 * Get a Calendar instance specified by locale and type. 473 * 474 * @syscap SystemCapability.Global.I18n 475 * @param locale The locale used to get calendar. 476 * @param type If type is not specified, get locale's default Calendar, else get the specified type of Calendar. 477 * such as buddhist, chinese, coptic, ethiopic, hebrew, gregory, indian, islamic_civil, islamic_tbla, islamic_umalqura, 478 * japanese, persian. 479 * @since 8 480 */ 481 export function getCalendar(locale: string, type?: string): Calendar; 482 483export class Calendar { 484 /** 485 * set the date. 486 * 487 * @syscap SystemCapability.Global.I18n 488 * @param date Date object used to set the time and date. 489 * @since 8 490 */ 491 setTime(date: Date): void; 492 493 /** 494 * set the time. 495 * 496 * @syscap SystemCapability.Global.I18n 497 * @param time Indicates the elapsed milliseconds from 1970.1.1 00:00:00 GMT. 498 * @since 8 499 */ 500 setTime(time: number): void; 501 502 /** 503 * Set the time 504 * 505 * @syscap SystemCapability.Global.I18n 506 * @param year The year field of the calendar, ranges from 0 to 9999. 507 * @param month The month field of the calendar, ranges from 0 to 11. 508 * @param date The day field of the calendar, ranges from 1 to 31. 509 * @param hour The hour field of the calendar, ranges from 0 to 23. 510 * @param minute The minute field of the calendar, ranges from 0 to 59. 511 * @param second the second field of the calendar, ranges from 0 to 59. 512 * @since 8 513 */ 514 set(year: number, month: number, date:number, hour?: number, minute?: number, second?: number): void; 515 516 /** 517 * Set the timezone of this calendar. 518 * 519 * @syscap SystemCapability.Global.I18n 520 * @param timezone The id of a timezone. 521 * @since 8 522 */ 523 setTimeZone(timezone: string): void; 524 525 /** 526 * Get the timezone id of this calendar instance. 527 * 528 * @syscap SystemCapability.Global.I18n 529 * @returns Returns the timezone id of this calendar. 530 * @since 8 531 */ 532 getTimeZone(): string; 533 534 /** 535 * Get the start day of a week. 1 indicates Sunday, 7 indicates Saturday. 536 * 537 * @syscap SystemCapability.Global.I18n 538 * @returns Returns start day of a week. 539 * @since 8 540 */ 541 getFirstDayOfWeek(): number; 542 543 /** 544 * Set the start day of a week. 1 indicates Sunday, 7 indicates Saturday. 545 * 546 * @syscap SystemCapability.Global.I18n 547 * @param value Indicates the start day of a week. 1 indicates Sunday, 7 indicates Saturday. 548 * @since 8 549 */ 550 setFirstDayOfWeek(value: number): void; 551 552 /** 553 * Get the minimal days of a week, which is needed for the first day of a year. 554 * 555 * @syscap SystemCapability.Global.I18n 556 * @returns Returns the minimal days of a week. 557 * @since 8 558 */ 559 getMinimalDaysInFirstWeek(): number; 560 561 /** 562 * Set the minimal days of a week, which is needed for the first week of a year. 563 * 564 * @syscap SystemCapability.Global.I18n 565 * @param value The value to be set. 566 * @since 8 567 */ 568 setMinimalDaysInFirstWeek(value: number): void; 569 570 /** 571 * Get the associated value with the field. 572 * 573 * @syscap SystemCapability.Global.I18n 574 * @param field Field values such as era, year, month, week_of_year, week_of_month, date, day_of_year, day_of_week 575 * day_of_week_in_month, hour, hour_of_day, minute, second, millisecond, zone_offset, dst_offset, year_woy, 576 * dow_local, extended_year, julian_day, milliseconds_in_day, is_leap_month. 577 * @returns Return the associated value. 578 * @since 8 579 */ 580 get(field: string): number; 581 582 /** 583 * Get calendar's name localized for display in the given locale. 584 * 585 * @syscap SystemCapability.Global.I18n 586 * @param locale Locale used to get the localized name for this calendar. 587 * @returns Returns the localized name of this calendar. 588 * @since 8 589 */ 590 getDisplayName(locale: string): string; 591 592 /** 593 * Returns true if the given date is a weekend day. If the date is not given, 594 * the date object of this calendar is used. 595 * 596 * @syscap SystemCapability.Global.I18n 597 * @param date Date object whose attribute is desired. 598 * @returns Returns whether the date is a weekend day. 599 * @since 8 600 */ 601 isWeekend(date?: Date): boolean; 602} 603 604/** 605 * Judge whether the locale is RTL locale. 606 * 607 * @syscap SystemCapability.Global.I18n 608 * @param locale The locale to be used. 609 * @returns Returns true representing the locale is an RTL locale 610 * 611 * @since 7 612 */ 613export function isRTL(locale: string): boolean; 614 615/** 616 * Obtains a BreakIterator object for finding the location of break point in text. 617 * 618 * @syscap SystemCapability.Global.I18n 619 * @param locale the returned BreakIterator will adapt the rule, specified by the locale, to break text. 620 * @returns Returns a newly constructed BreakIterator object. 621 * @since 8 622 */ 623 export function getLineInstance(locale: string): BreakIterator; 624 625/** 626 * The BreakIterator class is used for finding the location of break point in text. 627 * 628 * @syscap SystemCapability.Global.I18n 629 * @since 8 630 */ 631export class BreakIterator { 632 /** 633 * Obtains the current position of the BreakIterator instance. 634 * 635 * @syscap SystemCapability.Global.I18n 636 * @returns Returns the current position of the BreakIterator instance. 637 * @since 8 638 */ 639 current(): number; 640 641 /** 642 * Set the BreakIterator's position to the first break point, the first break point is always the beginning of the 643 * processed text. 644 * 645 * @syscap SystemCapability.Global.I18n 646 * @returns Returns the index of the first break point. 647 * @since 8 648 */ 649 first(): number; 650 651 /** 652 * Set the BreakIterator's position to the last break point. the last break point is always the index beyond the 653 * last character of the processed text. 654 * 655 * @syscap SystemCapability.Global.I18n 656 * @returns Returns the index of the last break point. 657 * @since 8 658 */ 659 last(): number; 660 661 /** 662 * Set the BreakIterator's position to the nth break point from the current break point. 663 * 664 * @syscap SystemCapability.Global.I18n 665 * @param index indicates the number of break points to advance. If index is not given, n is treated as 1. 666 * @returns Returns the index of the BreakIterator after moving. If there is not enough break points, returns -1. 667 * @since 8 668 */ 669 next(index?: number): number; 670 671 /** 672 * Set the BreakIterator's position to the break point preceding the current break point. 673 * 674 * @syscap SystemCapability.Global.I18n 675 * @returns Returns the index of the BreakIterator after moving. If there is not enough break points, returns -1. 676 * @since 8 677 */ 678 previous(): number; 679 680 /** 681 * Set the text to be processed. 682 * 683 * @syscap SystemCapability.Global.I18n 684 * @param text Indicates the text to be processed by the BreakIterator. 685 * @since 8 686 */ 687 setLineBreakText(text: string): void; 688 689 /** 690 * Set the BreakIterator's position to the first break point following the specified offset. 691 * 692 * @syscap SystemCapability.Global.I18n 693 * @returns Returns the index of the BreakIterator after moving. If there is not enough break points, returns -1. 694 * @since 8 695 */ 696 following(offset: number): number; 697 698 /** 699 * Obtains the text being processed. 700 * 701 * @syscap SystemCapability.Global.I18n 702 * @returns Returns the text that is processed by the BreakIterator. 703 * @since 8 704 */ 705 getLineBreakText(): string; 706 707 /** 708 * Returns true if the position indicated by the offset is a break point, otherwise false. The BreakIterator's 709 * position will be set to the position indicated by the offset if it returns true, otherwise the BreakIterator 710 * will be moved to the break point following the offset. 711 * 712 * @syscap SystemCapability.Global.I18n 713 * @param offset The offset to be checked. 714 * @returns Returns true if the offset is a break point. 715 * @since 8 716 */ 717 isBoundary(offset: number): boolean; 718} 719 720/** 721 * Get IndexUtil object. 722 * 723 * @syscap SystemCapability.Global.I18n 724 * @param locale Indicates a character string containing the locale information, including 725 * the language and optionally the script and region, for the NumberFormat object. 726 * @returns Returns IndexUtil object. 727 * @since 8 728 */ 729export function getInstance(locale?:string): IndexUtil; 730 731/** 732 * Sequence text can be grouped under the specified area, 733 * and grouping index with different lengths can be specified. 734 * 735 * @syscap SystemCapability.Global.I18n 736 * @since 8 737 */ 738export class IndexUtil { 739 /** 740 * Get a list of labels for use as a UI index 741 * 742 * @syscap SystemCapability.Global.I18n 743 * @returns Returns a list of labels 744 * @since 8 745 */ 746 getIndexList(): Array<string>; 747 748 /** 749 * Add the index characters from a Locale to the index. 750 * 751 * @syscap SystemCapability.Global.I18n 752 * @param locale The locale whose index characters are to be added. 753 * @since 8 754 */ 755 addLocale(locale: string): void; 756 757 /** 758 * Get corresponding index of the input text. 759 * 760 * @syscap SystemCapability.Global.I18n 761 * @param text input text 762 * @since 8 763 */ 764 getIndex(text: string): string; 765} 766 767/** 768 * Provides the API for accessing unicode character properties. For example, determine whether a character is a number. 769 * 770 * @syscap SystemCapability.Global.I18n 771 * @since 8 772 * @deprecated since 9 773 * @useinstead Unicode 774 */ 775export class Character { 776 /** 777 * Determines whether the specified code point is a digit character 778 * 779 * @syscap SystemCapability.Global.I18n 780 * @param char the character to be tested 781 * @returns Returns true if the character is a digit character 782 * @since 8 783 * @deprecated since 9 784 * @useinstead Unicode.isDigit 785 */ 786 isDigit(char: string): boolean; 787 788 /** 789 * Determines if the specified character is a space character or not. 790 * 791 * @syscap SystemCapability.Global.I18n 792 * @param char the character to be tested 793 * @returns Returns true if the character is a space character 794 * @since 8 795 * @deprecated since 9 796 * @useinstead Unicode.isSpaceChar 797 */ 798 isSpaceChar(char: string): boolean; 799 800 /** 801 * Determines if the specified character is a whitespace character 802 * 803 * @syscap SystemCapability.Global.I18n 804 * @param char the character to be tested 805 * @returns Returns true if the character is a whitespace character 806 * @since 8 807 * @deprecated since 9 808 * @useinstead Unicode.isWhitespace 809 */ 810 isWhitespace(char: string): boolean; 811 812 /** 813 * Determines if the specified character is a RTL character or not. 814 * 815 * @syscap SystemCapability.Global.I18n 816 * @param char the character to be tested 817 * @returns Returns true if the character is a RTL character 818 * @since 8 819 * @deprecated since 9 820 * @useinstead Unicode.isRTL 821 */ 822 isRTL(char: string): boolean; 823 824 /** 825 * Determines if the specified character is a Ideographic character or not. 826 * 827 * @syscap SystemCapability.Global.I18n 828 * @param char the character to be tested 829 * @returns Returns true if the character is a Ideographic character 830 * @since 8 831 * @deprecated since 9 832 * @useinstead Unicode.isIdeograph 833 */ 834 isIdeograph(char: string): boolean; 835 836 /** 837 * Determines if the specified character is a Letter or not. 838 * 839 * @syscap SystemCapability.Global.I18n 840 * @param char the character to be tested 841 * @returns Returns true if the character is a Letter 842 * @since 8 843 * @deprecated since 9 844 * @useinstead Unicode.isLetter 845 */ 846 isLetter(char: string): boolean; 847 848 /** 849 * Determines if the specified character is a LowerCase character or not. 850 * 851 * @syscap SystemCapability.Global.I18n 852 * @param char the character to be tested 853 * @returns Returns true if the character is a LowerCase character 854 * @since 8 855 * @deprecated since 9 856 * @useinstead Unicode.isLowerCase 857 */ 858 isLowerCase(char: string): boolean; 859 860 /** 861 * Determines if the specified character is a UpperCase character or not. 862 * 863 * @syscap SystemCapability.Global.I18n 864 * @param char the character to be tested 865 * @returns Returns true if the character is a UpperCase character 866 * @since 8 867 * @deprecated since 9 868 * @useinstead Unicode.isUpperCase 869 */ 870 isUpperCase(char: string): boolean; 871 872 /** 873 * Get the general category value of the specified character. 874 * 875 * @syscap SystemCapability.Global.I18n 876 * @param char the character to be tested 877 * @returns Returns the general category of the specified character. 878 * @since 8 879 * @deprecated since 9 880 * @useinstead Unicode.getType 881 */ 882 getType(char: string): string; 883} 884 885/** 886 * Provides the API for accessing unicode character properties. For example, determine whether a character is a number. 887 * 888 * @syscap SystemCapability.Global.I18n 889 * @since 9 890 */ 891 export class Unicode { 892 /** 893 * Determines whether the specified code point is a digit character 894 * 895 * @syscap SystemCapability.Global.I18n 896 * @param { string } char - the character to be tested 897 * @returns Returns true if the character is a digit character 898 * @since 9 899 */ 900 static isDigit(char: string): boolean; 901 902 /** 903 * Determines if the specified character is a space character or not. 904 * 905 * @syscap SystemCapability.Global.I18n 906 * @param { string } char - the character to be tested 907 * @returns Returns true if the character is a space character 908 * @since 9 909 */ 910 static isSpaceChar(char: string): boolean; 911 912 /** 913 * Determines if the specified character is a whitespace character 914 * 915 * @syscap SystemCapability.Global.I18n 916 * @param { string } char - the character to be tested 917 * @returns Returns true if the character is a whitespace character 918 * @since 9 919 */ 920 static isWhitespace(char: string): boolean; 921 922 /** 923 * Determines if the specified character is a RTL character or not. 924 * 925 * @syscap SystemCapability.Global.I18n 926 * @param { string } char - the character to be tested 927 * @returns Returns true if the character is a RTL character 928 * @since 9 929 */ 930 static isRTL(char: string): boolean; 931 932 /** 933 * Determines if the specified character is a Ideographic character or not. 934 * 935 * @syscap SystemCapability.Global.I18n 936 * @param { string } char - the character to be tested 937 * @returns Returns true if the character is a Ideographic character 938 * @since 9 939 */ 940 static isIdeograph(char: string): boolean; 941 942 /** 943 * Determines if the specified character is a Letter or not. 944 * 945 * @syscap SystemCapability.Global.I18n 946 * @param { string } char - the character to be tested 947 * @returns Returns true if the character is a Letter 948 * @since 9 949 */ 950 static isLetter(char: string): boolean; 951 952 /** 953 * Determines if the specified character is a LowerCase character or not. 954 * 955 * @syscap SystemCapability.Global.I18n 956 * @param { string } char - the character to be tested 957 * @returns Returns true if the character is a LowerCase character 958 * @since 9 959 */ 960 static isLowerCase(char: string): boolean; 961 962 /** 963 * Determines if the specified character is a UpperCase character or not. 964 * 965 * @syscap SystemCapability.Global.I18n 966 * @param { string } char - the character to be tested 967 * @returns Returns true if the character is a UpperCase character 968 * @since 9 969 */ 970 static isUpperCase(char: string): boolean; 971 972 /** 973 * Get the general category value of the specified character. 974 * 975 * @syscap SystemCapability.Global.I18n 976 * @param { string } char - the character to be tested 977 * @returns Returns the general category of the specified character. 978 * @since 9 979 */ 980 static getType(char: string): string; 981} 982 983/** 984 * check out whether system is 24-hour system. 985 * 986 * @syscap SystemCapability.Global.I18n 987 * @returns Returns a boolean represent whether system is 24-hour system. 988 * @since 7 989 * @deprecated since 9 990 * @useinstead ohos.System.is24HourClock 991 */ 992 export function is24HourClock(): boolean; 993 994/** 995 * set 24-hour system. 996 * 997 * @permission ohos.permission.UPDATE_CONFIGURATION 998 * @syscap SystemCapability.Global.I18n 999 * @param option represent the boolean to be set. 1000 * @returns Returns a boolean represent whether setting 24-hour system success. 1001 * @since 7 1002 * @deprecated since 9 1003 * @useinstead ohos.System.set24HourClock 1004 */ 1005 export function set24HourClock(option: boolean): boolean; 1006 1007/** 1008 * Add one language to preferred language List. 1009 * 1010 * @permission ohos.permission.UPDATE_CONFIGURATION 1011 * @syscap SystemCapability.Global.I18n 1012 * @param language the language to be added. 1013 * @param index the position of preferred language list to be inserted. 1014 * @returns Returns a boolean represent whether language added success. 1015 * @since 8 1016 * @deprecated since 9 1017 * @useinstead ohos.System.addPreferredLanguage 1018 */ 1019export function addPreferredLanguage(language: string, index?: number): boolean; 1020 1021/** 1022 * Remove one language from preferred language list. 1023 * 1024 * @permission ohos.permission.UPDATE_CONFIGURATION 1025 * @syscap SystemCapability.Global.I18n 1026 * @param index the position of removed language in preferred language list. 1027 * @returns Returns a boolean represent whether removed success. 1028 * @since 8 1029 * @deprecated since 9 1030 * @useinstead ohos.System.removePreferredLanguage 1031 */ 1032export function removePreferredLanguage(index: number): boolean; 1033 1034/** 1035 * Access the system preferred language list. 1036 * 1037 * @syscap SystemCapability.Global.I18n 1038 * @returns Returns a string Array represent the preferred language list. 1039 * @since 8 1040 * @deprecated since 9 1041 * @useinstead ohos.System.getPreferredLanguageList 1042 */ 1043export function getPreferredLanguageList(): Array<string>; 1044 1045/** 1046 * Get the first preferred language of system. 1047 * 1048 * @syscap SystemCapability.Global.I18n 1049 * @returns Returns a string represent the first preferred language of system. 1050 * @since 8 1051 * @deprecated since 9 1052 * @useinstead ohos.System.getFirstPreferredLanguage 1053 */ 1054export function getFirstPreferredLanguage(): string; 1055 1056/** 1057 * Get the default TimeZone object or the TimeZone object corresponds to zoneID. 1058 * 1059 * @syscap SystemCapability.Global.I18n 1060 * @param zoneID TimeZone ID used to create TimeZone Object. 1061 * @returns Returns a TimeZone object corresponds to zoneID. 1062 * @since 7 1063 */ 1064export function getTimeZone(zoneID?: string): TimeZone; 1065 1066/** 1067 * Provides the API for accessing TimeZone name, rawOffset and offset information. 1068 * 1069 * @syscap SystemCapability.Global.I18n 1070 * @since 7 1071 */ 1072export class TimeZone { 1073 /** 1074 * Get the id of the TimeZone object. 1075 * 1076 * @syscap SystemCapability.Global.I18n 1077 * @returns Returns a string represents the timezone id. 1078 * @since 7 1079 */ 1080 getID(): string; 1081 1082 /** 1083 * Get the displayName of the TimeZone Object under the locale. 1084 * 1085 * @syscap SystemCapability.Global.I18n 1086 * @param locale the locale tag use to display timezone object's name. 1087 * @param isDST wether consider daylight saving time when display timezone object's name. 1088 * @returns Returns a string represents the display name. 1089 * @since 7 1090 */ 1091 getDisplayName(locale?: string, isDST?: boolean): string; 1092 1093 /** 1094 * Get the raw offset of the TimeZone object. 1095 * 1096 * @syscap SystemCapability.Global.I18n 1097 * @returns Returns a number represents the raw offset. 1098 * @since 7 1099 */ 1100 getRawOffset(): number; 1101 1102 /** 1103 * Get the offset of the TimeZone object. 1104 * 1105 * @syscap SystemCapability.Global.I18n 1106 * @param date Indicates a date use to compute offset. 1107 * @returns Returns a number represents the offset with date. 1108 * @since 7 1109 */ 1110 getOffset(date?: number): number; 1111 1112 /** 1113 * Get available TimeZone ID list. 1114 * 1115 * @syscap SystemCapability.Global.I18n 1116 * @returns Returns a string array represents the available TimeZone ID list. 1117 * @since 9 1118 */ 1119 static getAvailableIDs(): Array<string>; 1120 1121 /** 1122 * Get available Zone City ID list. 1123 * 1124 * @syscap SystemCapability.Global.I18n 1125 * @returns Returns a string array represents the available Zone City ID list. 1126 * @since 9 1127 */ 1128 static getAvailableZoneCityIDs(): Array<string>; 1129 1130 /** 1131 * Get City display name in a certain locale. 1132 * 1133 * @syscap SystemCapability.Global.I18n 1134 * @param cityID Zone City ID. 1135 * @param locale locale used to display city name. 1136 * @returns Returns a string represents the display name of City in locale. 1137 * @since 9 1138 */ 1139 static getCityDisplayName(cityID: string, locale: string): string; 1140 1141 /** 1142 * Get TimeZone Object from city ID. 1143 * 1144 * @syscap SystemCapability.Global.I18n 1145 * @param cityID Zone City ID. 1146 * @returns Returns a TimeZone Object from city ID. 1147 * @since 9 1148 */ 1149 static getTimezoneFromCity(cityID: string): TimeZone; 1150} 1151 1152/** 1153 * Provides the API for transliterate text from one format to another. 1154 * 1155 * @syscap SystemCapability.Global.I18n 1156 * @since 9 1157 */ 1158export class Transliterator { 1159 /** 1160 * Get a string array of all available transliterator ids. 1161 * 1162 * @syscap SystemCapability.Global.I18n 1163 * @returns Returns a string array of all available transliterator ids. 1164 * @since 9 1165 */ 1166 static getAvailableIDs(): string[]; 1167 1168 /** 1169 * Get a Transliterator that is specified by id name. 1170 * 1171 * @syscap SystemCapability.Global.I18n 1172 * @param id specified the type of Transliterator. id is formed by source and dest. Transliterator will transliterate 1173 * the input string from source format to the dest format. For example, a Simplified Chinese to Latn 1174 * Transliterator will transform the text written in Chinese to Latn characters. 1175 * @returns Returns Transliterator that is specified by id name. 1176 * @since 9 1177 */ 1178 static getInstance(id: string): Transliterator; 1179 1180 /** 1181 * Transform the input text. 1182 * 1183 * @syscap SystemCapability.Global.I18n 1184 * @param id text to be transliterated. 1185 * @returns Returns the output text that is transliterated from source format to the dest format. 1186 * @since 9 1187 */ 1188 transform(text: string): string; 1189} 1190} 1191export default i18n; 1192