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 */ 15 16import { BusinessError } from './@ohos.base'; 17 18/** 19 * Provides international settings related APIs. 20 * 21 * @namespace i18n 22 * @syscap SystemCapability.Global.I18n 23 * @since 7 24 */ 25declare namespace i18n { 26 /** 27 * Obtains the country or region name localized for display on a given locale. 28 * 29 * @param { string } country - The locale whose country or region name will be displayed. 30 * @param { string } locale - The locale used to display the country or region. 31 * @param { boolean } [sentenceCase] - Specifies whether the country or region name is displayed in sentence case. 32 * @returns { string } the country or region name localized for display on a given locale. 33 * @syscap SystemCapability.Global.I18n 34 * @since 7 35 * @deprecated since 9 36 * @useinstead ohos.System.getDisplayCountry 37 */ 38 export function getDisplayCountry(country: string, locale: string, sentenceCase?: boolean): string; 39 40 /** 41 * Obtains the language name localized for display on a given locale. 42 * 43 * @param { string } language - The locale whose language name will be displayed. 44 * @param { string } locale - The locale used to display the language. 45 * @param { boolean } [sentenceCase] - Specifies whether the language name is displayed in sentence case. 46 * @returns { string } the language name localized for display on a given locale. 47 * @syscap SystemCapability.Global.I18n 48 * @since 7 49 * @deprecated since 9 50 * @useinstead ohos.System.getDisplayLanguage 51 */ 52 export function getDisplayLanguage(language: string, locale: string, sentenceCase?: boolean): string; 53 54 /** 55 * Obtains the language currently used by the system. 56 * 57 * @returns { string } the language currently used by the system. 58 * @syscap SystemCapability.Global.I18n 59 * @since 7 60 * @deprecated since 9 61 * @useinstead ohos.System.getSystemLanguage 62 */ 63 export function getSystemLanguage(): string; 64 65 /** 66 * Obtains the region currently used by the system. 67 * 68 * @returns { string } the region currently used by the system. 69 * @syscap SystemCapability.Global.I18n 70 * @since 7 71 * @deprecated since 9 72 * @useinstead ohos.System.getSystemRegion 73 */ 74 export function getSystemRegion(): string; 75 76 /** 77 * Obtains the locale currently used by the system. 78 * 79 * @returns { string } the locale currently used by the system. 80 * @syscap SystemCapability.Global.I18n 81 * @since 7 82 * @deprecated since 9 83 * @useinstead ohos.System.getSystemLocale 84 */ 85 export function getSystemLocale(): string; 86 87 /** 88 * Provides system functions. 89 * 90 * @syscap SystemCapability.Global.I18n 91 * @since 9 92 */ 93 /** 94 * Provides system functions. 95 * 96 * @syscap SystemCapability.Global.I18n 97 * @crossplatform 98 * @since 10 99 */ 100 export class System { 101 /** 102 * Obtains the country or region name localized for display on a given locale. 103 * 104 * @param { string } country - The locale whose country or region name will be displayed. 105 * @param { string } locale - The locale used to display the country or region. 106 * @param { boolean } [sentenceCase] - Specifies whether the country or region name is displayed in sentence case. 107 * @returns { string } the country or region name localized for display on a given locale. 108 * @throws { BusinessError } 401 - check param failed 109 * @throws { BusinessError } 890001 - param value not valid 110 * @syscap SystemCapability.Global.I18n 111 * @since 9 112 */ 113 /** 114 * Obtains the country or region name localized for display on a given locale. 115 * 116 * @param { string } country - The locale whose country or region name will be displayed. 117 * @param { string } locale - The locale used to display the country or region. 118 * @param { boolean } [sentenceCase] - Specifies whether the country or region name is displayed in sentence case. 119 * @returns { string } the country or region name localized for display on a given locale. 120 * @throws { BusinessError } 401 - check param failed 121 * @throws { BusinessError } 890001 - param value not valid 122 * @syscap SystemCapability.Global.I18n 123 * @crossplatform 124 * @since 10 125 */ 126 static getDisplayCountry(country: string, locale: string, sentenceCase?: boolean): string; 127 128 /** 129 * Obtains the language name localized for display on a given locale. 130 * 131 * @param { string } language - The locale whose language name will be displayed. 132 * @param { string } locale - The locale used to display the language. 133 * @param { boolean } [sentenceCase] - Specifies whether the language name is displayed in sentence case. 134 * @returns { string } the language name localized for display on a given locale. 135 * @throws { BusinessError } 401 - check param failed 136 * @throws { BusinessError } 890001 - param value not valid 137 * @syscap SystemCapability.Global.I18n 138 * @since 9 139 */ 140 /** 141 * Obtains the language name localized for display on a given locale. 142 * 143 * @param { string } language - The locale whose language name will be displayed. 144 * @param { string } locale - The locale used to display the language. 145 * @param { boolean } [sentenceCase] - Specifies whether the language name is displayed in sentence case. 146 * @returns { string } the language name localized for display on a given locale. 147 * @throws { BusinessError } 401 - check param failed 148 * @throws { BusinessError } 890001 - param value not valid 149 * @syscap SystemCapability.Global.I18n 150 * @crossplatform 151 * @since 10 152 */ 153 static getDisplayLanguage(language: string, locale: string, sentenceCase?: boolean): string; 154 155 /** 156 * Obtains all languages supported by the system. 157 * 158 * @returns { Array<string> } all languages supported by the system. 159 * @syscap SystemCapability.Global.I18n 160 * @since 9 161 */ 162 static getSystemLanguages(): Array<string>; 163 164 /** 165 * Obtains all regions supported by the system in the language. 166 * 167 * @param { string } language - The language used to get the list of regions. 168 * @returns { Array<string> } all countries or regions supported by the system in the language. 169 * @throws { BusinessError } 401 - check param failed 170 * @throws { BusinessError } 890001 - param value not valid 171 * @syscap SystemCapability.Global.I18n 172 * @since 9 173 */ 174 static getSystemCountries(language: string): Array<string>; 175 176 /** 177 * Determine whether the current language or region is recommended. 178 * 179 * @param { string } language - The language code. 180 * @param { string } [region] - The region code. 181 * @returns { boolean } whether the current language or region is recommended. 182 * @throws { BusinessError } 401 - check param failed 183 * @throws { BusinessError } 890001 - param value not valid 184 * @syscap SystemCapability.Global.I18n 185 * @since 9 186 */ 187 static isSuggested(language: string, region?: string): boolean; 188 189 /** 190 * Obtains the language currently used by the system. 191 * 192 * @returns { string } the language currently used by the system. 193 * @syscap SystemCapability.Global.I18n 194 * @since 9 195 */ 196 /** 197 * Obtains the language currently used by the system. 198 * 199 * @returns { string } the language currently used by the system. 200 * @syscap SystemCapability.Global.I18n 201 * @crossplatform 202 * @since 10 203 */ 204 static getSystemLanguage(): string; 205 206 /** 207 * Set the language currently used by the system. 208 * 209 * @permission ohos.permission.UPDATE_CONFIGURATION 210 * @param { string } language - The language to be used. 211 * @throws { BusinessError } 201 - the application does not have permission to call this function 212 * @throws { BusinessError } 401 - check param failed 213 * @throws { BusinessError } 890001 - param value not valid 214 * @syscap SystemCapability.Global.I18n 215 * @systemapi Hide this for inner system use. 216 * @since 9 217 */ 218 static setSystemLanguage(language: string): void; 219 220 /** 221 * Obtains the region currently used by the system. 222 * 223 * @returns { string } the region currently used by the system. 224 * @syscap SystemCapability.Global.I18n 225 * @since 9 226 */ 227 /** 228 * Obtains the region currently used by the system. 229 * 230 * @returns { string } the region currently used by the system. 231 * @syscap SystemCapability.Global.I18n 232 * @crossplatform 233 * @since 10 234 */ 235 static getSystemRegion(): string; 236 237 /** 238 * Set the region currently used by the system. 239 * 240 * @permission ohos.permission.UPDATE_CONFIGURATION 241 * @param { string } region - The region to be used. 242 * @throws { BusinessError } 201 - the application does not have permission to call this function 243 * @throws { BusinessError } 401 - check param failed 244 * @throws { BusinessError } 890001 - param value not valid 245 * @syscap SystemCapability.Global.I18n 246 * @systemapi Hide this for inner system use. 247 * @since 9 248 */ 249 static setSystemRegion(region: string): void; 250 251 /** 252 * Obtains the locale currently used by the system. 253 * 254 * @returns { string } the locale currently used by the system. 255 * @syscap SystemCapability.Global.I18n 256 * @since 9 257 */ 258 /** 259 * Obtains the locale currently used by the system. 260 * 261 * @returns { string } the locale currently used by the system. 262 * @syscap SystemCapability.Global.I18n 263 * @crossplatform 264 * @since 10 265 */ 266 static getSystemLocale(): string; 267 268 /** 269 * Set the locale currently used by the system. 270 * 271 * @permission ohos.permission.UPDATE_CONFIGURATION 272 * @param { string } locale - The locale to be used. 273 * @throws { BusinessError } 201 - the application does not have permission to call this function 274 * @throws { BusinessError } 401 - check param failed 275 * @throws { BusinessError } 890001 - param value not valid 276 * @syscap SystemCapability.Global.I18n 277 * @systemapi Hide this for inner system use. 278 * @since 9 279 */ 280 static setSystemLocale(locale: string): void; 281 282 /** 283 * Check out whether system is 24-hour system. 284 * 285 * @returns { boolean } a boolean represent whether system is 24-hour system. 286 * @syscap SystemCapability.Global.I18n 287 * @since 9 288 */ 289 /** 290 * Check out whether system is 24-hour system. 291 * 292 * @returns { boolean } a boolean represent whether system is 24-hour system. 293 * @syscap SystemCapability.Global.I18n 294 * @crossplatform 295 * @since 10 296 */ 297 static is24HourClock(): boolean; 298 299 /** 300 * Set 24-hour system. 301 * 302 * @permission ohos.permission.UPDATE_CONFIGURATION 303 * @param { boolean } option - represent the boolean to be set. 304 * @throws { BusinessError } 201 - the application does not have permission to call this function 305 * @throws { BusinessError } 401 - check param failed 306 * @throws { BusinessError } 890001 - param value not valid 307 * @syscap SystemCapability.Global.I18n 308 * @systemapi Hide this for inner system use. 309 * @since 9 310 */ 311 static set24HourClock(option: boolean): void; 312 313 /** 314 * Add one language to preferred language List. 315 * 316 * @permission ohos.permission.UPDATE_CONFIGURATION 317 * @param { string } language - the language to be added. 318 * @param { number } [index] - the position of preferred language list to be inserted. 319 * @throws { BusinessError } 201 - the application does not have permission to call this function 320 * @throws { BusinessError } 401 - check param failed 321 * @throws { BusinessError } 890001 - param value not valid 322 * @syscap SystemCapability.Global.I18n 323 * @systemapi Hide this for inner system use. 324 * @since 9 325 */ 326 static addPreferredLanguage(language: string, index?: number): void; 327 328 /** 329 * Remove one language from preferred language list. 330 * 331 * @permission ohos.permission.UPDATE_CONFIGURATION 332 * @param { number } index - the position of removed language in preferred language list. 333 * @throws { BusinessError } 201 - the application does not have permission to call this function 334 * @throws { BusinessError } 401 - check param failed 335 * @throws { BusinessError } 890001 - param value not valid 336 * @syscap SystemCapability.Global.I18n 337 * @systemapi Hide this for inner system use. 338 * @since 9 339 */ 340 static removePreferredLanguage(index: number): void; 341 342 /** 343 * Access the system preferred language list. 344 * 345 * @returns { Array<string> } a string Array represent the preferred language list. 346 * @syscap SystemCapability.Global.I18n 347 * @since 9 348 */ 349 static getPreferredLanguageList(): Array<string>; 350 351 /** 352 * Get the first preferred language of system. 353 * 354 * @returns { string } a string represent the first preferred language of system. 355 * @syscap SystemCapability.Global.I18n 356 * @since 9 357 */ 358 static getFirstPreferredLanguage(): string; 359 360 /** 361 * Get the preferred language of App. 362 * 363 * @returns { string } a string represent the preferred language of App. 364 * @syscap SystemCapability.Global.I18n 365 * @since 9 366 */ 367 static getAppPreferredLanguage(): string; 368 369 /** 370 * Set whether to use local digit. 371 * 372 * @permission ohos.permission.UPDATE_CONFIGURATION 373 * @param { boolean } flag - a boolean variable represents whether to use local digit 374 * @throws { BusinessError } 201 - the application does not have permission to call this function 375 * @throws { BusinessError } 401 - check param failed 376 * @throws { BusinessError } 890001 - param value not valid 377 * @syscap SystemCapability.Global.I18n 378 * @systemapi Hide this for inner system use. 379 * @since 9 380 */ 381 static setUsingLocalDigit(flag: boolean): void; 382 383 /** 384 * Get whether to use local digit. 385 * 386 * @returns { boolean } a boolean represents whether to use local digit. 387 * @syscap SystemCapability.Global.I18n 388 * @since 9 389 */ 390 static getUsingLocalDigit(): boolean; 391 } 392 393 /** 394 * Provides util functions. 395 * 396 * @interface Util 397 * @syscap SystemCapability.Global.I18n 398 * @since 8 399 * @deprecated since 9 400 * @useinstead ohos.i18n/i18n.I18NUtil 401 */ 402 export interface Util { 403 /** 404 * Convert from unit to unit and format according to the locale. 405 * 406 * @param { UnitInfo } fromUnit - Information of the unit to be converted. 407 * @param { UnitInfo } toUnit - Information about the unit to be converted to. 408 * @param { number } value - Indicates the number to be formatted. 409 * @param { string } locale - The locale to be used. 410 * @param { string } [style] - The style of format. 411 * @returns { string } converted number and unit. 412 * @syscap SystemCapability.Global.I18n 413 * @since 8 414 * @deprecated since 9 415 * @useinstead ohos.i18n/i18n.I18NUtil#unitConvert 416 */ 417 unitConvert(fromUnit: UnitInfo, toUnit: UnitInfo, value: number, locale: string, style?: string): string; 418 } 419 420 /** 421 * Provides util functions. 422 * 423 * @syscap SystemCapability.Global.I18n 424 * @since 9 425 */ 426 /** 427 * Provides util functions. 428 * 429 * @syscap SystemCapability.Global.I18n 430 * @crossplatform 431 * @since 10 432 */ 433 export class I18NUtil { 434 /** 435 * Convert from unit to unit and format according to the locale. 436 * 437 * @param { UnitInfo } fromUnit - Information of the unit to be converted. 438 * @param { UnitInfo } toUnit - Information about the unit to be converted to. 439 * @param { number } value - Indicates the number to be formatted. 440 * @param { string } locale - The locale to be used. 441 * @param { string } [style] - The style of format. 442 * @returns { string } converted number and unit. 443 * @syscap SystemCapability.Global.I18n 444 * @since 9 445 */ 446 static unitConvert(fromUnit: UnitInfo, toUnit: UnitInfo, value: number, locale: string, style?: string): string; 447 448 /** 449 * Get the order of year, month, day in the specified locale. Year, month, day are separated by '-'. 450 * 'y' stands for year, 'L' stands for month, d stands for day. 451 * 452 * @param { string } locale - Information of the locale 453 * @returns { string } the string of 'y', 'L', 'd' joined by '-'. 454 * @syscap SystemCapability.Global.I18n 455 * @since 9 456 */ 457 /** 458 * Get the order of year, month, day in the specified locale. Year, month, day are separated by '-'. 459 * 'y' stands for year, 'L' stands for month, d stands for day. 460 * 461 * @param { string } locale - Information of the locale 462 * @returns { string } the string of 'y', 'L', 'd' joined by '-'. 463 * @syscap SystemCapability.Global.I18n 464 * @crossplatform 465 * @since 10 466 */ 467 static getDateOrder(locale: string): string; 468 } 469 470 /** 471 * Provides the options of unit. 472 * 473 * @interface UnitInfo 474 * @syscap SystemCapability.Global.I18n 475 * @since 8 476 */ 477 export interface UnitInfo { 478 /** 479 * Unit name. 480 * 481 * @syscap SystemCapability.Global.I18n 482 * @since 8 483 */ 484 unit: string; 485 486 /** 487 * The measurement system of the unit. 488 * 489 * @syscap SystemCapability.Global.I18n 490 * @since 8 491 */ 492 measureSystem: string; 493 } 494 495 /** 496 * Provides the options of PhoneNumberFormat. 497 * 498 * @interface PhoneNumberFormatOptions 499 * @syscap SystemCapability.Global.I18n 500 * @since 8 501 */ 502 export interface PhoneNumberFormatOptions { 503 /** 504 * Indicates the type to format phone number. 505 * 506 * @type { string } 507 * @syscap SystemCapability.Global.I18n 508 * @since 8 509 */ 510 /** 511 * Indicates the type to format phone number. 512 * 513 * @type { ?string } 514 * @syscap SystemCapability.Global.I18n 515 * @since 9 516 */ 517 type?: string; 518 } 519 520 /** 521 * Provides the API for formatting phone number strings 522 * 523 * @syscap SystemCapability.Global.I18n 524 * @since 8 525 */ 526 export class PhoneNumberFormat { 527 /** 528 * A constructor used to create a PhoneNumberFormat object. 529 * 530 * @param { string } country - Indicates a character string containing the country information for the PhoneNumberFormat object. 531 * @param { PhoneNumberFormatOptions } [options] - format types: "E164", "RFC3966", "INTERNATIONAL", "NATIONAL". 532 * @syscap SystemCapability.Global.I18n 533 * @since 8 534 */ 535 constructor(country: string, options?: PhoneNumberFormatOptions); 536 537 /** 538 * Judge whether phone number is valid. 539 * 540 * @param { string } number - Indicates the input phone number. 541 * @returns { boolean } a boolean indicates whether the input phone number is valid. 542 * @syscap SystemCapability.Global.I18n 543 * @since 8 544 */ 545 isValidNumber(number: string): boolean; 546 547 /** 548 * Obtains the formatted phone number strings of number. 549 * 550 * @param { string } number - Indicates the input phone number to be formatted. 551 * @returns { string } the formatted phone number. 552 * @syscap SystemCapability.Global.I18n 553 * @since 8 554 */ 555 format(number: string): string; 556 557 /** 558 * Determine the location by phone number, and return it according to the specified regional language. 559 * 560 * @param { string } number - input phone number. 561 * @param { string } locale - locale ID. 562 * @returns { string } a string represents phone number's location. 563 * @syscap SystemCapability.Global.I18n 564 * @since 9 565 */ 566 getLocationName(number: string, locale: string): string; 567 } 568 569 /** 570 * Get a Calendar instance specified by locale and type. 571 * 572 * @param { string } locale - The locale used to get calendar. 573 * @param { string } [type] - If type is not specified, get locale's default Calendar, else get the specified type of Calendar. 574 * such as buddhist, chinese, coptic, ethiopic, hebrew, gregory, indian, islamic_civil, islamic_tbla, islamic_umalqura, 575 * japanese, persian. 576 * @returns { Calendar } Calendar object 577 * @syscap SystemCapability.Global.I18n 578 * @since 8 579 */ 580 /** 581 * Get a Calendar instance specified by locale and type. 582 * 583 * @param { string } locale - The locale used to get calendar. 584 * @param { string } [type] - If type is not specified, get locale's default Calendar, else get the specified type of Calendar. 585 * such as buddhist, chinese, coptic, ethiopic, hebrew, gregory, indian, islamic_civil, islamic_tbla, islamic_umalqura, 586 * japanese, persian. 587 * @returns { Calendar } Calendar object 588 * @syscap SystemCapability.Global.I18n 589 * @crossplatform 590 * @since 10 591 */ 592 export function getCalendar(locale: string, type?: string): Calendar; 593 594 export class Calendar { 595 /** 596 * set the date. 597 * 598 * @param { Date } date - Date object used to set the time and date. 599 * @syscap SystemCapability.Global.I18n 600 * @since 8 601 */ 602 /** 603 * set the date. 604 * 605 * @param { Date } date - Date object used to set the time and date. 606 * @syscap SystemCapability.Global.I18n 607 * @crossplatform 608 * @since 10 609 */ 610 setTime(date: Date): void; 611 612 /** 613 * set the time. 614 * 615 * @param { number } time - Indicates the elapsed milliseconds from 1970.1.1 00:00:00 GMT. 616 * @syscap SystemCapability.Global.I18n 617 * @since 8 618 */ 619 /** 620 * set the time. 621 * 622 * @param { number } time - Indicates the elapsed milliseconds from 1970.1.1 00:00:00 GMT. 623 * @syscap SystemCapability.Global.I18n 624 * @crossplatform 625 * @since 10 626 */ 627 setTime(time: number): void; 628 629 /** 630 * Set the time 631 * 632 * @param { number } year - The year field of the calendar, ranges from 0 to 9999. 633 * @param { number } month - The month field of the calendar, ranges from 0 to 11. 634 * @param { number } date - The day field of the calendar, ranges from 1 to 31. 635 * @param { number } hour - The hour field of the calendar, ranges from 0 to 23. 636 * @param { number } minute - The minute field of the calendar, ranges from 0 to 59. 637 * @param { number } second - the second field of the calendar, ranges from 0 to 59. 638 * @syscap SystemCapability.Global.I18n 639 * @since 8 640 */ 641 /** 642 * Set the time 643 * 644 * @param { number } year - The year field of the calendar, ranges from 0 to 9999. 645 * @param { number } month - The month field of the calendar, ranges from 0 to 11. 646 * @param { number } date - The day field of the calendar, ranges from 1 to 31. 647 * @param { number } hour - The hour field of the calendar, ranges from 0 to 23. 648 * @param { number } minute - The minute field of the calendar, ranges from 0 to 59. 649 * @param { number } second - the second field of the calendar, ranges from 0 to 59. 650 * @syscap SystemCapability.Global.I18n 651 * @crossplatform 652 * @since 10 653 */ 654 set(year: number, month: number, date: number, hour?: number, minute?: number, second?: number): void; 655 656 /** 657 * Set the timezone of this calendar. 658 * 659 * @param { string } timezone - The id of a timezone. 660 * @syscap SystemCapability.Global.I18n 661 * @since 8 662 */ 663 /** 664 * Set the timezone of this calendar. 665 * 666 * @param { string } timezone - The id of a timezone. 667 * @syscap SystemCapability.Global.I18n 668 * @crossplatform 669 * @since 10 670 */ 671 setTimeZone(timezone: string): void; 672 673 /** 674 * Get the timezone id of this calendar instance. 675 * 676 * @returns { string } the timezone id of this calendar. 677 * @syscap SystemCapability.Global.I18n 678 * @since 8 679 */ 680 /** 681 * Get the timezone id of this calendar instance. 682 * 683 * @returns { string } the timezone id of this calendar. 684 * @syscap SystemCapability.Global.I18n 685 * @crossplatform 686 * @since 10 687 */ 688 getTimeZone(): string; 689 690 /** 691 * Get the start day of a week. 1 indicates Sunday, 7 indicates Saturday. 692 * 693 * @returns { number } start day of a week. 694 * @syscap SystemCapability.Global.I18n 695 * @since 8 696 */ 697 /** 698 * Get the start day of a week. 1 indicates Sunday, 7 indicates Saturday. 699 * 700 * @returns { number } start day of a week. 701 * @syscap SystemCapability.Global.I18n 702 * @crossplatform 703 * @since 10 704 */ 705 getFirstDayOfWeek(): number; 706 707 /** 708 * Set the start day of a week. 1 indicates Sunday, 7 indicates Saturday. 709 * 710 * @param { number } value - Indicates the start day of a week. 1 indicates Sunday, 7 indicates Saturday. 711 * @syscap SystemCapability.Global.I18n 712 * @since 8 713 */ 714 /** 715 * Set the start day of a week. 1 indicates Sunday, 7 indicates Saturday. 716 * 717 * @param { number } value - Indicates the start day of a week. 1 indicates Sunday, 7 indicates Saturday. 718 * @syscap SystemCapability.Global.I18n 719 * @crossplatform 720 * @since 10 721 */ 722 setFirstDayOfWeek(value: number): void; 723 724 /** 725 * Get the minimal days of a week, which is needed for the first day of a year. 726 * 727 * @returns { number } the minimal days of a week. 728 * @syscap SystemCapability.Global.I18n 729 * @since 8 730 */ 731 /** 732 * Get the minimal days of a week, which is needed for the first day of a year. 733 * 734 * @returns { number } the minimal days of a week. 735 * @syscap SystemCapability.Global.I18n 736 * @crossplatform 737 * @since 10 738 */ 739 getMinimalDaysInFirstWeek(): number; 740 741 /** 742 * Set the minimal days of a week, which is needed for the first week of a year. 743 * 744 * @param { number } value - The value to be set. 745 * @syscap SystemCapability.Global.I18n 746 * @since 8 747 */ 748 /** 749 * Set the minimal days of a week, which is needed for the first week of a year. 750 * 751 * @param { number } value - The value to be set. 752 * @syscap SystemCapability.Global.I18n 753 * @crossplatform 754 * @since 10 755 */ 756 setMinimalDaysInFirstWeek(value: number): void; 757 758 /** 759 * Get the associated value with the field. 760 * 761 * @param { string } field - Field values such as era, year, month, week_of_year, week_of_month, date, day_of_year, day_of_week 762 * day_of_week_in_month, hour, hour_of_day, minute, second, millisecond, zone_offset, dst_offset, year_woy, 763 * dow_local, extended_year, julian_day, milliseconds_in_day, is_leap_month. 764 * @returns { number } the associated value. 765 * @syscap SystemCapability.Global.I18n 766 * @since 8 767 */ 768 /** 769 * Get the associated value with the field. 770 * 771 * @param { string } field - Field values such as era, year, month, week_of_year, week_of_month, date, day_of_year, day_of_week 772 * day_of_week_in_month, hour, hour_of_day, minute, second, millisecond, zone_offset, dst_offset, year_woy, 773 * dow_local, extended_year, julian_day, milliseconds_in_day, is_leap_month. 774 * @returns { number } the associated value. 775 * @syscap SystemCapability.Global.I18n 776 * @crossplatform 777 * @since 10 778 */ 779 get(field: string): number; 780 781 /** 782 * Get calendar's name localized for display in the given locale. 783 * 784 * @param { string } locale - Locale used to get the localized name for this calendar. 785 * @returns { string } the localized name of this calendar. 786 * @syscap SystemCapability.Global.I18n 787 * @since 8 788 */ 789 getDisplayName(locale: string): string; 790 791 /** 792 * Returns true if the given date is a weekend day. If the date is not given, 793 * the date object of this calendar is used. 794 * 795 * @param { Date } [date] - Date object whose attribute is desired. 796 * @returns { boolean } whether the date is a weekend day. 797 * @syscap SystemCapability.Global.I18n 798 * @since 8 799 */ 800 /** 801 * Returns true if the given date is a weekend day. If the date is not given, 802 * the date object of this calendar is used. 803 * 804 * @param { Date } [date] - Date object whose attribute is desired. 805 * @returns { boolean } whether the date is a weekend day. 806 * @syscap SystemCapability.Global.I18n 807 * @crossplatform 808 * @since 10 809 */ 810 isWeekend(date?: Date): boolean; 811 } 812 813 /** 814 * Judge whether the locale is RTL locale. 815 * 816 * @param { string } locale - The locale to be used. 817 * @returns { boolean } true representing the locale is an RTL locale 818 * @syscap SystemCapability.Global.I18n 819 * @since 7 820 */ 821 /** 822 * Judge whether the locale is RTL locale. 823 * 824 * @param { string } locale - The locale to be used. 825 * @returns { boolean } true representing the locale is an RTL locale 826 * @syscap SystemCapability.Global.I18n 827 * @crossplatform 828 * @since 10 829 */ 830 export function isRTL(locale: string): boolean; 831 832 /** 833 * Obtains a BreakIterator object for finding the location of break point in text. 834 * 835 * @param { string } locale - the returned BreakIterator will adapt the rule, specified by the locale, to break text. 836 * @returns { BreakIterator } a newly constructed BreakIterator object. 837 * @syscap SystemCapability.Global.I18n 838 * @since 8 839 */ 840 export function getLineInstance(locale: string): BreakIterator; 841 842 /** 843 * The BreakIterator class is used for finding the location of break point in text. 844 * 845 * @syscap SystemCapability.Global.I18n 846 * @since 8 847 */ 848 export class BreakIterator { 849 /** 850 * Obtains the current position of the BreakIterator instance. 851 * 852 * @returns { number } the current position of the BreakIterator instance. 853 * @syscap SystemCapability.Global.I18n 854 * @since 8 855 */ 856 current(): number; 857 858 /** 859 * Set the BreakIterator's position to the first break point, the first break point is always the beginning of the 860 * processed text. 861 * 862 * @returns { number } the index of the first break point. 863 * @syscap SystemCapability.Global.I18n 864 * @since 8 865 */ 866 first(): number; 867 868 /** 869 * Set the BreakIterator's position to the last break point. the last break point is always the index beyond the 870 * last character of the processed text. 871 * 872 * @returns { number } the index of the last break point. 873 * @syscap SystemCapability.Global.I18n 874 * @since 8 875 */ 876 last(): number; 877 878 /** 879 * Set the BreakIterator's position to the nth break point from the current break point. 880 * 881 * @param { number } [index] - indicates the number of break points to advance. If index is not given, n is treated as 1. 882 * @returns { number } the index of the BreakIterator after moving. If there is not enough break points, returns -1. 883 * @syscap SystemCapability.Global.I18n 884 * @since 8 885 */ 886 next(index?: number): number; 887 888 /** 889 * Set the BreakIterator's position to the break point preceding the current break point. 890 * 891 * @returns { number } the index of the BreakIterator after moving. If there is not enough break points, returns -1. 892 * @syscap SystemCapability.Global.I18n 893 * @since 8 894 */ 895 previous(): number; 896 897 /** 898 * Set the text to be processed. 899 * 900 * @param { string } text - Indicates the text to be processed by the BreakIterator. 901 * @syscap SystemCapability.Global.I18n 902 * @since 8 903 */ 904 setLineBreakText(text: string): void; 905 906 /** 907 * Set the BreakIterator's position to the first break point following the specified offset. 908 * 909 * @param { number } offset 910 * @returns { number } the index of the BreakIterator after moving. If there is not enough break points, returns -1. 911 * @syscap SystemCapability.Global.I18n 912 * @since 8 913 */ 914 following(offset: number): number; 915 916 /** 917 * Obtains the text being processed. 918 * 919 * @returns { string } the text that is processed by the BreakIterator. 920 * @syscap SystemCapability.Global.I18n 921 * @since 8 922 */ 923 getLineBreakText(): string; 924 925 /** 926 * Returns true if the position indicated by the offset is a break point, otherwise false. The BreakIterator's 927 * position will be set to the position indicated by the offset if it returns true, otherwise the BreakIterator 928 * will be moved to the break point following the offset. 929 * 930 * @param { number } offset The offset to be checked. 931 * @returns { boolean } true if the offset is a break point. 932 * @syscap SystemCapability.Global.I18n 933 * @since 8 934 */ 935 isBoundary(offset: number): boolean; 936 } 937 938 /** 939 * Get IndexUtil object. 940 * 941 * @param { string } [locale] - Indicates a character string containing the locale information, including 942 * the language and optionally the script and region, for the NumberFormat object. 943 * @returns { IndexUtil } IndexUtil object. 944 * @syscap SystemCapability.Global.I18n 945 * @since 8 946 */ 947 export function getInstance(locale?: string): IndexUtil; 948 949 /** 950 * Sequence text can be grouped under the specified area, 951 * and grouping index with different lengths can be specified. 952 * 953 * @syscap SystemCapability.Global.I18n 954 * @since 8 955 */ 956 export class IndexUtil { 957 /** 958 * Get a list of labels for use as a UI index 959 * 960 * @returns { Array<string> } a list of labels 961 * @syscap SystemCapability.Global.I18n 962 * @since 8 963 */ 964 getIndexList(): Array<string>; 965 966 /** 967 * Add the index characters from a Locale to the index. 968 * 969 * @param { string } locale - The locale whose index characters are to be added. 970 * @syscap SystemCapability.Global.I18n 971 * @since 8 972 */ 973 addLocale(locale: string): void; 974 975 /** 976 * Get corresponding index of the input text. 977 * 978 * @param { string } text - input text 979 * @returns { string } index of the input text 980 * @syscap SystemCapability.Global.I18n 981 * @since 8 982 */ 983 getIndex(text: string): string; 984 } 985 986 /** 987 * Provides the API for accessing unicode character properties. For example, determine whether a character is a number. 988 * 989 * @syscap SystemCapability.Global.I18n 990 * @since 8 991 * @deprecated since 9 992 * @useinstead Unicode 993 */ 994 export class Character { 995 /** 996 * Determines whether the specified code point is a digit character 997 * 998 * @param { string } char - the character to be tested 999 * @returns { boolean } true if the character is a digit character 1000 * @syscap SystemCapability.Global.I18n 1001 * @since 8 1002 * @deprecated since 9 1003 * @useinstead Unicode.isDigit 1004 */ 1005 isDigit(char: string): boolean; 1006 1007 /** 1008 * Determines if the specified character is a space character or not. 1009 * 1010 * @param { string } char - the character to be tested 1011 * @returns { boolean } true if the character is a space character 1012 * @syscap SystemCapability.Global.I18n 1013 * @since 8 1014 * @deprecated since 9 1015 * @useinstead Unicode.isSpaceChar 1016 */ 1017 isSpaceChar(char: string): boolean; 1018 1019 /** 1020 * Determines if the specified character is a whitespace character 1021 * 1022 * @param { string } char - the character to be tested 1023 * @returns { boolean } true if the character is a whitespace character 1024 * @syscap SystemCapability.Global.I18n 1025 * @since 8 1026 * @deprecated since 9 1027 * @useinstead Unicode.isWhitespace 1028 */ 1029 isWhitespace(char: string): boolean; 1030 1031 /** 1032 * Determines if the specified character is a RTL character or not. 1033 * 1034 * @param { string } char - the character to be tested 1035 * @returns { boolean } true if the character is a RTL character 1036 * @syscap SystemCapability.Global.I18n 1037 * @since 8 1038 * @deprecated since 9 1039 * @useinstead Unicode.isRTL 1040 */ 1041 isRTL(char: string): boolean; 1042 1043 /** 1044 * Determines if the specified character is a Ideographic character or not. 1045 * 1046 * @param { string } char - the character to be tested 1047 * @returns { boolean } true if the character is a Ideographic character 1048 * @syscap SystemCapability.Global.I18n 1049 * @since 8 1050 * @deprecated since 9 1051 * @useinstead Unicode.isIdeograph 1052 */ 1053 isIdeograph(char: string): boolean; 1054 1055 /** 1056 * Determines if the specified character is a Letter or not. 1057 * 1058 * @param { string } char - the character to be tested 1059 * @returns { boolean } true if the character is a Letter 1060 * @syscap SystemCapability.Global.I18n 1061 * @since 8 1062 * @deprecated since 9 1063 * @useinstead Unicode.isLetter 1064 */ 1065 isLetter(char: string): boolean; 1066 1067 /** 1068 * Determines if the specified character is a LowerCase character or not. 1069 * 1070 * @param { string } char - the character to be tested 1071 * @returns { boolean } true if the character is a LowerCase character 1072 * @syscap SystemCapability.Global.I18n 1073 * @since 8 1074 * @deprecated since 9 1075 * @useinstead Unicode.isLowerCase 1076 */ 1077 isLowerCase(char: string): boolean; 1078 1079 /** 1080 * Determines if the specified character is a UpperCase character or not. 1081 * 1082 * @param { string } char - the character to be tested 1083 * @returns { boolean } true if the character is a UpperCase character 1084 * @syscap SystemCapability.Global.I18n 1085 * @since 8 1086 * @deprecated since 9 1087 * @useinstead Unicode.isUpperCase 1088 */ 1089 isUpperCase(char: string): boolean; 1090 1091 /** 1092 * Get the general category value of the specified character. 1093 * 1094 * @param { string } char - the character to be tested 1095 * @returns { string } the general category of the specified character. 1096 * @syscap SystemCapability.Global.I18n 1097 * @since 8 1098 * @deprecated since 9 1099 * @useinstead Unicode.getType 1100 */ 1101 getType(char: string): string; 1102 } 1103 1104 /** 1105 * Provides the API for accessing unicode character properties. For example, determine whether a character is a number. 1106 * 1107 * @syscap SystemCapability.Global.I18n 1108 * @since 9 1109 */ 1110 /** 1111 * Provides the API for accessing unicode character properties. For example, determine whether a character is a number. 1112 * 1113 * @syscap SystemCapability.Global.I18n 1114 * @crossplatform 1115 * @since 10 1116 */ 1117 export class Unicode { 1118 /** 1119 * Determines whether the specified code point is a digit character 1120 * 1121 * @param { string } char - the character to be tested 1122 * @returns { boolean } true if the character is a digit character 1123 * @syscap SystemCapability.Global.I18n 1124 * @since 9 1125 */ 1126 /** 1127 * Determines whether the specified code point is a digit character 1128 * 1129 * @param { string } char - the character to be tested 1130 * @returns { boolean } true if the character is a digit character 1131 * @syscap SystemCapability.Global.I18n 1132 * @crossplatform 1133 * @since 10 1134 */ 1135 static isDigit(char: string): boolean; 1136 1137 /** 1138 * Determines if the specified character is a space character or not. 1139 * 1140 * @param { string } char - the character to be tested 1141 * @returns { boolean } true if the character is a space character 1142 * @syscap SystemCapability.Global.I18n 1143 * @since 9 1144 */ 1145 /** 1146 * Determines if the specified character is a space character or not. 1147 * 1148 * @param { string } char - the character to be tested 1149 * @returns { boolean } true if the character is a space character 1150 * @syscap SystemCapability.Global.I18n 1151 * @crossplatform 1152 * @since 10 1153 */ 1154 static isSpaceChar(char: string): boolean; 1155 1156 /** 1157 * Determines if the specified character is a whitespace character 1158 * 1159 * @param { string } char - the character to be tested 1160 * @returns { boolean } true if the character is a whitespace character 1161 * @syscap SystemCapability.Global.I18n 1162 * @since 9 1163 */ 1164 /** 1165 * Determines if the specified character is a whitespace character 1166 * 1167 * @param { string } char - the character to be tested 1168 * @returns { boolean } true if the character is a whitespace character 1169 * @syscap SystemCapability.Global.I18n 1170 * @crossplatform 1171 * @since 10 1172 */ 1173 static isWhitespace(char: string): boolean; 1174 1175 /** 1176 * Determines if the specified character is a RTL character or not. 1177 * 1178 * @param { string } char - the character to be tested 1179 * @returns { boolean } true if the character is a RTL character 1180 * @syscap SystemCapability.Global.I18n 1181 * @since 9 1182 */ 1183 /** 1184 * Determines if the specified character is a RTL character or not. 1185 * 1186 * @param { string } char - the character to be tested 1187 * @returns { boolean } true if the character is a RTL character 1188 * @syscap SystemCapability.Global.I18n 1189 * @crossplatform 1190 * @since 10 1191 */ 1192 static isRTL(char: string): boolean; 1193 1194 /** 1195 * Determines if the specified character is a Ideographic character or not. 1196 * 1197 * @param { string } char - the character to be tested 1198 * @returns { boolean } true if the character is a Ideographic character 1199 * @syscap SystemCapability.Global.I18n 1200 * @since 9 1201 */ 1202 /** 1203 * Determines if the specified character is a Ideographic character or not. 1204 * 1205 * @param { string } char - the character to be tested 1206 * @returns { boolean } true if the character is a Ideographic character 1207 * @syscap SystemCapability.Global.I18n 1208 * @crossplatform 1209 * @since 10 1210 */ 1211 static isIdeograph(char: string): boolean; 1212 1213 /** 1214 * Determines if the specified character is a Letter or not. 1215 * 1216 * @param { string } char - the character to be tested 1217 * @returns { boolean } true if the character is a Letter 1218 * @syscap SystemCapability.Global.I18n 1219 * @since 9 1220 */ 1221 /** 1222 * Determines if the specified character is a Letter or not. 1223 * 1224 * @param { string } char - the character to be tested 1225 * @returns { boolean } true if the character is a Letter 1226 * @syscap SystemCapability.Global.I18n 1227 * @crossplatform 1228 * @since 10 1229 */ 1230 static isLetter(char: string): boolean; 1231 1232 /** 1233 * Determines if the specified character is a LowerCase character or not. 1234 * 1235 * @param { string } char - the character to be tested 1236 * @returns { boolean } true if the character is a LowerCase character 1237 * @syscap SystemCapability.Global.I18n 1238 * @since 9 1239 */ 1240 /** 1241 * Determines if the specified character is a LowerCase character or not. 1242 * 1243 * @param { string } char - the character to be tested 1244 * @returns { boolean } true if the character is a LowerCase character 1245 * @syscap SystemCapability.Global.I18n 1246 * @crossplatform 1247 * @since 10 1248 */ 1249 static isLowerCase(char: string): boolean; 1250 1251 /** 1252 * Determines if the specified character is a UpperCase character or not. 1253 * 1254 * @param { string } char - the character to be tested 1255 * @returns { boolean } true if the character is a UpperCase character 1256 * @syscap SystemCapability.Global.I18n 1257 * @since 9 1258 */ 1259 /** 1260 * Determines if the specified character is a UpperCase character or not. 1261 * 1262 * @param { string } char - the character to be tested 1263 * @returns { boolean } true if the character is a UpperCase character 1264 * @syscap SystemCapability.Global.I18n 1265 * @crossplatform 1266 * @since 10 1267 */ 1268 static isUpperCase(char: string): boolean; 1269 1270 /** 1271 * Get the general category value of the specified character. 1272 * 1273 * @param { string } char - the character to be tested 1274 * @returns { string } the general category of the specified character. 1275 * @syscap SystemCapability.Global.I18n 1276 * @since 9 1277 */ 1278 /** 1279 * Get the general category value of the specified character. 1280 * 1281 * @param { string } char - the character to be tested 1282 * @returns { string } the general category of the specified character. 1283 * @syscap SystemCapability.Global.I18n 1284 * @crossplatform 1285 * @since 10 1286 */ 1287 static getType(char: string): string; 1288 } 1289 1290 /** 1291 * check out whether system is 24-hour system. 1292 * 1293 * @returns { boolean } a boolean represent whether system is 24-hour system. 1294 * @syscap SystemCapability.Global.I18n 1295 * @since 7 1296 * @deprecated since 9 1297 * @useinstead ohos.i18n/i18n.System#is24HourClock 1298 */ 1299 export function is24HourClock(): boolean; 1300 1301 /** 1302 * set 24-hour system. 1303 * 1304 * @permission ohos.permission.UPDATE_CONFIGURATION 1305 * @param { boolean } option - represent the boolean to be set. 1306 * @returns { boolean } a boolean represent whether setting 24-hour system success. 1307 * @syscap SystemCapability.Global.I18n 1308 * @since 7 1309 * @deprecated since 9 1310 * @useinstead ohos.i18n/i18n.System#set24HourClock 1311 */ 1312 export function set24HourClock(option: boolean): boolean; 1313 1314 /** 1315 * Add one language to preferred language List. 1316 * 1317 * @permission ohos.permission.UPDATE_CONFIGURATION 1318 * @param { string } language - the language to be added. 1319 * @param { number } [index] - the position of preferred language list to be inserted. 1320 * @returns { boolean } a boolean represent whether language added success. 1321 * @syscap SystemCapability.Global.I18n 1322 * @since 8 1323 * @deprecated since 9 1324 * @useinstead ohos.i18n/i18n.System#addPreferredLanguage 1325 */ 1326 export function addPreferredLanguage(language: string, index?: number): boolean; 1327 1328 /** 1329 * Remove one language from preferred language list. 1330 * 1331 * @permission ohos.permission.UPDATE_CONFIGURATION 1332 * @param { number } index - the position of removed language in preferred language list. 1333 * @returns { boolean } a boolean represent whether removed success. 1334 * @syscap SystemCapability.Global.I18n 1335 * @since 8 1336 * @deprecated since 9 1337 * @useinstead ohos.i18n/i18n.System#removePreferredLanguage 1338 */ 1339 export function removePreferredLanguage(index: number): boolean; 1340 1341 /** 1342 * Access the system preferred language list. 1343 * 1344 * @returns { Array<string> } a string Array represent the preferred language list. 1345 * @syscap SystemCapability.Global.I18n 1346 * @since 8 1347 * @deprecated since 9 1348 * @useinstead ohos.i18n/i18n.System#getPreferredLanguageList 1349 */ 1350 export function getPreferredLanguageList(): Array<string>; 1351 1352 /** 1353 * Get the first preferred language of system. 1354 * 1355 * @returns { string } a string represent the first preferred language of system. 1356 * @syscap SystemCapability.Global.I18n 1357 * @since 8 1358 * @deprecated since 9 1359 * @useinstead ohos.i18n/i18n.System#getFirstPreferredLanguage 1360 */ 1361 export function getFirstPreferredLanguage(): string; 1362 1363 /** 1364 * Get the default TimeZone object or the TimeZone object corresponds to zoneID. 1365 * 1366 * @param { string } [zoneID] - TimeZone ID used to create TimeZone Object. 1367 * @returns { TimeZone } a TimeZone object corresponds to zoneID. 1368 * @syscap SystemCapability.Global.I18n 1369 * @since 7 1370 */ 1371 /** 1372 * Get the default TimeZone object or the TimeZone object corresponds to zoneID. 1373 * 1374 * @param { string } [zoneID] - TimeZone ID used to create TimeZone Object. 1375 * @returns { TimeZone } a TimeZone object corresponds to zoneID. 1376 * @syscap SystemCapability.Global.I18n 1377 * @crossplatform 1378 * @since 10 1379 */ 1380 export function getTimeZone(zoneID?: string): TimeZone; 1381 1382 /** 1383 * Provides the API for accessing TimeZone name, rawOffset and offset information. 1384 * 1385 * @syscap SystemCapability.Global.I18n 1386 * @since 7 1387 */ 1388 /** 1389 * Provides the API for accessing TimeZone name, rawOffset and offset information. 1390 * 1391 * @syscap SystemCapability.Global.I18n 1392 * @crossplatform 1393 * @since 10 1394 */ 1395 export class TimeZone { 1396 /** 1397 * Get the id of the TimeZone object. 1398 * 1399 * @returns { string } a string represents the timezone id. 1400 * @syscap SystemCapability.Global.I18n 1401 * @since 7 1402 */ 1403 /** 1404 * Get the id of the TimeZone object. 1405 * 1406 * @returns { string } a string represents the timezone id. 1407 * @syscap SystemCapability.Global.I18n 1408 * @crossplatform 1409 * @since 10 1410 */ 1411 getID(): string; 1412 1413 /** 1414 * Get the displayName of the TimeZone Object under the locale. 1415 * 1416 * @param { string } [locale] - the locale tag use to display timezone object's name. 1417 * @param { boolean } [isDST] - wether consider daylight saving time when display timezone object's name. 1418 * @returns { string } a string represents the display name. 1419 * @syscap SystemCapability.Global.I18n 1420 * @since 7 1421 */ 1422 getDisplayName(locale?: string, isDST?: boolean): string; 1423 1424 /** 1425 * Get the raw offset of the TimeZone object. 1426 * 1427 * @returns { number } a number represents the raw offset. 1428 * @syscap SystemCapability.Global.I18n 1429 * @since 7 1430 */ 1431 /** 1432 * Get the raw offset of the TimeZone object. 1433 * 1434 * @returns { number } a number represents the raw offset. 1435 * @syscap SystemCapability.Global.I18n 1436 * @crossplatform 1437 * @since 10 1438 */ 1439 getRawOffset(): number; 1440 1441 /** 1442 * Get the offset of the TimeZone object. 1443 * 1444 * @param { number } [date] - Indicates a date use to compute offset. 1445 * @returns { number } a number represents the offset with date. 1446 * @syscap SystemCapability.Global.I18n 1447 * @since 7 1448 */ 1449 /** 1450 * Get the offset of the TimeZone object. 1451 * 1452 * @param { number } [date] - Indicates a date use to compute offset. 1453 * @returns { number } a number represents the offset with date. 1454 * @syscap SystemCapability.Global.I18n 1455 * @crossplatform 1456 * @since 10 1457 */ 1458 getOffset(date?: number): number; 1459 1460 /** 1461 * Get available TimeZone ID list. 1462 * 1463 * @returns { Array<string> } a string array represents the available TimeZone ID list. 1464 * @syscap SystemCapability.Global.I18n 1465 * @since 9 1466 */ 1467 /** 1468 * Get available TimeZone ID list. 1469 * 1470 * @returns { Array<string> } a string array represents the available TimeZone ID list. 1471 * @syscap SystemCapability.Global.I18n 1472 * @crossplatform 1473 * @since 10 1474 */ 1475 static getAvailableIDs(): Array<string>; 1476 1477 /** 1478 * Get available Zone City ID list. 1479 * 1480 * @returns { Array<string> } a string array represents the available Zone City ID list. 1481 * @syscap SystemCapability.Global.I18n 1482 * @since 9 1483 */ 1484 static getAvailableZoneCityIDs(): Array<string>; 1485 1486 /** 1487 * Get City display name in a certain locale. 1488 * 1489 * @param { string } cityID - Zone City ID. 1490 * @param { string } locale - locale used to display city name. 1491 * @returns { string } a string represents the display name of City in locale. 1492 * @syscap SystemCapability.Global.I18n 1493 * @since 9 1494 */ 1495 static getCityDisplayName(cityID: string, locale: string): string; 1496 1497 /** 1498 * Get TimeZone Object from city ID. 1499 * 1500 * @param { string } cityID - Zone City ID. 1501 * @returns { TimeZone } a TimeZone Object from city ID. 1502 * @syscap SystemCapability.Global.I18n 1503 * @since 9 1504 */ 1505 static getTimezoneFromCity(cityID: string): TimeZone; 1506 1507 /** 1508 * Get the possible time zones from the specified longitude and latitude. 1509 * 1510 * @param { number } longitude value 1511 * @param { number } latitude value 1512 * @returns { Array<TimeZone> } Returns a TimeZone array from the specified longitude and latitude. 1513 * @throws {BusinessError} 401 - check param failed 1514 * @throws {BusinessError} 890001 - param value not valid 1515 * @syscap SystemCapability.Global.I18n 1516 * @since 10 1517 */ 1518 static getTimezonesByLocation(longitude: number, latitude: number): Array<TimeZone>; 1519 } 1520 1521 /** 1522 * Provides the API for transliterate text from one format to another. 1523 * 1524 * @syscap SystemCapability.Global.I18n 1525 * @since 9 1526 */ 1527 export class Transliterator { 1528 /** 1529 * Get a string array of all available transliterator ids. 1530 * 1531 * @returns { string[] } a string array of all available transliterator ids. 1532 * @syscap SystemCapability.Global.I18n 1533 * @since 9 1534 */ 1535 static getAvailableIDs(): string[]; 1536 1537 /** 1538 * Get a Transliterator that is specified by id name. 1539 * 1540 * @param { string } id - specified the type of Transliterator. id is formed by source and dest. Transliterator will transliterate 1541 * the input string from source format to the dest format. For example, a Simplified Chinese to Latn 1542 * Transliterator will transform the text written in Chinese to Latn characters. 1543 * @returns { Transliterator } Transliterator that is specified by id name. 1544 * @syscap SystemCapability.Global.I18n 1545 * @since 9 1546 */ 1547 static getInstance(id: string): Transliterator; 1548 1549 /** 1550 * Transform the input text. 1551 * 1552 * @param { string } text - text to be transliterated. 1553 * @returns { string } the output text that is transliterated from source format to the dest format. 1554 * @syscap SystemCapability.Global.I18n 1555 * @since 9 1556 */ 1557 transform(text: string): string; 1558 } 1559 1560 /** 1561 * Enumerates the Normalizer modes. 1562 * 1563 * @enum { number } 1564 * @syscap SystemCapability.Global.I18n 1565 * @since 10 1566 */ 1567 export enum NormalizerMode { 1568 /** 1569 * Normalization form C, characters are decomposed and then re-composed by canonical equivalence 1570 * 1571 * @syscap SystemCapability.Global.I18n 1572 * @since 10 1573 */ 1574 NFC = 1, 1575 /** 1576 * Normalization form D, characters are decomposed by canonical equivalence 1577 * 1578 * @syscap SystemCapability.Global.I18n 1579 * @since 10 1580 */ 1581 NFD = 2, 1582 /** 1583 * Normalization form KC, characters are decomposed by compatibility, then re-composed by canonical equivalence 1584 * 1585 * @syscap SystemCapability.Global.I18n 1586 * @since 10 1587 */ 1588 NFKC = 3, 1589 /** 1590 * Normalization form KD, characters are decomposed by compatibility 1591 * 1592 * @syscap SystemCapability.Global.I18n 1593 * @since 10 1594 */ 1595 NFKD = 4 1596 } 1597 1598 /** 1599 * Provides the API for text encoding normalization. 1600 * 1601 * @syscap SystemCapability.Global.I18n 1602 * @since 10 1603 */ 1604 export class Normalizer { 1605 /** 1606 * Get a Normalizer that is specified by normalize mode. 1607 * 1608 * @param { NormalizerMode } mode - specified the mode of Normalizer. 1609 * @returns { Normalizer } Transliterator that is specified by id name. 1610 * @throws { BusinessError } 401 - check param failed 1611 * @syscap SystemCapability.Global.I18n 1612 * @since 10 1613 */ 1614 static getInstance(mode: NormalizerMode): Normalizer; 1615 1616 /** 1617 * Get a normalized string of specified mode. 1618 * 1619 * @param { string } text - text to normalized. 1620 * @returns { string } a normalized string from source. 1621 * @throws { BusinessError } 401 - check param failed 1622 * @syscap SystemCapability.Global.I18n 1623 * @since 10 1624 */ 1625 normalize(text: string): string; 1626 } 1627 1628 /** 1629 * Enumerates the locale suggestion type modes. 1630 * 1631 * @enum { number } 1632 * @syscap SystemCapability.Global.I18n 1633 * @systemapi Hide this for inner system use. 1634 * @since 10 1635 */ 1636 export enum SuggestionType { 1637 /** 1638 * No correlation between language and region. 1639 * 1640 * @syscap SystemCapability.Global.I18n 1641 * @systemapi Hide this for inner system use. 1642 * @since 10 1643 */ 1644 SUGGESTION_TYPE_NONE = 0, 1645 /** 1646 * The language related to the specified region 1647 * 1648 * @syscap SystemCapability.Global.I18n 1649 * @systemapi Hide this for inner system use. 1650 * @since 10 1651 */ 1652 SUGGESTION_TYPE_RELATED = 1, 1653 /** 1654 * The region is SIM card region. 1655 * 1656 * @syscap SystemCapability.Global.I18n 1657 * @systemapi Hide this for inner system use. 1658 * @since 10 1659 */ 1660 SUGGESTION_TYPE_SIM = 2, 1661 } 1662 1663 /** 1664 * Provides the options which is used to sort the locales. 1665 * 1666 * @interface SortOptions 1667 * @syscap SystemCapability.Global.I18n 1668 * @systemapi Hide this for inner system use. 1669 * @since 10 1670 */ 1671 export interface SortOptions { 1672 /** 1673 * Locale code. 1674 * 1675 * @type { ?string } 1676 * @syscap SystemCapability.Global.I18n 1677 * @systemapi Hide this for inner system use. 1678 * @since 10 1679 */ 1680 locale?: string; 1681 1682 /** 1683 * Whether to use local names for sorting 1684 * 1685 * @type { ?boolean } 1686 * @syscap SystemCapability.Global.I18n 1687 * @systemapi Hide this for inner system use. 1688 * @since 10 1689 */ 1690 isUseLocalName?: boolean; 1691 1692 /** 1693 * Whether to put the suggested item at the top 1694 * 1695 * @type { ?boolean } 1696 * @syscap SystemCapability.Global.I18n 1697 * @systemapi Hide this for inner system use. 1698 * @since 10 1699 */ 1700 isSuggestedFirst?: boolean; 1701 } 1702 1703 /** 1704 * Provide information for a language or region 1705 * 1706 * @interface LocaleItem 1707 * @syscap SystemCapability.Global.I18n 1708 * @systemapi Hide this for inner system use. 1709 * @since 10 1710 */ 1711 export interface LocaleItem { 1712 /** 1713 * language or region id. 1714 * 1715 * @type { string } 1716 * @syscap SystemCapability.Global.I18n 1717 * @systemapi Hide this for inner system use. 1718 * @since 10 1719 */ 1720 id: string; 1721 1722 /** 1723 * The suggestion type of the language or region. 1724 * 1725 * @type { SuggestionType } 1726 * @syscap SystemCapability.Global.I18n 1727 * @systemapi Hide this for inner system use. 1728 * @since 10 1729 */ 1730 suggestionType: SuggestionType; 1731 1732 /** 1733 * The display name of the language or region in specified language 1734 * 1735 * @type { string } 1736 * @syscap SystemCapability.Global.I18n 1737 * @systemapi Hide this for inner system use. 1738 * @since 10 1739 */ 1740 displayName: string; 1741 1742 /** 1743 * The display name of the language or region in local language 1744 * @type { ?string } 1745 * @syscap SystemCapability.Global.I18n 1746 * @systemapi Hide this for inner system use. 1747 * @since 10 1748 */ 1749 localName?: string; 1750 } 1751 1752 /** 1753 * Provides the informations of one time zone city. 1754 * 1755 * @interface TimeZoneCityItem 1756 * @syscap SystemCapability.Global.I18n 1757 * @systemapi Hide this for inner system use. 1758 * @since 10 1759 */ 1760 export interface TimeZoneCityItem { 1761 /** 1762 * Time zone id. 1763 * 1764 * @type { string } 1765 * @syscap SystemCapability.Global.I18n 1766 * @systemapi Hide this for inner system use. 1767 * @since 10 1768 */ 1769 zoneId: string; 1770 1771 /** 1772 * City id. 1773 * 1774 * @type { string } 1775 * @syscap SystemCapability.Global.I18n 1776 * @systemapi Hide this for inner system use. 1777 * @since 10 1778 */ 1779 cityId: string; 1780 1781 /** 1782 * The display name of the city. 1783 * 1784 * @type { string } 1785 * @syscap SystemCapability.Global.I18n 1786 * @systemapi Hide this for inner system use. 1787 * @since 10 1788 */ 1789 cityDisplayName: string; 1790 1791 /** 1792 * The time zone offset for the city. 1793 * @type { number } 1794 * @syscap SystemCapability.Global.I18n 1795 * @systemapi Hide this for inner system use. 1796 * @since 10 1797 */ 1798 offset: number; 1799 1800 /** 1801 * The display name of the time zone for the city. 1802 * 1803 * @type { string } 1804 * @syscap SystemCapability.Global.I18n 1805 * @systemapi Hide this for inner system use. 1806 * @since 10 1807 */ 1808 zoneDisplayName: string; 1809 1810 /** 1811 * The time zone raw offset for the city. 1812 * @type { ?number } 1813 * @syscap SystemCapability.Global.I18n 1814 * @systemapi Hide this for inner system use. 1815 * @since 10 1816 */ 1817 rawOffset?: number; 1818 } 1819 1820 /** 1821 * Provide some functions for settings and startup guide to select language or region. 1822 * 1823 * @syscap SystemCapability.Global.I18n 1824 * @systemapi Hide this for inner system use. 1825 * @since 10 1826 */ 1827 export class SystemLocaleManager { 1828 /** 1829 * A constructor used to create a SystemLocaleManager object. 1830 * 1831 * @syscap SystemCapability.Global.I18n 1832 * @systemapi Hide this for inner system use. 1833 * @since 10 1834 */ 1835 constructor(); 1836 1837 /** 1838 * Obtains sorted language array for setting or startup guide app. 1839 * 1840 * @param { Array<string> } languages - The languages whose name will be sorted and displayed. 1841 * @param { SortOptions } options - Sort options for locale item. 1842 * @returns { Array<LocaleItem> } Locale Informations sorted for specified options. 1843 * @throws { BusinessError } 401 - check param failed 1844 * @throws { BusinessError } 890001 - param value not valid 1845 * @syscap SystemCapability.Global.I18n 1846 * @systemapi Hide this for inner system use. 1847 * @since 10 1848 */ 1849 getLanguageInfoArray(languages: Array<string>, options?: SortOptions): Array<LocaleItem>; 1850 1851 /** 1852 * Obtains sorted region array for setting or startup guide app. 1853 * 1854 * @param { Array<string> } regions - The regions whose name will be sorted and displayed. 1855 * @param { SortOptions } options - Sort options for locale item. 1856 * @returns { Array<LocaleItem> } Locale Informations sorted for specified options. 1857 * @throws { BusinessError } 401 - check param failed 1858 * @throws { BusinessError } 890001 - param value not valid 1859 * @syscap SystemCapability.Global.I18n 1860 * @systemapi Hide this for inner system use. 1861 * @since 10 1862 */ 1863 getRegionInfoArray(regions: Array<string>, options?: SortOptions): Array<LocaleItem>; 1864 1865 /** 1866 * Obtains sorted time zone city info array for showing time zone list 1867 * 1868 * @returns { Array<TimeZoneCityItem> } Time zone city information sorted by city name. 1869 * @syscap SystemCapability.Global.I18n 1870 * @systemapi Hide this for inner system use. 1871 * @since 10 1872 */ 1873 static getTimeZoneCityItemArray(): Array<TimeZoneCityItem>; 1874 } 1875} 1876export default i18n; 1877