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 * Provides internationalization related APIs. 18 * 19 * @syscap SystemCapability.Global.I18n 20 * @since 6 21 */ 22declare namespace intl { 23/** 24 * Provides the options of Locale. 25 * 26 * @since 6 27 * @syscap SystemCapability.Global.I18n 28 */ 29export interface LocaleOptions { 30 /** 31 * Indicates the calendar. 32 * @type { string } calendar 33 * @since 6 34 */ 35 /** 36 * Indicates the calendar. 37 * @type { string } [ calendar ] 38 * @since 9 39 */ 40 calendar?: string; 41 42 /** 43 * Indicates the collation. 44 * @type { string } collation 45 * @since 6 46 */ 47 /** 48 * Indicates the collation. 49 * @type { string } [ collation ] 50 * @since 9 51 */ 52 collation?: string; 53 54 /** 55 * Indicates the hourCycle. 56 * @type { string } hourCycle 57 * @since 6 58 */ 59 /** 60 * Indicates the hourCycle. 61 * @type { string } [ hourCycle ] 62 * @since 9 63 */ 64 hourCycle?: string; 65 66 /** 67 * Indicates the numberingSystem. 68 * @type { string } numberingSystem 69 * @since 6 70 */ 71 /** 72 * Indicates the numberingSystem. 73 * @type { string } [ numberingSystem ] 74 * @since 9 75 */ 76 numberingSystem?: string; 77 78 /** 79 * Indicates the numeric. 80 * @type { boolean } numeric 81 * @since 6 82 */ 83 /** 84 * Indicates the numeric. 85 * @type { boolean } [ numeric ] 86 * @since 9 87 */ 88 numeric?: boolean; 89 90 /** 91 * Indicates the caseFirst. 92 * @type { string } caseFirst 93 * @since 6 94 */ 95 /** 96 * Indicates the caseFirst. 97 * @type { string } [ caseFirst ] 98 * @since 9 99 */ 100 caseFirst?: string; 101} 102 103/** 104 * Provides APIs for obtaining locale information. 105 * 106 * @syscap SystemCapability.Global.I18n 107 * @since 6 108 */ 109export class Locale { 110 /** 111 * A constructor used to create a Locale object. 112 * 113 * @syscap SystemCapability.Global.I18n 114 * @since 8 115 */ 116 constructor(); 117 118 /** 119 * A constructor used to create a Locale object. 120 * 121 * @syscap SystemCapability.Global.I18n 122 * @param locale Indicates a character string containing the locale information, including 123 * the language and optionally the script and region. 124 * @param options Indicates Locale option object use to initialize the Locale object. 125 * @since 6 126 */ 127 constructor(locale: string, options?: LocaleOptions); 128 129 /** 130 * Indicates the language of the locale. 131 * 132 * @syscap SystemCapability.Global.I18n 133 * @since 6 134 */ 135 language: string 136 137 /** 138 * Indicates the script of the locale. 139 * 140 * @syscap SystemCapability.Global.I18n 141 * @since 6 142 */ 143 script: string 144 145 /** 146 * Indicates the region of the locale. 147 * 148 * @syscap SystemCapability.Global.I18n 149 * @since 6 150 */ 151 region: string 152 153 /** 154 * Indicates the basic locale information, which is returned as a substring of 155 * a complete locale string. 156 * 157 * @syscap SystemCapability.Global.I18n 158 * @since 6 159 */ 160 baseName: string 161 162 /** 163 * Indicates the case first style of the locale. 164 * 165 * @syscap SystemCapability.Global.I18n 166 * @since 6 167 */ 168 caseFirst: string 169 170 /** 171 * Indicates the calendar. 172 * 173 * @syscap SystemCapability.Global.I18n 174 * @since 6 175 */ 176 calendar: string 177 178 /** 179 * Indicates the collation. 180 * 181 * @syscap SystemCapability.Global.I18n 182 * @since 6 183 */ 184 collation: string 185 186 /** 187 * Indicates the hour cycle. 188 * 189 * @syscap SystemCapability.Global.I18n 190 * @since 6 191 */ 192 hourCycle: string 193 194 /** 195 * Indicates the numbering system. 196 * 197 * @syscap SystemCapability.Global.I18n 198 * @since 6 199 */ 200 numberingSystem: string 201 202 /** 203 * Indicates whether it is numeric. 204 * 205 * @syscap SystemCapability.Global.I18n 206 * @since 6 207 */ 208 numeric: boolean 209 210 /** 211 * Convert the locale information to string. 212 * 213 * @syscap SystemCapability.Global.I18n 214 * @returns Returns locale information in string form. 215 * @since 6 216 */ 217 toString(): string; 218 219 /** 220 * Maximize the locale's base information. 221 * 222 * @syscap SystemCapability.Global.I18n 223 * @returns Returns maximized locale. 224 * @since 6 225 */ 226 maximize(): Locale; 227 228 /** 229 * Minimize the locale's base information. 230 * 231 * @syscap SystemCapability.Global.I18n 232 * @returns Returns minimized locale. 233 * @since 6 234 */ 235 minimize(): Locale; 236} 237 238/** 239 * Provides the options of date time format. 240 * 241 * @syscap SystemCapability.Global.I18n 242 * @since 6 243 */ 244export interface DateTimeOptions { 245 /** 246 * Indicates the locale. 247 * @type { string } locale 248 * @syscap SystemCapability.Global.I18n 249 * @since 6 250 */ 251 /** 252 * Indicates the locale. 253 * @type { string } [ locale ] 254 * @syscap SystemCapability.Global.I18n 255 * @since 9 256 */ 257 locale?: string 258 259 /** 260 * Indicates the dateStyle. 261 * @type { string } dateStyle 262 * @syscap SystemCapability.Global.I18n 263 * @since 6 264 */ 265 /** 266 * Indicates the dateStyle. 267 * @type { string } [ dateStyle ] 268 * @syscap SystemCapability.Global.I18n 269 * @since 9 270 */ 271 dateStyle?: string 272 273 /** 274 * Indicates the timeStyle. 275 * @type { string } timeStyle 276 * @syscap SystemCapability.Global.I18n 277 * @since 6 278 */ 279 /** 280 * Indicates the timeStyle. 281 * @type { string } [ timeStyle ] 282 * @syscap SystemCapability.Global.I18n 283 * @since 9 284 */ 285 timeStyle?: string 286 287 /** 288 * Indicates the hourCycle. 289 * @type { string } hourCycle 290 * @syscap SystemCapability.Global.I18n 291 * @since 6 292 */ 293 /** 294 * Indicates the hourCycle. 295 * @type { string } [ hourCycle ] 296 * @syscap SystemCapability.Global.I18n 297 * @since 9 298 */ 299 hourCycle?: string 300 301 /** 302 * Indicates the timeZone. 303 * @type { string } timeZone 304 * @syscap SystemCapability.Global.I18n 305 * @since 6 306 */ 307 /** 308 * Indicates the timeZone. 309 * @type { string } [ timeZone ] 310 * @syscap SystemCapability.Global.I18n 311 * @since 9 312 */ 313 timeZone?: string 314 315 /** 316 * Indicates the numberingSystem. 317 * @type { string } numberingSystem 318 * @syscap SystemCapability.Global.I18n 319 * @since 6 320 */ 321 /** 322 * Indicates the numberingSystem. 323 * @type { string } [ numberingSystem ] 324 * @syscap SystemCapability.Global.I18n 325 * @since 9 326 */ 327 numberingSystem?: string 328 329 /** 330 * Indicates the hour12. 331 * @type { boolean } hour12 332 * @syscap SystemCapability.Global.I18n 333 * @since 6 334 */ 335 /** 336 * Indicates the hour12. 337 * @type { boolean } [ hour12 ] 338 * @syscap SystemCapability.Global.I18n 339 * @since 9 340 */ 341 hour12?: boolean 342 343 /** 344 * Indicates the weekday. 345 * @type { string } weekday 346 * @syscap SystemCapability.Global.I18n 347 * @since 6 348 */ 349 /** 350 * Indicates the weekday. 351 * @type { string } [ weekday ] 352 * @syscap SystemCapability.Global.I18n 353 * @since 9 354 */ 355 weekday?: string 356 357 /** 358 * Indicates the era. 359 * @type { string } era 360 * @syscap SystemCapability.Global.I18n 361 * @since 6 362 */ 363 /** 364 * Indicates the era. 365 * @type { string } [ era ] 366 * @syscap SystemCapability.Global.I18n 367 * @since 9 368 */ 369 era?: string 370 371 /** 372 * Indicates the year. 373 * @type { string } year 374 * @syscap SystemCapability.Global.I18n 375 * @since 6 376 */ 377 /** 378 * Indicates the year. 379 * @type { string } [ year ] 380 * @syscap SystemCapability.Global.I18n 381 * @since 9 382 */ 383 year?: string 384 385 /** 386 * Indicates the month. 387 * @type { string } month 388 * @syscap SystemCapability.Global.I18n 389 * @since 6 390 */ 391 /** 392 * Indicates the month. 393 * @type { string } [ month ] 394 * @syscap SystemCapability.Global.I18n 395 * @since 9 396 */ 397 month?: string 398 399 /** 400 * Indicates the day. 401 * @type { string } day 402 * @syscap SystemCapability.Global.I18n 403 * @since 6 404 */ 405 /** 406 * Indicates the day. 407 * @type { string } [ day ] 408 * @syscap SystemCapability.Global.I18n 409 * @since 9 410 */ 411 day?: string 412 413 /** 414 * Indicates the hour. 415 * @type { string } hour 416 * @syscap SystemCapability.Global.I18n 417 * @since 6 418 */ 419 /** 420 * Indicates the hour. 421 * @type { string } [ hour ] 422 * @syscap SystemCapability.Global.I18n 423 * @since 9 424 */ 425 hour?: string 426 427 /** 428 * Indicates the minute. 429 * @type { string } minute 430 * @syscap SystemCapability.Global.I18n 431 * @since 6 432 */ 433 /** 434 * Indicates the minute. 435 * @type { string } [ minute ] 436 * @syscap SystemCapability.Global.I18n 437 * @since 9 438 */ 439 minute?: string 440 441 /** 442 * Indicates the second. 443 * @type { string } second 444 * @syscap SystemCapability.Global.I18n 445 * @since 6 446 */ 447 /** 448 * Indicates the second. 449 * @type { string } [ second ] 450 * @syscap SystemCapability.Global.I18n 451 * @since 9 452 */ 453 second?: string 454 455 /** 456 * Indicates the timeZoneName. 457 * @type { string } timeZoneName 458 * @syscap SystemCapability.Global.I18n 459 * @since 6 460 */ 461 /** 462 * Indicates the timeZoneName. 463 * @type { string } [ timeZoneName ] 464 * @syscap SystemCapability.Global.I18n 465 * @since 9 466 */ 467 timeZoneName?: string 468 469 /** 470 * Indicates the dayPeriod. 471 * @type { string } dayPeriod 472 * @syscap SystemCapability.Global.I18n 473 * @since 6 474 */ 475 /** 476 * Indicates the dayPeriod. 477 * @type { string } [ dayPeriod ] 478 * @syscap SystemCapability.Global.I18n 479 * @since 9 480 */ 481 dayPeriod?: string 482 483 /** 484 * Indicates the localeMatcher. 485 * @type { string } localeMatcher 486 * @syscap SystemCapability.Global.I18n 487 * @since 6 488 */ 489 /** 490 * Indicates the localeMatcher. 491 * @type { string } [ localeMatcher ] 492 * @syscap SystemCapability.Global.I18n 493 * @since 9 494 */ 495 localeMatcher?: string 496 497 /** 498 * Indicates the formatMatcher. 499 * @type { string } formatMatcher 500 * @syscap SystemCapability.Global.I18n 501 * @since 6 502 */ 503 /** 504 * Indicates the formatMatcher. 505 * @type { string } [ formatMatcher ] 506 * @syscap SystemCapability.Global.I18n 507 * @since 9 508 */ 509 formatMatcher?: string 510} 511 512/** 513 * Provides the API for formatting date strings. 514 * 515 * @syscap SystemCapability.Global.I18n 516 * @since 6 517 */ 518export class DateTimeFormat { 519 /** 520 * A constructor used to create a DateTimeFormat object. 521 * 522 * @syscap SystemCapability.Global.I18n 523 * @since 8 524 */ 525 constructor(); 526 527 /** 528 * A constructor used to create a DateTimeFormat object. 529 * 530 * @syscap SystemCapability.Global.I18n 531 * @param locale Indicates character string containing the locale information, including 532 * the language and optionally the script and region, for the DateTimeFormat object. 533 * @param options Indicates the options used to format the date. 534 * @since 6 535 */ 536 constructor(locale: string | Array<string>, options?: DateTimeOptions); 537 538 /** 539 * Obtains the formatted date strings. 540 * 541 * @syscap SystemCapability.Global.I18n 542 * @param date Indicates the Date object to be formatted. 543 * @returns Returns a date string formatted based on the specified locale. 544 * @since 6 545 */ 546 format(date: Date): string; 547 548 /** 549 * Obtains the formatted date strings of a date range. 550 * 551 * @syscap SystemCapability.Global.I18n 552 * @param startDate Indicates the start date of the date range. 553 * @param endDate Indicates the end date of the date range. 554 * @returns Returns a date string formatted based on the specified locale. 555 * @since 6 556 */ 557 formatRange(startDate: Date, endDate: Date): string; 558 559 /** 560 * Obtains the options of the DateTimeFormat object. 561 * 562 * @syscap SystemCapability.Global.I18n 563 * @returns Returns the options of the DateTimeFormat object. 564 * @since 6 565 */ 566 resolvedOptions(): DateTimeOptions; 567} 568 569/** 570 * Provides the options of number format. 571 * 572 * @syscap SystemCapability.Global.I18n 573 * @since 6 574 */ 575export interface NumberOptions { 576 /** 577 * Indicates the locale. 578 * @type { string } locale 579 * @syscap SystemCapability.Global.I18n 580 * @since 6 581 */ 582 /** 583 * Indicates the locale. 584 * @type { string } [ locale ] 585 * @syscap SystemCapability.Global.I18n 586 * @since 9 587 */ 588 locale?: string 589 590 /** 591 * Indicates the currency. 592 * @type { string } currency 593 * @syscap SystemCapability.Global.I18n 594 * @since 6 595 */ 596 /** 597 * Indicates the currency. 598 * @type { string } [ currency ] 599 * @syscap SystemCapability.Global.I18n 600 * @since 9 601 */ 602 currency?: string 603 604 /** 605 * Indicates the currencySign. 606 * @type { string } currencySign 607 * @syscap SystemCapability.Global.I18n 608 * @since 6 609 */ 610 /** 611 * Indicates the currencySign. 612 * @type { string } [ currencySign ] 613 * @syscap SystemCapability.Global.I18n 614 * @since 9 615 */ 616 currencySign?: string 617 618 /** 619 * Indicates the currencyDisplay. 620 * @type { string } currencyDisplay 621 * @syscap SystemCapability.Global.I18n 622 * @since 6 623 */ 624 /** 625 * Indicates the currencyDisplay. 626 * @type { string } [ currencyDisplay ] 627 * @syscap SystemCapability.Global.I18n 628 * @since 9 629 */ 630 currencyDisplay?: string 631 632 /** 633 * Indicates the unit. 634 * @type { string } unit 635 * @syscap SystemCapability.Global.I18n 636 * @since 6 637 */ 638 /** 639 * Indicates the unit. 640 * @type { string } [ unit ] 641 * @syscap SystemCapability.Global.I18n 642 * @since 9 643 */ 644 unit?: string 645 646 /** 647 * Indicates the unitDisplay. 648 * @type { string } unitDisplay 649 * @syscap SystemCapability.Global.I18n 650 * @since 6 651 */ 652 /** 653 * Indicates the unitDisplay. 654 * @type { string } [ unitDisplay ] 655 * @syscap SystemCapability.Global.I18n 656 * @since 9 657 */ 658 unitDisplay?: string 659 660 /** 661 * Indicates the unitUsage. 662 * @type { string } unitUsage 663 * @syscap SystemCapability.Global.I18n 664 * @since 8 665 */ 666 /** 667 * Indicates the unitUsage. 668 * @type { string } [ unitUsage ] 669 * @syscap SystemCapability.Global.I18n 670 * @since 9 671 */ 672 unitUsage?: string 673 674 /** 675 * Indicates the signDisplay. 676 * @type { string } signDisplay 677 * @syscap SystemCapability.Global.I18n 678 * @since 6 679 */ 680 /** 681 * Indicates the signDisplay. 682 * @type { string } [ signDisplay ] 683 * @syscap SystemCapability.Global.I18n 684 * @since 9 685 */ 686 signDisplay?: string 687 688 /** 689 * Indicates the compactDisplay. 690 * @type { string } compactDisplay 691 * @syscap SystemCapability.Global.I18n 692 * @since 6 693 */ 694 /** 695 * Indicates the compactDisplay. 696 * @type { string } [ compactDisplay ] 697 * @syscap SystemCapability.Global.I18n 698 * @since 9 699 */ 700 compactDisplay?: string 701 702 /** 703 * Indicates the notation. 704 * @type { string } notation 705 * @syscap SystemCapability.Global.I18n 706 * @since 6 707 */ 708 /** 709 * Indicates the notation. 710 * @type { string } [ notation ] 711 * @syscap SystemCapability.Global.I18n 712 * @since 9 713 */ 714 notation?: string 715 716 /** 717 * Indicates the localeMatcher. 718 * @type { string } localeMatcher 719 * @syscap SystemCapability.Global.I18n 720 * @since 6 721 */ 722 /** 723 * Indicates the localeMatcher. 724 * @type { string } [ localeMatcher ] 725 * @syscap SystemCapability.Global.I18n 726 * @since 9 727 */ 728 localeMatcher?: string 729 730 /** 731 * Indicates the style. 732 * @type { string } style 733 * @syscap SystemCapability.Global.I18n 734 * @since 6 735 */ 736 /** 737 * Indicates the style. 738 * @type { string } [ style ] 739 * @syscap SystemCapability.Global.I18n 740 * @since 9 741 */ 742 style?: string 743 744 /** 745 * Indicates the numberingSystem. 746 * @type { string } numberingSystem 747 * @syscap SystemCapability.Global.I18n 748 * @since 6 749 */ 750 /** 751 * Indicates the numberingSystem. 752 * @type { string } [ numberingSystem ] 753 * @syscap SystemCapability.Global.I18n 754 * @since 9 755 */ 756 numberingSystem?: string 757 758 /** 759 * Indicates the useGrouping. 760 * @type { boolean } useGrouping 761 * @syscap SystemCapability.Global.I18n 762 * @since 6 763 */ 764 /** 765 * Indicates the useGrouping. 766 * @type { boolean } [ useGrouping ] 767 * @syscap SystemCapability.Global.I18n 768 * @since 9 769 */ 770 useGrouping?: boolean 771 772 /** 773 * Indicates the minimumIntegerDigits. 774 * @type { number } minimumIntegerDigits 775 * @syscap SystemCapability.Global.I18n 776 * @since 6 777 */ 778 /** 779 * Indicates the minimumIntegerDigits. 780 * @type { number } [ minimumIntegerDigits ] 781 * @syscap SystemCapability.Global.I18n 782 * @since 9 783 */ 784 minimumIntegerDigits?: number 785 786 /** 787 * Indicates the minimumFractionDigits. 788 * @type { number } minimumFractionDigits 789 * @syscap SystemCapability.Global.I18n 790 * @since 6 791 */ 792 /** 793 * Indicates the minimumFractionDigits. 794 * @type { number } [ minimumFractionDigits ] 795 * @syscap SystemCapability.Global.I18n 796 * @since 9 797 */ 798 minimumFractionDigits?: number 799 800 /** 801 * Indicates the maximumFractionDigits. 802 * @type { number } maximumFractionDigits 803 * @syscap SystemCapability.Global.I18n 804 * @since 6 805 */ 806 /** 807 * Indicates the maximumFractionDigits. 808 * @type { number } [ maximumFractionDigits ] 809 * @syscap SystemCapability.Global.I18n 810 * @since 9 811 */ 812 maximumFractionDigits?: number 813 814 /** 815 * Indicates the minimumSignificantDigits. 816 * @type { number } minimumSignificantDigits 817 * @syscap SystemCapability.Global.I18n 818 * @since 6 819 */ 820 /** 821 * Indicates the minimumSignificantDigits. 822 * @type { number } [ minimumSignificantDigits ] 823 * @syscap SystemCapability.Global.I18n 824 * @since 9 825 */ 826 minimumSignificantDigits?: number 827 828 /** 829 * Indicates the maximumSignificantDigits. 830 * @type { number } maximumSignificantDigits 831 * @syscap SystemCapability.Global.I18n 832 * @since 6 833 */ 834 /** 835 * Indicates the maximumSignificantDigits. 836 * @type { number } [ maximumSignificantDigits ] 837 * @syscap SystemCapability.Global.I18n 838 * @since 9 839 */ 840 maximumSignificantDigits?: number 841} 842 843/** 844 * Provides the API for formatting number strings. 845 * 846 * @syscap SystemCapability.Global.I18n 847 * @since 6 848 */ 849export class NumberFormat { 850 /** 851 * A constructor used to create a NumberFormat object. 852 * 853 * @syscap SystemCapability.Global.I18n 854 * @since 8 855 */ 856 constructor(); 857 858 /** 859 * A constructor used to create a NumberFormat object. 860 * 861 * @syscap SystemCapability.Global.I18n 862 * @param locale Indicates a character string containing the locale information, including 863 * the language and optionally the script and region, for the NumberFormat object. 864 * @param options Indicates the options used to format the number. 865 * @since 6 866 */ 867 constructor(locale: string | Array<string>, options?: NumberOptions); 868 869 /** 870 * Obtains the formatted number string. 871 * 872 * @syscap SystemCapability.Global.I18n 873 * @param number Indicates the number to be formatted. 874 * @returns Returns a number string formatted based on the specified locale. 875 * @since 6 876 */ 877 format(number: number): string; 878 879 /** 880 * Obtains the options of the NumberFormat object. 881 * 882 * @syscap SystemCapability.Global.I18n 883 * @returns Returns the options of the NumberFormat object. 884 * @since 6 885 */ 886 resolvedOptions(): NumberOptions; 887} 888 889/** 890 * Provides the options of Collator 891 * 892 * @syscap SystemCapability.Global.I18n 893 * @since 8 894 */ 895export interface CollatorOptions { 896 /** 897 * The locale matching algorithm to use. 898 * Possible values are "lookup" and "best fit"; the default is "best fit". 899 * 900 * @type { string } localeMatcher 901 * @syscap SystemCapability.Global.I18n 902 * @since 8 903 */ 904 /** 905 * The locale matching algorithm to use. 906 * Possible values are "lookup" and "best fit"; the default is "best fit". 907 * 908 * @type { string } [ localeMatcher ] 909 * @syscap SystemCapability.Global.I18n 910 * @since 9 911 */ 912 localeMatcher?: string; 913 914 /** 915 * Whether the comparison is for sorting or for searching for matching strings. 916 * Possible values are "sort" and "search"; the default is "sort". 917 * 918 * @type { string } usage 919 * @syscap SystemCapability.Global.I18n 920 * @since 8 921 */ 922 /** 923 * Whether the comparison is for sorting or for searching for matching strings. 924 * Possible values are "sort" and "search"; the default is "sort". 925 * 926 * @type { string } [ usage ] 927 * @syscap SystemCapability.Global.I18n 928 * @since 9 929 */ 930 usage?: string; 931 932 /** 933 * Which differences in the strings should lead to non-zero result values. 934 * Possible values are "base", "accent", "case", "variant". 935 * "base" are used when only strings that differ in base letters compare as unequal. 936 * "accent" are used when only strings that differ in base letters or accents and 937 * other diacritic marks compare as unequal. 938 * "case" are used when only strings that differ in base letters or case compare as unequal. 939 * "variant" are used when Strings that differ in base letters, accents and other diacritic marks, 940 * or case compare as unequal. 941 * 942 * @type { string } sensitivity 943 * @syscap SystemCapability.Global.I18n 944 * @since 8 945 */ 946 /** 947 * Which differences in the strings should lead to non-zero result values. 948 * Possible values are "base", "accent", "case", "variant". 949 * "base" are used when only strings that differ in base letters compare as unequal. 950 * "accent" are used when only strings that differ in base letters or accents and 951 * other diacritic marks compare as unequal. 952 * "case" are used when only strings that differ in base letters or case compare as unequal. 953 * "variant" are used when Strings that differ in base letters, accents and other diacritic marks, 954 * or case compare as unequal. 955 * @type { string } [ sensitivity ] 956 * @syscap SystemCapability.Global.I18n 957 * @since 9 958 */ 959 sensitivity?: string; 960 961 /** 962 * Whether punctuation should be ignored. default value is false. 963 * 964 * @type { boolean } ignorePunctuation 965 * @syscap SystemCapability.Global.I18n 966 * @since 8 967 */ 968 /** 969 * Whether punctuation should be ignored. Default value is false. 970 * 971 * @type { boolean } [ ignorePunctuation ] 972 * @syscap SystemCapability.Global.I18n 973 * @since 9 974 */ 975 ignorePunctuation?: boolean; 976 977 /** 978 * Variant collations for certain locales. 979 * 980 * @type { string } collation 981 * @syscap SystemCapability.Global.I18n 982 * @since 8 983 */ 984 /** 985 * Variant collations for certain locales. 986 * 987 * @type { string } [ collation ] 988 * @syscap SystemCapability.Global.I18n 989 * @since 9 990 */ 991 collation?: string; 992 993 /** 994 * Whether numeric collation should be used. Default value is false. 995 * 996 * @type { boolean } numeric 997 * @syscap SystemCapability.Global.I18n 998 * @since 8 999 */ 1000 /** 1001 * Whether numeric collation should be used. Default value is false. 1002 * 1003 * @type { boolean } [ numeric ] 1004 * @syscap SystemCapability.Global.I18n 1005 * @since 9 1006 */ 1007 numeric?: boolean; 1008 1009 /** 1010 * Whether upper case or lower case should sort first. 1011 * Possible values are "upper", "lower", or "false" (use the locale's default). 1012 * 1013 * @type { string } caseFirst 1014 * @syscap SystemCapability.Global.I18n 1015 * @since 8 1016 */ 1017 /** 1018 * Whether upper case or lower case should sort first. 1019 * Possible values are "upper", "lower", or "false" (use the locale's default). 1020 * 1021 * @type { string } [ caseFirst ] 1022 * @syscap SystemCapability.Global.I18n 1023 * @since 9 1024 */ 1025 caseFirst?: string; 1026} 1027 1028/** 1029 * Enable language-sensitive string comparison. 1030 * 1031 * @syscap SystemCapability.Global.I18n 1032 * @since 8 1033 */ 1034export class Collator { 1035 /** 1036 * A constructor used to create Collator object. 1037 * 1038 * @syscap SystemCapability.Global.I18n 1039 * @since 8 1040 */ 1041 constructor(); 1042 /** 1043 * A constructor used to create Collator Object; 1044 * 1045 * @syscap SystemCapability.Global.I18n 1046 * @param locale Indicates a character string containing the locale information, including 1047 * the language and optionally the script and region, for the Collator object. 1048 * @param options Indicates the options used to initialize Collator object. 1049 * @since 8 1050 */ 1051 constructor(locale: string | Array<string>, options?: CollatorOptions); 1052 1053 /** 1054 * compares two strings according to the sort order of this Collator object 1055 * 1056 * @syscap SystemCapability.Global.I18n 1057 * @param first The first string to compare. 1058 * @param second The second string to compare. 1059 * @returns Returns a number indicating how first compare to second: 1060 * a negative value if string1 comes before string2; 1061 * a positive value if string1 comes after string2; 1062 * 0 if they are considered equal. 1063 * @since 8 1064 */ 1065 compare(first: string, second: string): number; 1066 1067 /** 1068 * Returns a new object with properties that reflect the locale and collation options computed 1069 * during initialization of the object. 1070 * 1071 * @syscap SystemCapability.Global.I18n 1072 * @returns Returns a CollatorOptions object with properties that reflect the properties of this object. 1073 * @since 8 1074 */ 1075 resolvedOptions(): CollatorOptions; 1076} 1077 1078/** 1079 * Provides the options of PluralRules 1080 * 1081 * @syscap SystemCapability.Global.I18n 1082 * @since 8 1083 */ 1084export interface PluralRulesOptions { 1085 /** 1086 * The locale matching algorithm to use. 1087 * Possible values are "lookup" and "best fit"; the default is "best fit". 1088 * 1089 * @type { string } localeMatcher 1090 * @syscap SystemCapability.Global.I18n 1091 * @since 8 1092 */ 1093 /** 1094 * The locale matching algorithm to use. 1095 * Possible values are "lookup" and "best fit"; the default is "best fit". 1096 * 1097 * @type { string } [ localeMatcher ] 1098 * @syscap SystemCapability.Global.I18n 1099 * @since 9 1100 */ 1101 localeMatcher?: string; 1102 1103 /** 1104 * The type to use. Possible values are: "cardinal", "ordinal" 1105 * 1106 * @type { string } type 1107 * @syscap SystemCapability.Global.I18n 1108 * @since 8 1109 */ 1110 /** 1111 * The type to use. Possible values are: "cardinal", "ordinal" 1112 * 1113 * @type { string } [ type ] 1114 * @syscap SystemCapability.Global.I18n 1115 * @since 9 1116 */ 1117 type?: string; 1118 1119 /** 1120 * The minimum number of integer digits to use. 1121 * Possible values are from 1 to 21; the default is 1. 1122 * 1123 * @type { number } minimumIntegerDigits 1124 * @syscap SystemCapability.Global.I18n 1125 * @since 8 1126 */ 1127 /** 1128 * The minimum number of integer digits to use. 1129 * Possible values are from 1 to 21; the default is 1. 1130 * 1131 * @type { number } [ minimumIntegerDigits ] 1132 * @syscap SystemCapability.Global.I18n 1133 * @since 9 1134 */ 1135 minimumIntegerDigits?: number; 1136 1137 /** 1138 * The minimum number of fraction digits to use. 1139 * Possible values are from 0 to 20; the default for plain number and percent formatting is 0; 1140 * 1141 * @type { number } minimumFractionDigits 1142 * @syscap SystemCapability.Global.I18n 1143 * @since 8 1144 */ 1145 /** 1146 * The minimum number of fraction digits to use. 1147 * Possible values are from 0 to 20; the default for plain number and percent formatting is 0; 1148 * 1149 * @type { number } [ minimumFractionDigits ] 1150 * @syscap SystemCapability.Global.I18n 1151 * @since 9 1152 */ 1153 minimumFractionDigits?: number; 1154 1155 /** 1156 * The maximum number of fraction digits to use. 1157 * Possible values are from 0 to 20; 1158 * the default for plain number formatting is the larger of minimumFractionDigits and 3; 1159 * 1160 * @type { number } maximumFractionDigits 1161 * @syscap SystemCapability.Global.I18n 1162 * @since 8 1163 */ 1164 /** 1165 * The maximum number of fraction digits to use. 1166 * Possible values are from 0 to 20; 1167 * the default for plain number formatting is the larger of minimumFractionDigits and 3; 1168 * 1169 * @type { number } [ maximumFractionDigits ] 1170 * @syscap SystemCapability.Global.I18n 1171 * @since 9 1172 */ 1173 maximumFractionDigits?: number; 1174 1175 /** 1176 * The minimum number of significant digits to use. 1177 * Possible values are from 1 to 21; the default is 1. 1178 * 1179 * @type { number } minimumSignificantDigits 1180 * @syscap SystemCapability.Global.I18n 1181 * @since 8 1182 */ 1183 /** 1184 * The minimum number of significant digits to use. 1185 * Possible values are from 1 to 21; the default is 1. 1186 * 1187 * @type { number } [ minimumSignificantDigits ] 1188 * @syscap SystemCapability.Global.I18n 1189 * @since 9 1190 */ 1191 minimumSignificantDigits?: number; 1192 1193 /** 1194 * The maximum number of significant digits to use. 1195 * Possible values are from 1 to 21; the default is 21. 1196 * 1197 * @type { number } maximumSignificantDigits 1198 * @syscap SystemCapability.Global.I18n 1199 * @since 8 1200 */ 1201 /** 1202 * The maximum number of significant digits to use. 1203 * Possible values are from 1 to 21; the default is 21. 1204 * 1205 * @type { number } [ maximumSignificantDigits ] 1206 * @syscap SystemCapability.Global.I18n 1207 * @since 9 1208 */ 1209 maximumSignificantDigits?: number; 1210} 1211 1212/** 1213 * Enables plural-sensitive formatting and plural-related language rules. 1214 * 1215 * @syscap SystemCapability.Global.I18n 1216 * @since 8 1217 */ 1218export class PluralRules { 1219 /** 1220 * A constructor used to create PluralRules object. 1221 * 1222 * @syscap SystemCapability.Global.I18n 1223 * @since 8 1224 */ 1225 constructor(); 1226 1227 /** 1228 * A constructor used to create PluralRules object. 1229 * 1230 * @syscap SystemCapability.Global.I18n 1231 * @param locale Indicates a character string containing the locale information, including 1232 * the language and optionally the script and region, for the PluralRules object. 1233 * @param options Indicates the options used to initialize PluralRules object. 1234 * @since 8 1235 */ 1236 constructor(locale: string | Array<string>, options?: PluralRulesOptions); 1237 1238 /** 1239 * Returns a string indicating which plural rule to use for locale-aware formatting. 1240 * 1241 * @syscap SystemCapability.Global.I18n 1242 * @param n The number to get a plural rule for. 1243 * @returns A string representing the pluralization category of the number, 1244 * can be one of zero, one, two, few, many or other. 1245 * @since 8 1246 */ 1247 select(n: number): string; 1248} 1249 1250/** 1251 * Provides the input options of RelativeTimeFormat. 1252 * 1253 * @syscap SystemCapability.Global.I18n 1254 * @since 8 1255 */ 1256 export interface RelativeTimeFormatInputOptions { 1257 /** 1258 * The locale matching algorithm to use. 1259 * Possible values are: lookup, best fit 1260 * 1261 * @type { string } localeMatcher 1262 * @syscap SystemCapability.Global.I18n 1263 * @since 8 1264 */ 1265 /** 1266 * The locale matching algorithm to use. 1267 * Possible values are: lookup, best fit 1268 * 1269 * @type { string } [ localeMatcher ] 1270 * @syscap SystemCapability.Global.I18n 1271 * @since 9 1272 */ 1273 localeMatcher?: string; 1274 1275 /** 1276 * The format of output message. 1277 * Possible values are: always, auto 1278 * 1279 * @type { string } numeric 1280 * @syscap SystemCapability.Global.I18n 1281 * @since 8 1282 */ 1283 /** 1284 * The format of output message. 1285 * Possible values are: always, auto 1286 * 1287 * @type { string } [ numeric ] 1288 * @syscap SystemCapability.Global.I18n 1289 * @since 9 1290 */ 1291 numeric?: string; 1292 1293 /** 1294 * The length of the internationalized message. 1295 * Possible values are: long, short, narrow 1296 * 1297 * @type { string } style 1298 * @syscap SystemCapability.Global.I18n 1299 * @since 8 1300 */ 1301 /** 1302 * The length of the internationalized message. 1303 * Possible values are: long, short, narrow 1304 * 1305 * @type { string } [ style ] 1306 * @syscap SystemCapability.Global.I18n 1307 * @since 9 1308 */ 1309 style?: string; 1310} 1311 1312/** 1313 * Provides the resolved options of RelativeTimeFormat. 1314 * 1315 * @syscap SystemCapability.Global.I18n 1316 * @since 8 1317 */ 1318export interface RelativeTimeFormatResolvedOptions { 1319 /** 1320 * The BCP 47 language tag for the locale actually used. 1321 * 1322 * @syscap SystemCapability.Global.I18n 1323 * @since 8 1324 */ 1325 locale: string; 1326 1327 /** 1328 * The length of the internationalized message. 1329 * Possible values are: long, short, narrow 1330 * 1331 * @syscap SystemCapability.Global.I18n 1332 * @since 8 1333 */ 1334 style: string; 1335 1336 /** 1337 * The format of output message. 1338 * Possible values are: always, auto 1339 * 1340 * @syscap SystemCapability.Global.I18n 1341 * @since 8 1342 */ 1343 numeric: string; 1344 1345 /** 1346 * The value requested using the Unicode extension key "nu" or filled in as a default. 1347 * 1348 * @syscap SystemCapability.Global.I18n 1349 * @since 8 1350 */ 1351 numberingSystem: string; 1352} 1353 1354/** 1355 * Given a Time period length value and a unit, RelativeTimeFormat object enables 1356 * language-sensitive relative time formatting. 1357 * 1358 * @syscap SystemCapability.Global.I18n 1359 * @since 8 1360 */ 1361export class RelativeTimeFormat { 1362 /** 1363 * A constructor used to create RelativeTimeFormat object. 1364 * 1365 * @syscap SystemCapability.Global.I18n 1366 * @since 8 1367 */ 1368 constructor(); 1369 1370 /** 1371 * A constructor used to create RelativeTimeFormat object. 1372 * 1373 * @syscap SystemCapability.Global.I18n 1374 * @param locale Indicates a character string containing the locale information, including 1375 * the language and optionally the script and region, for the RelativeTimeFormat object. 1376 * @param options Indicates the options used to initialize RelativeTimeFormat object. 1377 * @since 8 1378 */ 1379 constructor(locale: string | Array<string>, options?: RelativeTimeFormatInputOptions); 1380 1381 /** 1382 * formats a value and unit according to the locale and formatting options of this object. 1383 * 1384 * @syscap SystemCapability.Global.I18n 1385 * @param value Numeric value to use in the internationalized relative time message. 1386 * @param unit Unit to use in the relative time internationalized message. 1387 * Possible values are: year, quarter, month, week, day, hour, minute, second. 1388 * @returns formatted language-sensitive relative time. 1389 * @since 8 1390 */ 1391 format(value: number, unit: string): string; 1392 1393 /** 1394 * returns an Array of objects representing the relative time format in parts that can be used for 1395 * custom locale-aware formatting 1396 * 1397 * @syscap SystemCapability.Global.I18n 1398 * @param value Numeric value to use in the internationalized relative time message. 1399 * @param unit to use in the relative time internationalized message. 1400 * Possible values are: year, quarter, month, week, day, hour, minute, second. 1401 * @returns an Array of objects representing the relative time format in parts 1402 * @since 8 1403 */ 1404 formatToParts(value: number, unit: string): Array<object>; 1405 1406 /** 1407 * Returns a new object with properties that reflect the locale and formatting options computed during 1408 * initialization of the object. 1409 * 1410 * @syscap SystemCapability.Global.I18n 1411 * @returns RelativeTimeFormatOptions which reflect the locale and formatting options of the object. 1412 * @since 8 1413 */ 1414 resolvedOptions(): RelativeTimeFormatResolvedOptions; 1415} 1416} 1417export default intl;