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