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 * @namespace intl 20 * @syscap SystemCapability.Global.I18n 21 * @since 6 22 */ 23/** 24 * Provides internationalization related APIs. 25 * 26 * @namespace intl 27 * @syscap SystemCapability.Global.I18n 28 * @crossplatform 29 * @since 10 30 */ 31declare namespace intl { 32 /** 33 * Provides the options of Locale. 34 * 35 * @interface LocaleOptions 36 * @syscap SystemCapability.Global.I18n 37 * @since 6 38 */ 39 /** 40 * Provides the options of Locale. 41 * 42 * @interface LocaleOptions 43 * @syscap SystemCapability.Global.I18n 44 * @crossplatform 45 * @since 10 46 */ 47 export interface LocaleOptions { 48 /** 49 * Indicates the calendar. 50 * 51 * @type { string } 52 * @syscap SystemCapability.Global.I18n 53 * @since 6 54 */ 55 /** 56 * Indicates the calendar. 57 * 58 * @type { ?string } 59 * @syscap SystemCapability.Global.I18n 60 * @since 9 61 */ 62 /** 63 * Indicates the calendar. 64 * 65 * @type { ?string } 66 * @syscap SystemCapability.Global.I18n 67 * @crossplatform 68 * @since 10 69 */ 70 calendar?: string; 71 72 /** 73 * Indicates the collation. 74 * 75 * @type { string } 76 * @syscap SystemCapability.Global.I18n 77 * @since 6 78 */ 79 /** 80 * Indicates the collation. 81 * 82 * @type { ?string } 83 * @syscap SystemCapability.Global.I18n 84 * @since 9 85 */ 86 /** 87 * Indicates the collation. 88 * 89 * @type { ?string } 90 * @syscap SystemCapability.Global.I18n 91 * @crossplatform 92 * @since 10 93 */ 94 collation?: string; 95 96 /** 97 * Indicates the hourCycle. 98 * 99 * @type { string } 100 * @syscap SystemCapability.Global.I18n 101 * @since 6 102 */ 103 /** 104 * Indicates the hourCycle. 105 * 106 * @type { ?string } 107 * @syscap SystemCapability.Global.I18n 108 * @since 9 109 */ 110 /** 111 * Indicates the hourCycle. 112 * 113 * @type { ?string } 114 * @syscap SystemCapability.Global.I18n 115 * @crossplatform 116 * @since 10 117 */ 118 hourCycle?: string; 119 120 /** 121 * Indicates the numberingSystem. 122 * 123 * @type { string } 124 * @syscap SystemCapability.Global.I18n 125 * @since 6 126 */ 127 /** 128 * Indicates the numberingSystem. 129 * 130 * @type { ?string } 131 * @syscap SystemCapability.Global.I18n 132 * @since 9 133 */ 134 /** 135 * Indicates the numberingSystem. 136 * 137 * @type { ?string } 138 * @syscap SystemCapability.Global.I18n 139 * @crossplatform 140 * @since 10 141 */ 142 numberingSystem?: string; 143 144 /** 145 * Indicates the numeric. 146 * 147 * @type { boolean } 148 * @syscap SystemCapability.Global.I18n 149 * @since 6 150 */ 151 /** 152 * Indicates the numeric. 153 * 154 * @type { ?boolean } 155 * @syscap SystemCapability.Global.I18n 156 * @since 9 157 */ 158 /** 159 * Indicates the numeric. 160 * 161 * @type { ?boolean } 162 * @syscap SystemCapability.Global.I18n 163 * @crossplatform 164 * @since 10 165 */ 166 numeric?: boolean; 167 168 /** 169 * Indicates the caseFirst. 170 * 171 * @type { string } 172 * @syscap SystemCapability.Global.I18n 173 * @since 6 174 */ 175 /** 176 * Indicates the caseFirst. 177 * 178 * @type { ?string } 179 * @syscap SystemCapability.Global.I18n 180 * @since 9 181 */ 182 /** 183 * Indicates the caseFirst. 184 * 185 * @type { ?string } 186 * @syscap SystemCapability.Global.I18n 187 * @crossplatform 188 * @since 10 189 */ 190 caseFirst?: string; 191 } 192 193 /** 194 * Provides APIs for obtaining locale information. 195 * 196 * @syscap SystemCapability.Global.I18n 197 * @since 6 198 */ 199 /** 200 * Provides APIs for obtaining locale information. 201 * 202 * @syscap SystemCapability.Global.I18n 203 * @crossplatform 204 * @since 10 205 */ 206 export class Locale { 207 /** 208 * A constructor used to create a Locale object. 209 * 210 * @syscap SystemCapability.Global.I18n 211 * @since 8 212 */ 213 /** 214 * A constructor used to create a Locale object. 215 * 216 * @syscap SystemCapability.Global.I18n 217 * @crossplatform 218 * @since 10 219 */ 220 constructor(); 221 222 /** 223 * A constructor used to create a Locale object. 224 * 225 * @param { string } locale - Indicates a character string containing the locale information, including 226 * the language and optionally the script and region. 227 * @param { LocaleOptions } options - Indicates Locale option object use to initialize the Locale object. 228 * @syscap SystemCapability.Global.I18n 229 * @since 6 230 */ 231 /** 232 * A constructor used to create a Locale object. 233 * 234 * @param { string } locale - Indicates a character string containing the locale information, including 235 * the language and optionally the script and region. 236 * @param { LocaleOptions } options - Indicates Locale option object use to initialize the Locale object. 237 * @syscap SystemCapability.Global.I18n 238 * @crossplatform 239 * @since 10 240 */ 241 constructor(locale: string, options?: LocaleOptions); 242 243 /** 244 * Indicates the language of the locale. 245 * 246 * @syscap SystemCapability.Global.I18n 247 * @since 6 248 */ 249 /** 250 * Indicates the language of the locale. 251 * 252 * @syscap SystemCapability.Global.I18n 253 * @crossplatform 254 * @since 10 255 */ 256 language: string; 257 258 /** 259 * Indicates the script of the locale. 260 * 261 * @syscap SystemCapability.Global.I18n 262 * @since 6 263 */ 264 /** 265 * Indicates the script of the locale. 266 * 267 * @syscap SystemCapability.Global.I18n 268 * @crossplatform 269 * @since 10 270 */ 271 script: string; 272 273 /** 274 * Indicates the region of the locale. 275 * 276 * @syscap SystemCapability.Global.I18n 277 * @since 6 278 */ 279 /** 280 * Indicates the region of the locale. 281 * 282 * @syscap SystemCapability.Global.I18n 283 * @crossplatform 284 * @since 10 285 */ 286 region: string; 287 288 /** 289 * Indicates the basic locale information, which is returned as a substring of 290 * a complete locale string. 291 * 292 * @syscap SystemCapability.Global.I18n 293 * @since 6 294 */ 295 /** 296 * Indicates the basic locale information, which is returned as a substring of 297 * a complete locale string. 298 * 299 * @syscap SystemCapability.Global.I18n 300 * @crossplatform 301 * @since 10 302 */ 303 baseName: string; 304 305 /** 306 * Indicates the case first style of the locale. 307 * 308 * @syscap SystemCapability.Global.I18n 309 * @since 6 310 */ 311 /** 312 * Indicates the case first style of the locale. 313 * 314 * @syscap SystemCapability.Global.I18n 315 * @crossplatform 316 * @since 10 317 */ 318 caseFirst: string; 319 320 /** 321 * Indicates the calendar. 322 * 323 * @syscap SystemCapability.Global.I18n 324 * @since 6 325 */ 326 /** 327 * Indicates the calendar. 328 * 329 * @syscap SystemCapability.Global.I18n 330 * @crossplatform 331 * @since 10 332 */ 333 calendar: string; 334 335 /** 336 * Indicates the collation. 337 * 338 * @syscap SystemCapability.Global.I18n 339 * @since 6 340 */ 341 /** 342 * Indicates the collation. 343 * 344 * @syscap SystemCapability.Global.I18n 345 * @crossplatform 346 * @since 10 347 */ 348 collation: string; 349 350 /** 351 * Indicates the hour cycle. 352 * 353 * @syscap SystemCapability.Global.I18n 354 * @since 6 355 */ 356 /** 357 * Indicates the hour cycle. 358 * 359 * @syscap SystemCapability.Global.I18n 360 * @crossplatform 361 * @since 10 362 */ 363 hourCycle: string; 364 365 /** 366 * Indicates the numbering system. 367 * 368 * @syscap SystemCapability.Global.I18n 369 * @since 6 370 */ 371 /** 372 * Indicates the numbering system. 373 * 374 * @syscap SystemCapability.Global.I18n 375 * @crossplatform 376 * @since 10 377 */ 378 numberingSystem: string; 379 380 /** 381 * Indicates whether it is numeric. 382 * 383 * @syscap SystemCapability.Global.I18n 384 * @since 6 385 */ 386 /** 387 * Indicates whether it is numeric. 388 * 389 * @syscap SystemCapability.Global.I18n 390 * @crossplatform 391 * @since 10 392 */ 393 numeric: boolean; 394 395 /** 396 * Convert the locale information to string. 397 * 398 * @returns { string } locale information in string form. 399 * @syscap SystemCapability.Global.I18n 400 * @since 6 401 */ 402 /** 403 * Convert the locale information to string. 404 * 405 * @returns { string } locale information in string form. 406 * @syscap SystemCapability.Global.I18n 407 * @crossplatform 408 * @since 10 409 */ 410 toString(): string; 411 412 /** 413 * Maximize the locale's base information. 414 * 415 * @returns { Locale } maximized locale. 416 * @syscap SystemCapability.Global.I18n 417 * @since 6 418 */ 419 /** 420 * Maximize the locale's base information. 421 * 422 * @returns { Locale } maximized locale. 423 * @syscap SystemCapability.Global.I18n 424 * @crossplatform 425 * @since 10 426 */ 427 maximize(): Locale; 428 429 /** 430 * Minimize the locale's base information. 431 * 432 * @returns { Locale } minimized locale. 433 * @syscap SystemCapability.Global.I18n 434 * @since 6 435 */ 436 /** 437 * Minimize the locale's base information. 438 * 439 * @returns { Locale } minimized locale. 440 * @syscap SystemCapability.Global.I18n 441 * @crossplatform 442 * @since 10 443 */ 444 minimize(): Locale; 445 } 446 447 /** 448 * Provides the options of date time format. 449 * 450 * @interface DateTimeOptions 451 * @syscap SystemCapability.Global.I18n 452 * @since 6 453 */ 454 /** 455 * Provides the options of date time format. 456 * 457 * @interface DateTimeOptions 458 * @syscap SystemCapability.Global.I18n 459 * @crossplatform 460 * @since 10 461 */ 462 export interface DateTimeOptions { 463 /** 464 * Indicates the locale. 465 * 466 * @type { string } 467 * @syscap SystemCapability.Global.I18n 468 * @since 6 469 */ 470 /** 471 * Indicates the locale. 472 * 473 * @type { ?string } 474 * @syscap SystemCapability.Global.I18n 475 * @since 9 476 */ 477 /** 478 * Indicates the locale. 479 * 480 * @type { ?string } 481 * @syscap SystemCapability.Global.I18n 482 * @crossplatform 483 * @since 10 484 */ 485 locale?: string; 486 487 /** 488 * Indicates the dateStyle. 489 * 490 * @type { string } 491 * @syscap SystemCapability.Global.I18n 492 * @since 6 493 */ 494 /** 495 * Indicates the dateStyle. 496 * 497 * @type { ?string } 498 * @syscap SystemCapability.Global.I18n 499 * @since 9 500 */ 501 /** 502 * Indicates the dateStyle. 503 * 504 * @type { ?string } 505 * @syscap SystemCapability.Global.I18n 506 * @crossplatform 507 * @since 10 508 */ 509 dateStyle?: string; 510 511 /** 512 * Indicates the timeStyle. 513 * 514 * @type { string } 515 * @syscap SystemCapability.Global.I18n 516 * @since 6 517 */ 518 /** 519 * Indicates the timeStyle. 520 * 521 * @type { ?string } 522 * @syscap SystemCapability.Global.I18n 523 * @since 9 524 */ 525 /** 526 * Indicates the timeStyle. 527 * 528 * @type { ?string } 529 * @syscap SystemCapability.Global.I18n 530 * @crossplatform 531 * @since 10 532 */ 533 timeStyle?: string; 534 535 /** 536 * Indicates the hourCycle. 537 * 538 * @type { string } 539 * @syscap SystemCapability.Global.I18n 540 * @since 6 541 */ 542 /** 543 * Indicates the hourCycle. 544 * 545 * @type { ?string } 546 * @syscap SystemCapability.Global.I18n 547 * @since 9 548 */ 549 /** 550 * Indicates the hourCycle. 551 * 552 * @type { ?string } 553 * @syscap SystemCapability.Global.I18n 554 * @crossplatform 555 * @since 10 556 */ 557 hourCycle?: string; 558 559 /** 560 * Indicates the timeZone. 561 * 562 * @type { string } 563 * @syscap SystemCapability.Global.I18n 564 * @since 6 565 */ 566 /** 567 * Indicates the timeZone. 568 * 569 * @type { ?string } 570 * @syscap SystemCapability.Global.I18n 571 * @since 9 572 */ 573 /** 574 * Indicates the timeZone. 575 * 576 * @type { ?string } 577 * @syscap SystemCapability.Global.I18n 578 * @crossplatform 579 * @since 10 580 */ 581 timeZone?: string; 582 583 /** 584 * Indicates the numberingSystem. 585 * 586 * @type { string } 587 * @syscap SystemCapability.Global.I18n 588 * @since 6 589 */ 590 /** 591 * Indicates the numberingSystem. 592 * 593 * @type { ?string } 594 * @syscap SystemCapability.Global.I18n 595 * @since 9 596 */ 597 /** 598 * Indicates the numberingSystem. 599 * 600 * @type { ?string } 601 * @syscap SystemCapability.Global.I18n 602 * @crossplatform 603 * @since 10 604 */ 605 numberingSystem?: string; 606 607 /** 608 * Indicates the hour12. 609 * 610 * @type { boolean } 611 * @syscap SystemCapability.Global.I18n 612 * @since 6 613 */ 614 /** 615 * Indicates the hour12. 616 * 617 * @type { ?boolean } 618 * @syscap SystemCapability.Global.I18n 619 * @since 9 620 */ 621 /** 622 * Indicates the hour12. 623 * 624 * @type { ?boolean } 625 * @syscap SystemCapability.Global.I18n 626 * @crossplatform 627 * @since 10 628 */ 629 hour12?: boolean; 630 631 /** 632 * Indicates the weekday. 633 * 634 * @type { string } 635 * @syscap SystemCapability.Global.I18n 636 * @since 6 637 */ 638 /** 639 * Indicates the weekday. 640 * 641 * @type { ?string } 642 * @syscap SystemCapability.Global.I18n 643 * @since 9 644 */ 645 /** 646 * Indicates the weekday. 647 * 648 * @type { ?string } 649 * @syscap SystemCapability.Global.I18n 650 * @crossplatform 651 * @since 10 652 */ 653 weekday?: string; 654 655 /** 656 * Indicates the era. 657 * 658 * @type { string } 659 * @syscap SystemCapability.Global.I18n 660 * @since 6 661 */ 662 /** 663 * Indicates the era. 664 * 665 * @type { ?string } 666 * @syscap SystemCapability.Global.I18n 667 * @since 9 668 */ 669 /** 670 * Indicates the era. 671 * 672 * @type { ?string } 673 * @syscap SystemCapability.Global.I18n 674 * @crossplatform 675 * @since 10 676 */ 677 era?: string; 678 679 /** 680 * Indicates the year. 681 * 682 * @type { string } 683 * @syscap SystemCapability.Global.I18n 684 * @since 6 685 */ 686 /** 687 * Indicates the year. 688 * 689 * @type { ?string } 690 * @syscap SystemCapability.Global.I18n 691 * @since 9 692 */ 693 /** 694 * Indicates the year. 695 * 696 * @type { ?string } 697 * @syscap SystemCapability.Global.I18n 698 * @crossplatform 699 * @since 10 700 */ 701 year?: string; 702 703 /** 704 * Indicates the month. 705 * 706 * @type { string } 707 * @syscap SystemCapability.Global.I18n 708 * @since 6 709 */ 710 /** 711 * Indicates the month. 712 * 713 * @type { ?string } 714 * @syscap SystemCapability.Global.I18n 715 * @since 9 716 */ 717 /** 718 * Indicates the month. 719 * 720 * @type { ?string } 721 * @syscap SystemCapability.Global.I18n 722 * @crossplatform 723 * @since 10 724 */ 725 month?: string; 726 727 /** 728 * Indicates the day. 729 * 730 * @type { string } 731 * @syscap SystemCapability.Global.I18n 732 * @since 6 733 */ 734 /** 735 * Indicates the day. 736 * 737 * @type { ?string } 738 * @syscap SystemCapability.Global.I18n 739 * @since 9 740 */ 741 /** 742 * Indicates the day. 743 * 744 * @type { ?string } 745 * @syscap SystemCapability.Global.I18n 746 * @crossplatform 747 * @since 10 748 */ 749 day?: string; 750 751 /** 752 * Indicates the hour. 753 * 754 * @type { string } 755 * @syscap SystemCapability.Global.I18n 756 * @since 6 757 */ 758 /** 759 * Indicates the hour. 760 * 761 * @type { ?string } 762 * @syscap SystemCapability.Global.I18n 763 * @since 9 764 */ 765 /** 766 * Indicates the hour. 767 * 768 * @type { ?string } 769 * @syscap SystemCapability.Global.I18n 770 * @crossplatform 771 * @since 10 772 */ 773 hour?: string; 774 775 /** 776 * Indicates the minute. 777 * 778 * @type { string } 779 * @syscap SystemCapability.Global.I18n 780 * @since 6 781 */ 782 /** 783 * Indicates the minute. 784 * 785 * @type { ?string } 786 * @syscap SystemCapability.Global.I18n 787 * @since 9 788 */ 789 /** 790 * Indicates the minute. 791 * 792 * @type { ?string } 793 * @syscap SystemCapability.Global.I18n 794 * @crossplatform 795 * @since 10 796 */ 797 minute?: string; 798 799 /** 800 * Indicates the second. 801 * 802 * @type { string } 803 * @syscap SystemCapability.Global.I18n 804 * @since 6 805 */ 806 /** 807 * Indicates the second. 808 * 809 * @type { ?string } 810 * @syscap SystemCapability.Global.I18n 811 * @since 9 812 */ 813 /** 814 * Indicates the second. 815 * 816 * @type { ?string } 817 * @syscap SystemCapability.Global.I18n 818 * @crossplatform 819 * @since 10 820 */ 821 second?: string; 822 823 /** 824 * Indicates the timeZoneName. 825 * 826 * @type { string } 827 * @syscap SystemCapability.Global.I18n 828 * @since 6 829 */ 830 /** 831 * Indicates the timeZoneName. 832 * 833 * @type { ?string } 834 * @syscap SystemCapability.Global.I18n 835 * @since 9 836 */ 837 /** 838 * Indicates the timeZoneName. 839 * 840 * @type { ?string } 841 * @syscap SystemCapability.Global.I18n 842 * @crossplatform 843 * @since 10 844 */ 845 timeZoneName?: string; 846 847 /** 848 * Indicates the dayPeriod. 849 * 850 * @type { string } 851 * @syscap SystemCapability.Global.I18n 852 * @since 6 853 */ 854 /** 855 * Indicates the dayPeriod. 856 * 857 * @type { ?string } 858 * @syscap SystemCapability.Global.I18n 859 * @since 9 860 */ 861 /** 862 * Indicates the dayPeriod. 863 * 864 * @type { ?string } 865 * @syscap SystemCapability.Global.I18n 866 * @crossplatform 867 * @since 10 868 */ 869 dayPeriod?: string; 870 871 /** 872 * Indicates the localeMatcher. 873 * 874 * @type { string } 875 * @syscap SystemCapability.Global.I18n 876 * @since 6 877 */ 878 /** 879 * Indicates the localeMatcher. 880 * 881 * @type { ?string } 882 * @syscap SystemCapability.Global.I18n 883 * @since 9 884 */ 885 /** 886 * Indicates the localeMatcher. 887 * 888 * @type { ?string } 889 * @syscap SystemCapability.Global.I18n 890 * @crossplatform 891 * @since 10 892 */ 893 localeMatcher?: string; 894 895 /** 896 * Indicates the formatMatcher. 897 * 898 * @type { string } 899 * @syscap SystemCapability.Global.I18n 900 * @since 6 901 */ 902 /** 903 * Indicates the formatMatcher. 904 * 905 * @type { ?string } 906 * @syscap SystemCapability.Global.I18n 907 * @since 9 908 */ 909 /** 910 * Indicates the formatMatcher. 911 * 912 * @type { ?string } 913 * @syscap SystemCapability.Global.I18n 914 * @crossplatform 915 * @since 10 916 */ 917 formatMatcher?: string; 918 } 919 920 /** 921 * Provides the API for formatting date strings. 922 * 923 * @syscap SystemCapability.Global.I18n 924 * @since 6 925 */ 926 /** 927 * Provides the API for formatting date strings. 928 * 929 * @syscap SystemCapability.Global.I18n 930 * @crossplatform 931 * @since 10 932 */ 933 export class DateTimeFormat { 934 /** 935 * A constructor used to create a DateTimeFormat object. 936 * 937 * @syscap SystemCapability.Global.I18n 938 * @since 8 939 */ 940 /** 941 * A constructor used to create a DateTimeFormat object. 942 * 943 * @syscap SystemCapability.Global.I18n 944 * @crossplatform 945 * @since 10 946 */ 947 constructor(); 948 949 /** 950 * A constructor used to create a DateTimeFormat object. 951 * 952 * @param { string | Array<string> } locale - Indicates character string containing the locale information, including 953 * the language and optionally the script and region, for the DateTimeFormat object. 954 * @param { DateTimeOptions } [options] - Indicates the options used to format the date. 955 * @syscap SystemCapability.Global.I18n 956 * @since 6 957 */ 958 /** 959 * A constructor used to create a DateTimeFormat object. 960 * 961 * @param { string | Array<string> } locale - Indicates character string containing the locale information, including 962 * the language and optionally the script and region, for the DateTimeFormat object. 963 * @param { DateTimeOptions } [options] - Indicates the options used to format the date. 964 * @syscap SystemCapability.Global.I18n 965 * @crossplatform 966 * @since 10 967 */ 968 constructor(locale: string | Array<string>, options?: DateTimeOptions); 969 970 /** 971 * Obtains the formatted date strings. 972 * 973 * @param { Date } date - Indicates the Date object to be formatted. 974 * @returns { string } a date string formatted based on the specified locale. 975 * @syscap SystemCapability.Global.I18n 976 * @since 6 977 */ 978 /** 979 * Obtains the formatted date strings. 980 * 981 * @param { Date } date - Indicates the Date object to be formatted. 982 * @returns { string } a date string formatted based on the specified locale. 983 * @syscap SystemCapability.Global.I18n 984 * @crossplatform 985 * @since 10 986 */ 987 format(date: Date): string; 988 989 /** 990 * Obtains the formatted date strings of a date range. 991 * 992 * @param { Date } startDate - Indicates the start date of the date range. 993 * @param { Date } endDate - Indicates the end date of the date range. 994 * @returns { string } a date string formatted based on the specified locale. 995 * @syscap SystemCapability.Global.I18n 996 * @since 6 997 */ 998 /** 999 * Obtains the formatted date strings of a date range. 1000 * 1001 * @param { Date } startDate - Indicates the start date of the date range. 1002 * @param { Date } endDate - Indicates the end date of the date range. 1003 * @returns { string } a date string formatted based on the specified locale. 1004 * @syscap SystemCapability.Global.I18n 1005 * @crossplatform 1006 * @since 10 1007 */ 1008 formatRange(startDate: Date, endDate: Date): string; 1009 1010 /** 1011 * Obtains the options of the DateTimeFormat object. 1012 * 1013 * @returns { DateTimeOptions } the options of the DateTimeFormat object. 1014 * @syscap SystemCapability.Global.I18n 1015 * @since 6 1016 */ 1017 /** 1018 * Obtains the options of the DateTimeFormat object. 1019 * 1020 * @returns { DateTimeOptions } the options of the DateTimeFormat object. 1021 * @syscap SystemCapability.Global.I18n 1022 * @crossplatform 1023 * @since 10 1024 */ 1025 resolvedOptions(): DateTimeOptions; 1026 } 1027 1028 /** 1029 * Provides the options of number format. 1030 * 1031 * @interface NumberOptions 1032 * @syscap SystemCapability.Global.I18n 1033 * @since 6 1034 */ 1035 /** 1036 * Provides the options of number format. 1037 * 1038 * @interface NumberOptions 1039 * @syscap SystemCapability.Global.I18n 1040 * @crossplatform 1041 * @since 10 1042 */ 1043 export interface NumberOptions { 1044 /** 1045 * Indicates the locale. 1046 * 1047 * @type { string } 1048 * @syscap SystemCapability.Global.I18n 1049 * @since 6 1050 */ 1051 /** 1052 * Indicates the locale. 1053 * 1054 * @type { ?string } 1055 * @syscap SystemCapability.Global.I18n 1056 * @since 9 1057 */ 1058 /** 1059 * Indicates the locale. 1060 * 1061 * @type { ?string } 1062 * @syscap SystemCapability.Global.I18n 1063 * @crossplatform 1064 * @since 10 1065 */ 1066 locale?: string; 1067 1068 /** 1069 * Indicates the currency. 1070 * 1071 * @type { string } 1072 * @syscap SystemCapability.Global.I18n 1073 * @since 6 1074 */ 1075 /** 1076 * Indicates the currency. 1077 * 1078 * @type { ?string } 1079 * @syscap SystemCapability.Global.I18n 1080 * @since 9 1081 */ 1082 /** 1083 * Indicates the currency. 1084 * 1085 * @type { ?string } 1086 * @syscap SystemCapability.Global.I18n 1087 * @crossplatform 1088 * @since 10 1089 */ 1090 currency?: string; 1091 1092 /** 1093 * Indicates the currencySign. 1094 * 1095 * @type { string } 1096 * @syscap SystemCapability.Global.I18n 1097 * @since 6 1098 */ 1099 /** 1100 * Indicates the currencySign. 1101 * 1102 * @type { ?string } 1103 * @syscap SystemCapability.Global.I18n 1104 * @since 9 1105 */ 1106 /** 1107 * Indicates the currencySign. 1108 * 1109 * @type { ?string } 1110 * @syscap SystemCapability.Global.I18n 1111 * @crossplatform 1112 * @since 10 1113 */ 1114 currencySign?: string; 1115 1116 /** 1117 * Indicates the currencyDisplay. 1118 * 1119 * @type { string } 1120 * @syscap SystemCapability.Global.I18n 1121 * @since 6 1122 */ 1123 /** 1124 * Indicates the currencyDisplay. 1125 * 1126 * @type { ?string } 1127 * @syscap SystemCapability.Global.I18n 1128 * @since 9 1129 */ 1130 /** 1131 * Indicates the currencyDisplay. 1132 * 1133 * @type { ?string } 1134 * @syscap SystemCapability.Global.I18n 1135 * @crossplatform 1136 * @since 10 1137 */ 1138 currencyDisplay?: string; 1139 1140 /** 1141 * Indicates the unit. 1142 * 1143 * @type { string } 1144 * @syscap SystemCapability.Global.I18n 1145 * @since 6 1146 */ 1147 /** 1148 * Indicates the unit. 1149 * 1150 * @type { ?string } 1151 * @syscap SystemCapability.Global.I18n 1152 * @since 9 1153 */ 1154 /** 1155 * Indicates the unit. 1156 * 1157 * @type { ?string } 1158 * @syscap SystemCapability.Global.I18n 1159 * @crossplatform 1160 * @since 10 1161 */ 1162 unit?: string; 1163 1164 /** 1165 * Indicates the unitDisplay. 1166 * 1167 * @type { string } 1168 * @syscap SystemCapability.Global.I18n 1169 * @since 6 1170 */ 1171 /** 1172 * Indicates the unitDisplay. 1173 * 1174 * @type { ?string } 1175 * @syscap SystemCapability.Global.I18n 1176 * @since 9 1177 */ 1178 /** 1179 * Indicates the unitDisplay. 1180 * 1181 * @type { ?string } 1182 * @syscap SystemCapability.Global.I18n 1183 * @crossplatform 1184 * @since 10 1185 */ 1186 unitDisplay?: string; 1187 1188 /** 1189 * Indicates the unitUsage. 1190 * 1191 * @type { string } 1192 * @syscap SystemCapability.Global.I18n 1193 * @since 8 1194 */ 1195 /** 1196 * Indicates the unitUsage. 1197 * 1198 * @type { ?string } 1199 * @syscap SystemCapability.Global.I18n 1200 * @since 9 1201 */ 1202 /** 1203 * Indicates the unitUsage. 1204 * 1205 * @type { ?string } 1206 * @syscap SystemCapability.Global.I18n 1207 * @crossplatform 1208 * @since 10 1209 */ 1210 unitUsage?: string; 1211 1212 /** 1213 * Indicates the signDisplay. 1214 * 1215 * @type { string } 1216 * @syscap SystemCapability.Global.I18n 1217 * @since 6 1218 */ 1219 /** 1220 * Indicates the signDisplay. 1221 * 1222 * @type { ?string } 1223 * @syscap SystemCapability.Global.I18n 1224 * @since 9 1225 */ 1226 /** 1227 * Indicates the signDisplay. 1228 * 1229 * @type { ?string } 1230 * @syscap SystemCapability.Global.I18n 1231 * @crossplatform 1232 * @since 10 1233 */ 1234 signDisplay?: string; 1235 1236 /** 1237 * Indicates the compactDisplay. 1238 * 1239 * @type { string } 1240 * @syscap SystemCapability.Global.I18n 1241 * @since 6 1242 */ 1243 /** 1244 * Indicates the compactDisplay. 1245 * 1246 * @type { ?string } 1247 * @syscap SystemCapability.Global.I18n 1248 * @since 9 1249 */ 1250 /** 1251 * Indicates the compactDisplay. 1252 * 1253 * @type { ?string } 1254 * @syscap SystemCapability.Global.I18n 1255 * @crossplatform 1256 * @since 10 1257 */ 1258 compactDisplay?: string; 1259 1260 /** 1261 * Indicates the notation. 1262 * 1263 * @type { string } 1264 * @syscap SystemCapability.Global.I18n 1265 * @since 6 1266 */ 1267 /** 1268 * Indicates the notation. 1269 * 1270 * @type { ?string } 1271 * @syscap SystemCapability.Global.I18n 1272 * @since 9 1273 */ 1274 /** 1275 * Indicates the notation. 1276 * 1277 * @type { ?string } 1278 * @syscap SystemCapability.Global.I18n 1279 * @crossplatform 1280 * @since 10 1281 */ 1282 notation?: string; 1283 1284 /** 1285 * Indicates the localeMatcher. 1286 * 1287 * @type { string } 1288 * @syscap SystemCapability.Global.I18n 1289 * @since 6 1290 */ 1291 /** 1292 * Indicates the localeMatcher. 1293 * 1294 * @type { ?string } 1295 * @syscap SystemCapability.Global.I18n 1296 * @since 9 1297 */ 1298 /** 1299 * Indicates the localeMatcher. 1300 * 1301 * @type { ?string } 1302 * @syscap SystemCapability.Global.I18n 1303 * @crossplatform 1304 * @since 10 1305 */ 1306 localeMatcher?: string; 1307 1308 /** 1309 * Indicates the style. 1310 * 1311 * @type { string } 1312 * @syscap SystemCapability.Global.I18n 1313 * @since 6 1314 */ 1315 /** 1316 * Indicates the style. 1317 * 1318 * @type { ?string } 1319 * @syscap SystemCapability.Global.I18n 1320 * @since 9 1321 */ 1322 /** 1323 * Indicates the style. 1324 * 1325 * @type { ?string } 1326 * @syscap SystemCapability.Global.I18n 1327 * @crossplatform 1328 * @since 10 1329 */ 1330 style?: string; 1331 1332 /** 1333 * Indicates the numberingSystem. 1334 * 1335 * @type { string } 1336 * @syscap SystemCapability.Global.I18n 1337 * @since 6 1338 */ 1339 /** 1340 * Indicates the numberingSystem. 1341 * 1342 * @type { ?string } 1343 * @syscap SystemCapability.Global.I18n 1344 * @since 9 1345 */ 1346 /** 1347 * Indicates the numberingSystem. 1348 * 1349 * @type { ?string } 1350 * @syscap SystemCapability.Global.I18n 1351 * @crossplatform 1352 * @since 10 1353 */ 1354 numberingSystem?: string; 1355 1356 /** 1357 * Indicates the useGrouping. 1358 * 1359 * @type { boolean } 1360 * @syscap SystemCapability.Global.I18n 1361 * @since 6 1362 */ 1363 /** 1364 * Indicates the useGrouping. 1365 * 1366 * @type { ?boolean } 1367 * @syscap SystemCapability.Global.I18n 1368 * @since 9 1369 */ 1370 /** 1371 * Indicates the useGrouping. 1372 * 1373 * @type { ?boolean } 1374 * @syscap SystemCapability.Global.I18n 1375 * @crossplatform 1376 * @since 10 1377 */ 1378 useGrouping?: boolean; 1379 1380 /** 1381 * Indicates the minimumIntegerDigits. 1382 * 1383 * @type { number } 1384 * @syscap SystemCapability.Global.I18n 1385 * @since 6 1386 */ 1387 /** 1388 * Indicates the minimumIntegerDigits. 1389 * 1390 * @type { ?number } 1391 * @syscap SystemCapability.Global.I18n 1392 * @since 9 1393 */ 1394 /** 1395 * Indicates the minimumIntegerDigits. 1396 * 1397 * @type { ?number } 1398 * @syscap SystemCapability.Global.I18n 1399 * @crossplatform 1400 * @since 10 1401 */ 1402 minimumIntegerDigits?: number; 1403 1404 /** 1405 * Indicates the minimumFractionDigits. 1406 * 1407 * @type { number } 1408 * @syscap SystemCapability.Global.I18n 1409 * @since 6 1410 */ 1411 /** 1412 * Indicates the minimumFractionDigits. 1413 * 1414 * @type { ?number } 1415 * @syscap SystemCapability.Global.I18n 1416 * @since 9 1417 */ 1418 /** 1419 * Indicates the minimumFractionDigits. 1420 * 1421 * @type { ?number } 1422 * @syscap SystemCapability.Global.I18n 1423 * @crossplatform 1424 * @since 10 1425 */ 1426 minimumFractionDigits?: number; 1427 1428 /** 1429 * Indicates the maximumFractionDigits. 1430 * 1431 * @type { number } 1432 * @syscap SystemCapability.Global.I18n 1433 * @since 6 1434 */ 1435 /** 1436 * Indicates the maximumFractionDigits. 1437 * 1438 * @type { ?number } 1439 * @syscap SystemCapability.Global.I18n 1440 * @since 9 1441 */ 1442 /** 1443 * Indicates the maximumFractionDigits. 1444 * 1445 * @type { ?number } 1446 * @syscap SystemCapability.Global.I18n 1447 * @crossplatform 1448 * @since 10 1449 */ 1450 maximumFractionDigits?: number; 1451 1452 /** 1453 * Indicates the minimumSignificantDigits. 1454 * 1455 * @type { number } 1456 * @syscap SystemCapability.Global.I18n 1457 * @since 6 1458 */ 1459 /** 1460 * Indicates the minimumSignificantDigits. 1461 * 1462 * @type { ?number } 1463 * @syscap SystemCapability.Global.I18n 1464 * @since 9 1465 */ 1466 /** 1467 * Indicates the minimumSignificantDigits. 1468 * 1469 * @type { ?number } 1470 * @syscap SystemCapability.Global.I18n 1471 * @crossplatform 1472 * @since 10 1473 */ 1474 minimumSignificantDigits?: number; 1475 1476 /** 1477 * Indicates the maximumSignificantDigits. 1478 * 1479 * @type { number } 1480 * @syscap SystemCapability.Global.I18n 1481 * @since 6 1482 */ 1483 /** 1484 * Indicates the maximumSignificantDigits. 1485 * 1486 * @type { ?number } 1487 * @syscap SystemCapability.Global.I18n 1488 * @since 9 1489 */ 1490 /** 1491 * Indicates the maximumSignificantDigits. 1492 * 1493 * @type { ?number } 1494 * @syscap SystemCapability.Global.I18n 1495 * @crossplatform 1496 * @since 10 1497 */ 1498 maximumSignificantDigits?: number; 1499 } 1500 1501 /** 1502 * Provides the API for formatting number strings. 1503 * 1504 * @syscap SystemCapability.Global.I18n 1505 * @since 6 1506 */ 1507 /** 1508 * Provides the API for formatting number strings. 1509 * 1510 * @syscap SystemCapability.Global.I18n 1511 * @crossplatform 1512 * @since 10 1513 */ 1514 export class NumberFormat { 1515 /** 1516 * A constructor used to create a NumberFormat object. 1517 * 1518 * @syscap SystemCapability.Global.I18n 1519 * @since 8 1520 */ 1521 /** 1522 * A constructor used to create a NumberFormat object. 1523 * 1524 * @syscap SystemCapability.Global.I18n 1525 * @crossplatform 1526 * @since 10 1527 */ 1528 constructor(); 1529 1530 /** 1531 * A constructor used to create a NumberFormat object. 1532 * 1533 * @param { string | Array<string> } locale - Indicates a character string containing the locale information, including 1534 * the language and optionally the script and region, for the NumberFormat object. 1535 * @param { NumberOptions } [options] - Indicates the options used to format the number. 1536 * @syscap SystemCapability.Global.I18n 1537 * @since 6 1538 */ 1539 /** 1540 * A constructor used to create a NumberFormat object. 1541 * 1542 * @param { string | Array<string> } locale - Indicates a character string containing the locale information, including 1543 * the language and optionally the script and region, for the NumberFormat object. 1544 * @param { NumberOptions } [options] - Indicates the options used to format the number. 1545 * @syscap SystemCapability.Global.I18n 1546 * @crossplatform 1547 * @since 10 1548 */ 1549 constructor(locale: string | Array<string>, options?: NumberOptions); 1550 1551 /** 1552 * Obtains the formatted number string. 1553 * 1554 * @param { number } number Indicates the number to be formatted. 1555 * @returns { string } a number string formatted based on the specified locale. 1556 * @syscap SystemCapability.Global.I18n 1557 * @since 6 1558 */ 1559 /** 1560 * Obtains the formatted number string. 1561 * 1562 * @param { number } number Indicates the number to be formatted. 1563 * @returns { string } a number string formatted based on the specified locale. 1564 * @syscap SystemCapability.Global.I18n 1565 * @crossplatform 1566 * @since 10 1567 */ 1568 format(number: number): string; 1569 1570 /** 1571 * Obtains the options of the NumberFormat object. 1572 * 1573 * @returns { NumberOptions } the options of the NumberFormat object. 1574 * @syscap SystemCapability.Global.I18n 1575 * @since 6 1576 */ 1577 /** 1578 * Obtains the options of the NumberFormat object. 1579 * 1580 * @returns { NumberOptions } the options of the NumberFormat object. 1581 * @syscap SystemCapability.Global.I18n 1582 * @crossplatform 1583 * @since 10 1584 */ 1585 resolvedOptions(): NumberOptions; 1586 } 1587 1588 /** 1589 * Provides the options of Collator 1590 * 1591 * @interface CollatorOptions 1592 * @syscap SystemCapability.Global.I18n 1593 * @since 8 1594 */ 1595 /** 1596 * Provides the options of Collator 1597 * 1598 * @interface CollatorOptions 1599 * @syscap SystemCapability.Global.I18n 1600 * @crossplatform 1601 * @since 10 1602 */ 1603 export interface CollatorOptions { 1604 /** 1605 * The locale matching algorithm to use. 1606 * Possible values are "lookup" and "best fit"; the default is "best fit". 1607 * 1608 * @type { string } 1609 * @syscap SystemCapability.Global.I18n 1610 * @since 8 1611 */ 1612 /** 1613 * The locale matching algorithm to use. 1614 * Possible values are "lookup" and "best fit"; the default is "best fit". 1615 * 1616 * @type { ?string } 1617 * @syscap SystemCapability.Global.I18n 1618 * @since 9 1619 */ 1620 /** 1621 * The locale matching algorithm to use. 1622 * Possible values are "lookup" and "best fit"; the default is "best fit". 1623 * 1624 * @type { ?string } 1625 * @syscap SystemCapability.Global.I18n 1626 * @crossplatform 1627 * @since 10 1628 */ 1629 localeMatcher?: string; 1630 1631 /** 1632 * Whether the comparison is for sorting or for searching for matching strings. 1633 * Possible values are "sort" and "search"; the default is "sort". 1634 * 1635 * @type { string } 1636 * @syscap SystemCapability.Global.I18n 1637 * @since 8 1638 */ 1639 /** 1640 * Whether the comparison is for sorting or for searching for matching strings. 1641 * Possible values are "sort" and "search"; the default is "sort". 1642 * 1643 * @type { ?string } 1644 * @syscap SystemCapability.Global.I18n 1645 * @since 9 1646 */ 1647 /** 1648 * Whether the comparison is for sorting or for searching for matching strings. 1649 * Possible values are "sort" and "search"; the default is "sort". 1650 * 1651 * @type { ?string } 1652 * @syscap SystemCapability.Global.I18n 1653 * @crossplatform 1654 * @since 10 1655 */ 1656 usage?: string; 1657 1658 /** 1659 * Which differences in the strings should lead to non-zero result values. 1660 * Possible values are "base", "accent", "case", "variant". 1661 * "base" are used when only strings that differ in base letters compare as unequal. 1662 * "accent" are used when only strings that differ in base letters or accents and 1663 * other diacritic marks compare as unequal. 1664 * "case" are used when only strings that differ in base letters or case compare as unequal. 1665 * "variant" are used when Strings that differ in base letters, accents and other diacritic marks, 1666 * or case compare as unequal. 1667 * 1668 * @type { string } 1669 * @syscap SystemCapability.Global.I18n 1670 * @since 8 1671 */ 1672 /** 1673 * Which differences in the strings should lead to non-zero result values. 1674 * Possible values are "base", "accent", "case", "variant". 1675 * "base" are used when only strings that differ in base letters compare as unequal. 1676 * "accent" are used when only strings that differ in base letters or accents and 1677 * other diacritic marks compare as unequal. 1678 * "case" are used when only strings that differ in base letters or case compare as unequal. 1679 * "variant" are used when Strings that differ in base letters, accents and other diacritic marks, 1680 * or case compare as unequal. 1681 * 1682 * @type { ?string } 1683 * @syscap SystemCapability.Global.I18n 1684 * @since 9 1685 */ 1686 /** 1687 * Which differences in the strings should lead to non-zero result values. 1688 * Possible values are "base", "accent", "case", "variant". 1689 * "base" are used when only strings that differ in base letters compare as unequal. 1690 * "accent" are used when only strings that differ in base letters or accents and 1691 * other diacritic marks compare as unequal. 1692 * "case" are used when only strings that differ in base letters or case compare as unequal. 1693 * "variant" are used when Strings that differ in base letters, accents and other diacritic marks, 1694 * or case compare as unequal. 1695 * 1696 * @type { ?string } 1697 * @syscap SystemCapability.Global.I18n 1698 * @crossplatform 1699 * @since 10 1700 */ 1701 sensitivity?: string; 1702 1703 /** 1704 * Whether punctuation should be ignored. default value is false. 1705 * 1706 * @type { boolean } 1707 * @syscap SystemCapability.Global.I18n 1708 * @since 8 1709 */ 1710 /** 1711 * Whether punctuation should be ignored. Default value is false. 1712 * 1713 * @type { ?boolean } 1714 * @syscap SystemCapability.Global.I18n 1715 * @since 9 1716 */ 1717 /** 1718 * Whether punctuation should be ignored. Default value is false. 1719 * 1720 * @type { ?boolean } 1721 * @syscap SystemCapability.Global.I18n 1722 * @crossplatform 1723 * @since 10 1724 */ 1725 ignorePunctuation?: boolean; 1726 1727 /** 1728 * Variant collations for certain locales. 1729 * 1730 * @type { string } 1731 * @syscap SystemCapability.Global.I18n 1732 * @since 8 1733 */ 1734 /** 1735 * Variant collations for certain locales. 1736 * 1737 * @type { ?string } 1738 * @syscap SystemCapability.Global.I18n 1739 * @since 9 1740 */ 1741 /** 1742 * Variant collations for certain locales. 1743 * 1744 * @type { ?string } 1745 * @syscap SystemCapability.Global.I18n 1746 * @crossplatform 1747 * @since 10 1748 */ 1749 collation?: string; 1750 1751 /** 1752 * Whether numeric collation should be used. Default value is false. 1753 * 1754 * @type { boolean } 1755 * @syscap SystemCapability.Global.I18n 1756 * @since 8 1757 */ 1758 /** 1759 * Whether numeric collation should be used. Default value is false. 1760 * 1761 * @type { ?boolean } 1762 * @syscap SystemCapability.Global.I18n 1763 * @since 9 1764 */ 1765 /** 1766 * Whether numeric collation should be used. Default value is false. 1767 * 1768 * @type { ?boolean } 1769 * @syscap SystemCapability.Global.I18n 1770 * @crossplatform 1771 * @since 10 1772 */ 1773 numeric?: boolean; 1774 1775 /** 1776 * Whether upper case or lower case should sort first. 1777 * Possible values are "upper", "lower", or "false" (use the locale's default). 1778 * 1779 * @type { string } 1780 * @syscap SystemCapability.Global.I18n 1781 * @since 8 1782 */ 1783 /** 1784 * Whether upper case or lower case should sort first. 1785 * Possible values are "upper", "lower", or "false" (use the locale's default). 1786 * 1787 * @type { ?string } 1788 * @syscap SystemCapability.Global.I18n 1789 * @since 9 1790 */ 1791 /** 1792 * Whether upper case or lower case should sort first. 1793 * Possible values are "upper", "lower", or "false" (use the locale's default). 1794 * 1795 * @type { ?string } 1796 * @syscap SystemCapability.Global.I18n 1797 * @crossplatform 1798 * @since 10 1799 */ 1800 caseFirst?: string; 1801 } 1802 1803 /** 1804 * Enable language-sensitive string comparison. 1805 * 1806 * @syscap SystemCapability.Global.I18n 1807 * @since 8 1808 */ 1809 /** 1810 * Enable language-sensitive string comparison. 1811 * 1812 * @syscap SystemCapability.Global.I18n 1813 * @crossplatform 1814 * @since 10 1815 */ 1816 export class Collator { 1817 /** 1818 * A constructor used to create Collator object. 1819 * 1820 * @syscap SystemCapability.Global.I18n 1821 * @since 8 1822 */ 1823 /** 1824 * A constructor used to create Collator object. 1825 * 1826 * @syscap SystemCapability.Global.I18n 1827 * @crossplatform 1828 * @since 10 1829 */ 1830 constructor(); 1831 /** 1832 * A constructor used to create Collator Object; 1833 * 1834 * @param { string | Array<string> } locale - Indicates a character string containing the locale information, including 1835 * the language and optionally the script and region, for the Collator object. 1836 * @param { CollatorOptions } [options] - Indicates the options used to initialize Collator object. 1837 * @syscap SystemCapability.Global.I18n 1838 * @since 8 1839 */ 1840 /** 1841 * A constructor used to create Collator Object; 1842 * 1843 * @param { string | Array<string> } locale - Indicates a character string containing the locale information, including 1844 * the language and optionally the script and region, for the Collator object. 1845 * @param { CollatorOptions } [options] - Indicates the options used to initialize Collator object. 1846 * @syscap SystemCapability.Global.I18n 1847 * @crossplatform 1848 * @since 10 1849 */ 1850 constructor(locale: string | Array<string>, options?: CollatorOptions); 1851 1852 /** 1853 * compares two strings according to the sort order of this Collator object 1854 * 1855 * @param { string } first - The first string to compare. 1856 * @param { string } second - The second string to compare. 1857 * @returns { number } a number indicating how first compare to second: 1858 * a negative value if string1 comes before string2; 1859 * a positive value if string1 comes after string2; 1860 * 0 if they are considered equal. 1861 * @syscap SystemCapability.Global.I18n 1862 * @since 8 1863 */ 1864 /** 1865 * compares two strings according to the sort order of this Collator object 1866 * 1867 * @param { string } first - The first string to compare. 1868 * @param { string } second - The second string to compare. 1869 * @returns { number } a number indicating how first compare to second: 1870 * a negative value if string1 comes before string2; 1871 * a positive value if string1 comes after string2; 1872 * 0 if they are considered equal. 1873 * @syscap SystemCapability.Global.I18n 1874 * @crossplatform 1875 * @since 10 1876 */ 1877 compare(first: string, second: string): number; 1878 1879 /** 1880 * Returns a new object with properties that reflect the locale and collation options computed 1881 * during initialization of the object. 1882 * 1883 * @returns { CollatorOptions } a CollatorOptions object with properties that reflect the properties of this object. 1884 * @syscap SystemCapability.Global.I18n 1885 * @since 8 1886 */ 1887 /** 1888 * Returns a new object with properties that reflect the locale and collation options computed 1889 * during initialization of the object. 1890 * 1891 * @returns { CollatorOptions } a CollatorOptions object with properties that reflect the properties of this object. 1892 * @syscap SystemCapability.Global.I18n 1893 * @crossplatform 1894 * @since 10 1895 */ 1896 resolvedOptions(): CollatorOptions; 1897 } 1898 1899 /** 1900 * Provides the options of PluralRules 1901 * 1902 * @interface PluralRulesOptions 1903 * @syscap SystemCapability.Global.I18n 1904 * @since 8 1905 */ 1906 /** 1907 * Provides the options of PluralRules 1908 * 1909 * @interface PluralRulesOptions 1910 * @syscap SystemCapability.Global.I18n 1911 * @crossplatform 1912 * @since 10 1913 */ 1914 export interface PluralRulesOptions { 1915 /** 1916 * The locale matching algorithm to use. 1917 * Possible values are "lookup" and "best fit"; the default is "best fit". 1918 * 1919 * @type { string } 1920 * @syscap SystemCapability.Global.I18n 1921 * @since 8 1922 */ 1923 /** 1924 * The locale matching algorithm to use. 1925 * Possible values are "lookup" and "best fit"; the default is "best fit". 1926 * 1927 * @type { ?string } 1928 * @syscap SystemCapability.Global.I18n 1929 * @since 9 1930 */ 1931 /** 1932 * The locale matching algorithm to use. 1933 * Possible values are "lookup" and "best fit"; the default is "best fit". 1934 * 1935 * @type { ?string } 1936 * @syscap SystemCapability.Global.I18n 1937 * @crossplatform 1938 * @since 10 1939 */ 1940 localeMatcher?: string; 1941 1942 /** 1943 * The type to use. Possible values are: "cardinal", "ordinal" 1944 * 1945 * @type { string } 1946 * @syscap SystemCapability.Global.I18n 1947 * @since 8 1948 */ 1949 /** 1950 * The type to use. Possible values are: "cardinal", "ordinal" 1951 * 1952 * @type { ?string } 1953 * @syscap SystemCapability.Global.I18n 1954 * @since 9 1955 */ 1956 /** 1957 * The type to use. Possible values are: "cardinal", "ordinal" 1958 * 1959 * @type { ?string } 1960 * @syscap SystemCapability.Global.I18n 1961 * @crossplatform 1962 * @since 10 1963 */ 1964 type?: string; 1965 1966 /** 1967 * The minimum number of integer digits to use. 1968 * Possible values are from 1 to 21; the default is 1. 1969 * 1970 * @type { number } 1971 * @syscap SystemCapability.Global.I18n 1972 * @since 8 1973 */ 1974 /** 1975 * The minimum number of integer digits to use. 1976 * Possible values are from 1 to 21; the default is 1. 1977 * 1978 * @type { ?number } 1979 * @syscap SystemCapability.Global.I18n 1980 * @since 9 1981 */ 1982 /** 1983 * The minimum number of integer digits to use. 1984 * Possible values are from 1 to 21; the default is 1. 1985 * 1986 * @type { ?number } 1987 * @syscap SystemCapability.Global.I18n 1988 * @crossplatform 1989 * @since 10 1990 */ 1991 minimumIntegerDigits?: number; 1992 1993 /** 1994 * The minimum number of fraction digits to use. 1995 * Possible values are from 0 to 20; the default for plain number and percent formatting is 0; 1996 * 1997 * @type { number } 1998 * @syscap SystemCapability.Global.I18n 1999 * @since 8 2000 */ 2001 /** 2002 * The minimum number of fraction digits to use. 2003 * Possible values are from 0 to 20; the default for plain number and percent formatting is 0; 2004 * 2005 * @type { ?number } 2006 * @syscap SystemCapability.Global.I18n 2007 * @since 9 2008 */ 2009 /** 2010 * The minimum number of fraction digits to use. 2011 * Possible values are from 0 to 20; the default for plain number and percent formatting is 0; 2012 * 2013 * @type { ?number } 2014 * @syscap SystemCapability.Global.I18n 2015 * @crossplatform 2016 * @since 10 2017 */ 2018 minimumFractionDigits?: number; 2019 2020 /** 2021 * The maximum number of fraction digits to use. 2022 * Possible values are from 0 to 20; 2023 * the default for plain number formatting is the larger of minimumFractionDigits and 3; 2024 * 2025 * @type { number } 2026 * @syscap SystemCapability.Global.I18n 2027 * @since 8 2028 */ 2029 /** 2030 * The maximum number of fraction digits to use. 2031 * Possible values are from 0 to 20; 2032 * the default for plain number formatting is the larger of minimumFractionDigits and 3; 2033 * 2034 * @type { ?number } 2035 * @syscap SystemCapability.Global.I18n 2036 * @since 9 2037 */ 2038 /** 2039 * The maximum number of fraction digits to use. 2040 * Possible values are from 0 to 20; 2041 * the default for plain number formatting is the larger of minimumFractionDigits and 3; 2042 * 2043 * @type { ?number } 2044 * @syscap SystemCapability.Global.I18n 2045 * @crossplatform 2046 * @since 10 2047 */ 2048 maximumFractionDigits?: number; 2049 2050 /** 2051 * The minimum number of significant digits to use. 2052 * Possible values are from 1 to 21; the default is 1. 2053 * 2054 * @type { number } 2055 * @syscap SystemCapability.Global.I18n 2056 * @since 8 2057 */ 2058 /** 2059 * The minimum number of significant digits to use. 2060 * Possible values are from 1 to 21; the default is 1. 2061 * 2062 * @type { ?number } 2063 * @syscap SystemCapability.Global.I18n 2064 * @since 9 2065 */ 2066 /** 2067 * The minimum number of significant digits to use. 2068 * Possible values are from 1 to 21; the default is 1. 2069 * 2070 * @type { ?number } 2071 * @syscap SystemCapability.Global.I18n 2072 * @crossplatform 2073 * @since 10 2074 */ 2075 minimumSignificantDigits?: number; 2076 2077 /** 2078 * The maximum number of significant digits to use. 2079 * Possible values are from 1 to 21; the default is 21. 2080 * 2081 * @type { number } 2082 * @syscap SystemCapability.Global.I18n 2083 * @since 8 2084 */ 2085 /** 2086 * The maximum number of significant digits to use. 2087 * Possible values are from 1 to 21; the default is 21. 2088 * 2089 * @type { ?number } 2090 * @syscap SystemCapability.Global.I18n 2091 * @since 9 2092 */ 2093 /** 2094 * The maximum number of significant digits to use. 2095 * Possible values are from 1 to 21; the default is 21. 2096 * 2097 * @type { ?number } 2098 * @syscap SystemCapability.Global.I18n 2099 * @crossplatform 2100 * @since 10 2101 */ 2102 maximumSignificantDigits?: number; 2103 } 2104 2105 /** 2106 * Enables plural-sensitive formatting and plural-related language rules. 2107 * 2108 * @syscap SystemCapability.Global.I18n 2109 * @since 8 2110 */ 2111 /** 2112 * Enables plural-sensitive formatting and plural-related language rules. 2113 * 2114 * @syscap SystemCapability.Global.I18n 2115 * @crossplatform 2116 * @since 10 2117 */ 2118 export class PluralRules { 2119 /** 2120 * A constructor used to create PluralRules object. 2121 * 2122 * @syscap SystemCapability.Global.I18n 2123 * @since 8 2124 */ 2125 /** 2126 * A constructor used to create PluralRules object. 2127 * 2128 * @syscap SystemCapability.Global.I18n 2129 * @crossplatform 2130 * @since 10 2131 */ 2132 constructor(); 2133 2134 /** 2135 * A constructor used to create PluralRules object. 2136 * 2137 * @param { string | Array<string> } locale - Indicates a character string containing the locale information, including 2138 * the language and optionally the script and region, for the PluralRules object. 2139 * @param { PluralRulesOptions } [options] - Indicates the options used to initialize PluralRules object. 2140 * @syscap SystemCapability.Global.I18n 2141 * @since 8 2142 */ 2143 /** 2144 * A constructor used to create PluralRules object. 2145 * 2146 * @param { string | Array<string> } locale - Indicates a character string containing the locale information, including 2147 * the language and optionally the script and region, for the PluralRules object. 2148 * @param { PluralRulesOptions } [options] - Indicates the options used to initialize PluralRules object. 2149 * @syscap SystemCapability.Global.I18n 2150 * @crossplatform 2151 * @since 10 2152 */ 2153 constructor(locale: string | Array<string>, options?: PluralRulesOptions); 2154 2155 /** 2156 * Returns a string indicating which plural rule to use for locale-aware formatting. 2157 * 2158 * @param { number } n - The number to get a plural rule for. 2159 * @returns { string } A string representing the pluralization category of the number, 2160 * can be one of zero, one, two, few, many or other. 2161 * @syscap SystemCapability.Global.I18n 2162 * @since 8 2163 */ 2164 /** 2165 * Returns a string indicating which plural rule to use for locale-aware formatting. 2166 * 2167 * @param { number } n - The number to get a plural rule for. 2168 * @returns { string } A string representing the pluralization category of the number, 2169 * can be one of zero, one, two, few, many or other. 2170 * @syscap SystemCapability.Global.I18n 2171 * @crossplatform 2172 * @since 10 2173 */ 2174 select(n: number): string; 2175 } 2176 2177 /** 2178 * Provides the input options of RelativeTimeFormat. 2179 * 2180 * @interface RelativeTimeFormatInputOptions 2181 * @syscap SystemCapability.Global.I18n 2182 * @since 8 2183 */ 2184 /** 2185 * Provides the input options of RelativeTimeFormat. 2186 * 2187 * @interface RelativeTimeFormatInputOptions 2188 * @syscap SystemCapability.Global.I18n 2189 * @crossplatform 2190 * @since 10 2191 */ 2192 export interface RelativeTimeFormatInputOptions { 2193 /** 2194 * The locale matching algorithm to use. 2195 * Possible values are: lookup, best fit 2196 * 2197 * @type { string } 2198 * @syscap SystemCapability.Global.I18n 2199 * @since 8 2200 */ 2201 /** 2202 * The locale matching algorithm to use. 2203 * Possible values are: lookup, best fit 2204 * 2205 * @type { ?string } 2206 * @syscap SystemCapability.Global.I18n 2207 * @since 9 2208 */ 2209 /** 2210 * The locale matching algorithm to use. 2211 * Possible values are: lookup, best fit 2212 * 2213 * @type { ?string } 2214 * @syscap SystemCapability.Global.I18n 2215 * @crossplatform 2216 * @since 10 2217 */ 2218 localeMatcher?: string; 2219 2220 /** 2221 * The format of output message. 2222 * Possible values are: always, auto 2223 * 2224 * @type { string } 2225 * @syscap SystemCapability.Global.I18n 2226 * @since 8 2227 */ 2228 /** 2229 * The format of output message. 2230 * Possible values are: always, auto 2231 * 2232 * @type { ?string } 2233 * @syscap SystemCapability.Global.I18n 2234 * @since 9 2235 */ 2236 /** 2237 * The format of output message. 2238 * Possible values are: always, auto 2239 * 2240 * @type { ?string } 2241 * @syscap SystemCapability.Global.I18n 2242 * @crossplatform 2243 * @since 10 2244 */ 2245 numeric?: string; 2246 2247 /** 2248 * The length of the internationalized message. 2249 * Possible values are: long, short, narrow 2250 * 2251 * @type { string } 2252 * @syscap SystemCapability.Global.I18n 2253 * @since 8 2254 */ 2255 /** 2256 * The length of the internationalized message. 2257 * Possible values are: long, short, narrow 2258 * 2259 * @type { ?string } 2260 * @syscap SystemCapability.Global.I18n 2261 * @since 9 2262 */ 2263 /** 2264 * The length of the internationalized message. 2265 * Possible values are: long, short, narrow 2266 * 2267 * @type { ?string } 2268 * @syscap SystemCapability.Global.I18n 2269 * @crossplatform 2270 * @since 10 2271 */ 2272 style?: string; 2273 } 2274 2275 /** 2276 * Provides the resolved options of RelativeTimeFormat. 2277 * 2278 * @interface RelativeTimeFormatResolvedOptions 2279 * @syscap SystemCapability.Global.I18n 2280 * @since 8 2281 */ 2282 /** 2283 * Provides the resolved options of RelativeTimeFormat. 2284 * 2285 * @interface RelativeTimeFormatResolvedOptions 2286 * @syscap SystemCapability.Global.I18n 2287 * @crossplatform 2288 * @since 10 2289 */ 2290 export interface RelativeTimeFormatResolvedOptions { 2291 /** 2292 * The BCP 47 language tag for the locale actually used. 2293 * 2294 * @syscap SystemCapability.Global.I18n 2295 * @since 8 2296 */ 2297 /** 2298 * The BCP 47 language tag for the locale actually used. 2299 * 2300 * @syscap SystemCapability.Global.I18n 2301 * @crossplatform 2302 * @since 10 2303 */ 2304 locale: string; 2305 2306 /** 2307 * The length of the internationalized message. 2308 * Possible values are: long, short, narrow 2309 * 2310 * @syscap SystemCapability.Global.I18n 2311 * @since 8 2312 */ 2313 /** 2314 * The length of the internationalized message. 2315 * Possible values are: long, short, narrow 2316 * 2317 * @syscap SystemCapability.Global.I18n 2318 * @crossplatform 2319 * @since 10 2320 */ 2321 style: string; 2322 2323 /** 2324 * The format of output message. 2325 * Possible values are: always, auto 2326 * 2327 * @syscap SystemCapability.Global.I18n 2328 * @since 8 2329 */ 2330 /** 2331 * The format of output message. 2332 * Possible values are: always, auto 2333 * 2334 * @syscap SystemCapability.Global.I18n 2335 * @crossplatform 2336 * @since 10 2337 */ 2338 numeric: string; 2339 2340 /** 2341 * The value requested using the Unicode extension key "nu" or filled in as a default. 2342 * 2343 * @syscap SystemCapability.Global.I18n 2344 * @since 8 2345 */ 2346 /** 2347 * The value requested using the Unicode extension key "nu" or filled in as a default. 2348 * 2349 * @syscap SystemCapability.Global.I18n 2350 * @crossplatform 2351 * @since 10 2352 */ 2353 numberingSystem: string; 2354 } 2355 2356 /** 2357 * Given a Time period length value and a unit, RelativeTimeFormat object enables 2358 * language-sensitive relative time formatting. 2359 * 2360 * @syscap SystemCapability.Global.I18n 2361 * @since 8 2362 */ 2363 /** 2364 * Given a Time period length value and a unit, RelativeTimeFormat object enables 2365 * language-sensitive relative time formatting. 2366 * 2367 * @syscap SystemCapability.Global.I18n 2368 * @crossplatform 2369 * @since 10 2370 */ 2371 export class RelativeTimeFormat { 2372 /** 2373 * A constructor used to create RelativeTimeFormat object. 2374 * 2375 * @syscap SystemCapability.Global.I18n 2376 * @since 8 2377 */ 2378 /** 2379 * A constructor used to create RelativeTimeFormat object. 2380 * 2381 * @syscap SystemCapability.Global.I18n 2382 * @crossplatform 2383 * @since 10 2384 */ 2385 constructor(); 2386 2387 /** 2388 * A constructor used to create RelativeTimeFormat object. 2389 * 2390 * @param { string | Array<string> } locale - Indicates a character string containing the locale information, including 2391 * the language and optionally the script and region, for the RelativeTimeFormat object. 2392 * @param { RelativeTimeFormatInputOptions } [options] - Indicates the options used to initialize RelativeTimeFormat object. 2393 * @syscap SystemCapability.Global.I18n 2394 * @since 8 2395 */ 2396 /** 2397 * A constructor used to create RelativeTimeFormat object. 2398 * 2399 * @param { string | Array<string> } locale - Indicates a character string containing the locale information, including 2400 * the language and optionally the script and region, for the RelativeTimeFormat object. 2401 * @param { RelativeTimeFormatInputOptions } [options] - Indicates the options used to initialize RelativeTimeFormat object. 2402 * @syscap SystemCapability.Global.I18n 2403 * @crossplatform 2404 * @since 10 2405 */ 2406 constructor(locale: string | Array<string>, options?: RelativeTimeFormatInputOptions); 2407 2408 /** 2409 * formats a value and unit according to the locale and formatting options of this object. 2410 * 2411 * @param { number } value - Numeric value to use in the internationalized relative time message. 2412 * @param { string } unit - Unit to use in the relative time internationalized message. 2413 * Possible values are: year, quarter, month, week, day, hour, minute, second. 2414 * @returns { string } formatted language-sensitive relative time. 2415 * @syscap SystemCapability.Global.I18n 2416 * @since 8 2417 */ 2418 /** 2419 * formats a value and unit according to the locale and formatting options of this object. 2420 * 2421 * @param { number } value - Numeric value to use in the internationalized relative time message. 2422 * @param { string } unit - Unit to use in the relative time internationalized message. 2423 * Possible values are: year, quarter, month, week, day, hour, minute, second. 2424 * @returns { string } formatted language-sensitive relative time. 2425 * @syscap SystemCapability.Global.I18n 2426 * @crossplatform 2427 * @since 10 2428 */ 2429 format(value: number, unit: string): string; 2430 2431 /** 2432 * returns an Array of objects representing the relative time format in parts that can be used for 2433 * custom locale-aware formatting 2434 * 2435 * @param { number } value - Numeric value to use in the internationalized relative time message. 2436 * @param { string } unit - to use in the relative time internationalized message. 2437 * Possible values are: year, quarter, month, week, day, hour, minute, second. 2438 * @returns { Array<object> } an Array of objects representing the relative time format in parts 2439 * @syscap SystemCapability.Global.I18n 2440 * @since 8 2441 */ 2442 /** 2443 * returns an Array of objects representing the relative time format in parts that can be used for 2444 * custom locale-aware formatting 2445 * 2446 * @param { number } value - Numeric value to use in the internationalized relative time message. 2447 * @param { string } unit - to use in the relative time internationalized message. 2448 * Possible values are: year, quarter, month, week, day, hour, minute, second. 2449 * @returns { Array<object> } an Array of objects representing the relative time format in parts 2450 * @syscap SystemCapability.Global.I18n 2451 * @crossplatform 2452 * @since 10 2453 */ 2454 formatToParts(value: number, unit: string): Array<object>; 2455 2456 /** 2457 * Returns a new object with properties that reflect the locale and formatting options computed during 2458 * initialization of the object. 2459 * 2460 * @returns { RelativeTimeFormatResolvedOptions } RelativeTimeFormatOptions which reflect the locale and formatting options of the object. 2461 * @syscap SystemCapability.Global.I18n 2462 * @since 8 2463 */ 2464 /** 2465 * Returns a new object with properties that reflect the locale and formatting options computed during 2466 * initialization of the object. 2467 * 2468 * @returns { RelativeTimeFormatResolvedOptions } RelativeTimeFormatOptions which reflect the locale and formatting options of the object. 2469 * @syscap SystemCapability.Global.I18n 2470 * @crossplatform 2471 * @since 10 2472 */ 2473 resolvedOptions(): RelativeTimeFormatResolvedOptions; 2474 } 2475} 2476export default intl; 2477