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