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/*** if arkts 1.1&1.2 */ 22import { BusinessError } from './@ohos.base'; 23import intl from './@ohos.intl'; 24/*** endif */ 25 26/** 27 * Provides international settings related APIs. 28 * 29 * @namespace i18n 30 * @syscap SystemCapability.Global.I18n 31 * @since 7 32 */ 33/** 34 * Provides international settings related APIs. 35 * 36 * @namespace i18n 37 * @syscap SystemCapability.Global.I18n 38 * @crossplatform 39 * @form 40 * @atomicservice 41 * @since arkts {'1.1':'11','1.2':'20'} 42 * @arkts 1.1&1.2 43 */ 44declare namespace i18n { 45 /** 46 * Obtains the localized name of the specified country/region. 47 * 48 * @param { string } country - Specified country. 49 * @param { string } locale - System locale, which consists of the language, script, and country/region. 50 * @param { boolean } [sentenceCase] - Whether to use sentence case to display the text. The value "true" means to 51 * display the text in title case format, and the value "false" means to display 52 * the text in the default case format of the locale. The default value is true. 53 * @returns { string } Localized script for the specified country. 54 * @syscap SystemCapability.Global.I18n 55 * @since 7 56 * @deprecated since 9 57 * @useinstead ohos.System.getDisplayCountry 58 */ 59 export function getDisplayCountry(country: string, locale: string, sentenceCase?: boolean): string; 60 61 /** 62 * Obtains the localized script for the specified language. 63 * 64 * @param { string } language - Specified language. 65 * @param { string } locale - System locale, which consists of the language, script, and country/region. 66 * @param { boolean } [sentenceCase] - Whether to use sentence case to display the text. The value "true" means to 67 * display the text in title case format, and the value "false" means to display 68 * the text in the default case format of the locale. The default value is true. 69 * @returns { string } Localized script for the specified language. 70 * @syscap SystemCapability.Global.I18n 71 * @since 7 72 * @deprecated since 9 73 * @useinstead ohos.System.getDisplayLanguage 74 */ 75 export function getDisplayLanguage(language: string, locale: string, sentenceCase?: boolean): string; 76 77 /** 78 * Obtains the system language. 79 * 80 * @returns { string } System language ID. 81 * @syscap SystemCapability.Global.I18n 82 * @since 7 83 * @deprecated since 9 84 * @useinstead ohos.System.getSystemLanguage 85 */ 86 export function getSystemLanguage(): string; 87 88 /** 89 * Obtains the system region. 90 * 91 * @returns { string } System region ID. 92 * @syscap SystemCapability.Global.I18n 93 * @since 7 94 * @deprecated since 9 95 * @useinstead ohos.System.getSystemRegion 96 */ 97 export function getSystemRegion(): string; 98 99 /** 100 * Obtains the system locale. 101 * 102 * @returns { string } System locale ID. 103 * @syscap SystemCapability.Global.I18n 104 * @since 7 105 * @deprecated since 9 106 * @useinstead ohos.System.getSystemLocale 107 */ 108 export function getSystemLocale(): string; 109 110 /** 111 * Provides system functions. 112 * 113 * @syscap SystemCapability.Global.I18n 114 * @since 9 115 */ 116 /** 117 * Provides system functions. 118 * 119 * @syscap SystemCapability.Global.I18n 120 * @crossplatform 121 * @since 10 122 */ 123 /** 124 * Provides system functions. 125 * 126 * @syscap SystemCapability.Global.I18n 127 * @crossplatform 128 * @form 129 * @atomicservice 130 * @since arkts {'1.1':'11','1.2':'20'} 131 * @arkts 1.1&1.2 132 */ 133 export class System { 134 /** 135 * Obtains the country or region name localized for display on a given locale. 136 * 137 * @param { string } country - The locale whose country or region name will be displayed. 138 * @param { string } locale - The locale used to display the country or region. 139 * @param { boolean } [sentenceCase] - Specifies whether the country or region name is displayed in sentence case. 140 * @returns { string } the country or region name localized for display on a given locale. 141 * @throws { BusinessError } 401 - check param failed 142 * @throws { BusinessError } 890001 - param value not valid 143 * @syscap SystemCapability.Global.I18n 144 * @since 9 145 */ 146 /** 147 * Obtains the country or region name localized for display on a given locale. 148 * 149 * @param { string } country - The locale whose country or region name will be displayed. It must be a valid country. 150 * @param { string } locale - The locale used to display the country or region. It must be a valid locale. 151 * @param { boolean } [sentenceCase] - Specifies whether the country or region name is displayed in sentence case. 152 * @returns { string } the country or region name localized for display on a given locale. 153 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 154 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 155 * @syscap SystemCapability.Global.I18n 156 * @crossplatform 157 * @since 10 158 */ 159 /** 160 * Obtains the country/region display name in the specified language. 161 * 162 * @param { string } country - Valid country/region code. 163 * @param { string } locale - System locale, which consists of the language, script, and country/region. 164 * @param { boolean } [sentenceCase] - Whether to use sentence case to display the text. The value "true" means to 165 * display the text in title case format, and the value "false" means to 166 * display the text in the default case format of the locale. The default value 167 * is true. 168 * @returns { string } Country/region display name in the specified language. 169 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 170 * 2.Incorrect parameter types. 171 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 172 * @syscap SystemCapability.Global.I18n 173 * @crossplatform 174 * @atomicservice 175 * @since arkts {'1.1':'12','1.2':'20'} 176 * @arkts 1.1&1.2 177 */ 178 static getDisplayCountry(country: string, locale: string, sentenceCase?: boolean): string; 179 180 /** 181 * Obtains the language name localized for display on a given locale. 182 * 183 * @param { string } language - The locale whose language name will be displayed. 184 * @param { string } locale - The locale used to display the language. 185 * @param { boolean } [sentenceCase] - Specifies whether the language name is displayed in sentence case. 186 * @returns { string } the language name localized for display on a given locale. 187 * @throws { BusinessError } 401 - check param failed 188 * @throws { BusinessError } 890001 - param value not valid 189 * @syscap SystemCapability.Global.I18n 190 * @since 9 191 */ 192 /** 193 * Obtains the language name localized for display on a given locale. 194 * 195 * @param { string } language - The locale whose language name will be displayed. 196 * @param { string } locale - The locale used to display the language. 197 * @param { boolean } [sentenceCase] - Specifies whether the language name is displayed in sentence case. 198 * @returns { string } the language name localized for display on a given locale. 199 * @throws { BusinessError } 401 - check param failed 200 * @throws { BusinessError } 890001 - param value not valid 201 * @syscap SystemCapability.Global.I18n 202 * @crossplatform 203 * @since 10 204 */ 205 /** 206 * Obtains the language display name in the specified language. 207 * 208 * @param { string } language - Valid language ID. 209 * @param { string } locale - System locale, which consists of the language, script, and country/region. 210 * @param { boolean } [sentenceCase] - Whether to use sentence case to display the text. The value "true" means to 211 * display the text in title case format, and the value "false" means to 212 * display the text in the default case format of the locale. The default value 213 * is true. 214 * @returns { string } Language display name in the specified language. 215 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 216 * 2.Incorrect parameter types. 217 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 218 * @syscap SystemCapability.Global.I18n 219 * @crossplatform 220 * @atomicservice 221 * @since arkts {'1.1':'11','1.2':'20'} 222 * @arkts 1.1&1.2 223 */ 224 static getDisplayLanguage(language: string, locale: string, sentenceCase?: boolean): string; 225 226 /** 227 * Obtains all languages supported by the system. 228 * 229 * @returns { Array<string> } all languages supported by the system. 230 * @syscap SystemCapability.Global.I18n 231 * @since 9 232 */ 233 /** 234 * Obtains the list of system languages. 235 * 236 * @returns { Array<string> } List of system languages. 237 * @syscap SystemCapability.Global.I18n 238 * @atomicservice 239 * @since arkts {'1.1':'12','1.2':'20'} 240 * @arkts 1.1&1.2 241 */ 242 static getSystemLanguages(): Array<string>; 243 244 /** 245 * Obtains all regions supported by the system in the language. 246 * 247 * @param { string } language - The language used to get the list of regions. It must be a valid language. 248 * @returns { Array<string> } all countries or regions supported by the system in the language. 249 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 250 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 251 * @syscap SystemCapability.Global.I18n 252 * @since 9 253 */ 254 /** 255 * Obtains the list of countries/regions supported for the specified language. 256 * 257 * @param { string } language - Valid language ID. 258 * @returns { Array<string> } List of countries/regions supported for the specified language. 259 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 260 * 2.Incorrect parameter types. 261 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 262 * @syscap SystemCapability.Global.I18n 263 * @atomicservice 264 * @since arkts {'1.1':'12','1.2':'20'} 265 * @arkts 1.1&1.2 266 */ 267 static getSystemCountries(language: string): Array<string>; 268 269 /** 270 * Determine whether the current language or region is recommended. 271 * 272 * @param { string } language - The language code. It must be a valid language. 273 * @param { string } [region] - The region code. It must be a valid region. 274 * @returns { boolean } whether the current language or region is recommended. 275 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 276 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 277 * @syscap SystemCapability.Global.I18n 278 * @since 9 279 */ 280 /** 281 * Checks whether a language is a suggested language in the specified region. It can be used for region-based 282 * language recommendation or language-based region recommendation. 283 * 284 * @param { string } language - Valid language ID, for example, "zh". 285 * @param { string } [region] - Valid region ID, for example, "CN". The default value is the country/region of the 286 * SIM card. 287 * @returns { boolean } Whether a language is a suggested language. The value "true" indicates that the language 288 * is a suggested language of the region, the the value "false" indicates the opposite. 289 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 290 * 2.Incorrect parameter types. 291 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 292 * @syscap SystemCapability.Global.I18n 293 * @atomicservice 294 * @since arkts {'1.1':'12','1.2':'20'} 295 * @arkts 1.1&1.2 296 */ 297 static isSuggested(language: string, region?: string): boolean; 298 299 /** 300 * Obtains the language currently used by the system. 301 * 302 * @returns { string } the language currently used by the system. 303 * @syscap SystemCapability.Global.I18n 304 * @since 9 305 */ 306 /** 307 * Obtains the language currently used by the system. 308 * 309 * @returns { string } the language currently used by the system. 310 * @syscap SystemCapability.Global.I18n 311 * @crossplatform 312 * @since 10 313 */ 314 /** 315 * Obtains the current system language. 316 * 317 * @returns { string } Language ID. 318 * @syscap SystemCapability.Global.I18n 319 * @crossplatform 320 * @form 321 * @atomicservice 322 * @since arkts {'1.1':'11','1.2':'20'} 323 * @arkts 1.1&1.2 324 */ 325 static getSystemLanguage(): string; 326 327 /** 328 * Sets the system language. 329 * 330 * @permission ohos.permission.UPDATE_CONFIGURATION 331 * @param { string } language - Valid language ID. 332 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission 333 * required to call the API. 334 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 335 * 2.Incorrect parameter types. 336 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 337 * @syscap SystemCapability.Global.I18n 338 * @systemapi Hide this for inner system use. 339 * @since arkts {'1.1':'9','1.2':'20'} 340 * @arkts 1.1&1.2 341 */ 342 static setSystemLanguage(language: string): void; 343 344 /** 345 * Obtains the region currently used by the system. 346 * 347 * @returns { string } the region currently used by the system. 348 * @syscap SystemCapability.Global.I18n 349 * @since 9 350 */ 351 /** 352 * Obtains the region currently used by the system. 353 * 354 * @returns { string } the region currently used by the system. 355 * @syscap SystemCapability.Global.I18n 356 * @crossplatform 357 * @since 10 358 */ 359 /** 360 * Obtains the current system country/region. 361 * 362 * @returns { string } Country/region ID. 363 * @syscap SystemCapability.Global.I18n 364 * @crossplatform 365 * @atomicservice 366 * @since arkts {'1.1':'12','1.2':'20'} 367 * @arkts 1.1&1.2 368 */ 369 static getSystemRegion(): string; 370 371 /** 372 * Sets the system region. 373 * 374 * @permission ohos.permission.UPDATE_CONFIGURATION 375 * @param { string } region - Valid region ID. 376 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission 377 * required to call the API. 378 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 379 * 2.Incorrect parameter types. 380 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 381 * @syscap SystemCapability.Global.I18n 382 * @systemapi Hide this for inner system use. 383 * @since arkts {'1.1':'9','1.2':'20'} 384 * @arkts 1.1&1.2 385 */ 386 static setSystemRegion(region: string): void; 387 388 /** 389 * Obtains the locale currently used by the system. 390 * 391 * @returns { string } the locale currently used by the system. 392 * @syscap SystemCapability.Global.I18n 393 * @since 9 394 */ 395 /** 396 * Obtains the locale currently used by the system. 397 * 398 * @returns { string } the locale currently used by the system. 399 * @syscap SystemCapability.Global.I18n 400 * @crossplatform 401 * @since 10 402 */ 403 /** 404 * Obtains the current system locale. 405 * 406 * @returns { string } Locale ID. 407 * @syscap SystemCapability.Global.I18n 408 * @crossplatform 409 * @atomicservice 410 * @since 11 411 * @deprecated since 20 412 * @useinstead ohos.System.getSystemLocaleInstance 413 */ 414 static getSystemLocale(): string; 415 416 /** 417 * Obtains the locale object currently used by the system. 418 * 419 * @returns { Intl.Locale } the locale object currently used by the system. 420 * @static 421 * @syscap SystemCapability.Global.I18n 422 * @crossplatform 423 * @atomicservice 424 * @since 20 425 * @arkts 1.1&1.2 426 */ 427 static getSystemLocaleInstance(): Intl.Locale; 428 429 /** 430 * Sets the system locale. 431 * 432 * @permission ohos.permission.UPDATE_CONFIGURATION 433 * @param { string } locale - System locale, which consists of the language, script, and country/region. 434 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission 435 * required to call the API. 436 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 437 * 2.Incorrect parameter types. 438 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 439 * @syscap SystemCapability.Global.I18n 440 * @systemapi Hide this for inner system use. 441 * @since 9 442 * @deprecated since 20 443 */ 444 static setSystemLocale(locale: string): void; 445 446 /** 447 * Check out whether system is 24-hour system. 448 * 449 * @returns { boolean } a boolean represent whether system is 24-hour system. 450 * @syscap SystemCapability.Global.I18n 451 * @since 9 452 */ 453 /** 454 * Check out whether system is 24-hour system. 455 * 456 * @returns { boolean } a boolean represent whether system is 24-hour system. 457 * @syscap SystemCapability.Global.I18n 458 * @crossplatform 459 * @since 10 460 */ 461 /** 462 * Check out whether system is 24-hour system. 463 * 464 * @returns { boolean } a boolean represent whether system is 24-hour system. 465 * @syscap SystemCapability.Global.I18n 466 * @crossplatform 467 * @form 468 * @since 11 469 */ 470 /** 471 * Checks whether the 24-hour clock is used. 472 * 473 * @returns { boolean } Whether the 24-hour clock is used. The value "true" indicates that the 24-hour clock is 474 * used, the the value "false" means the opposite. 475 * @syscap SystemCapability.Global.I18n 476 * @crossplatform 477 * @form 478 * @atomicservice 479 * @since arkts {'1.1':'12','1.2':'20'} 480 * @arkts 1.1&1.2 481 */ 482 static is24HourClock(): boolean; 483 484 /** 485 * Sets whether to use the 24-hour clock. 486 * 487 * @permission ohos.permission.UPDATE_CONFIGURATION 488 * @param { boolean } option - Whether to use the 24-hour clock. The value "true" means to use the 24-hour clock, 489 * the the value "false" means the opposite. 490 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission 491 * required to call the API. 492 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 493 * 2.Incorrect parameter types. 494 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 495 * @syscap SystemCapability.Global.I18n 496 * @systemapi Hide this for inner system use. 497 * @since arkts {'1.1':'9','1.2':'20'} 498 * @arkts 1.1&1.2 499 */ 500 static set24HourClock(option: boolean): void; 501 502 /** 503 * Adds a preferred language to the specified position on the preferred language list. 504 * 505 * @permission ohos.permission.UPDATE_CONFIGURATION 506 * @param { string } language - Valid ID of the language to be added as a preferred language. 507 * @param { number } [index] - Position to which the preferred language is added. The default value is the length 508 * of the preferred language list. 509 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission 510 * required to call the API. 511 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 512 * 2.Incorrect parameter types. 513 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 514 * @static 515 * @syscap SystemCapability.Global.I18n 516 * @systemapi Hide this for inner system use. 517 * @since arkts {'1.1':'9','1.2':'20'} 518 * @arkts 1.1&1.2 519 */ 520 static addPreferredLanguage(language: string, index?: number): void; 521 522 /** 523 * Removes a preferred language from the specified position on the preferred language list. 524 * 525 * @permission ohos.permission.UPDATE_CONFIGURATION 526 * @param { number } index - Position of the preferred language to delete. 527 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission 528 * required to call the API. 529 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 530 * 2.Incorrect parameter types. 531 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 532 * @static 533 * @syscap SystemCapability.Global.I18n 534 * @systemapi Hide this for inner system use. 535 * @since arkts {'1.1':'9','1.2':'20'} 536 * @arkts 1.1&1.2 537 */ 538 static removePreferredLanguage(index: number): void; 539 540 /** 541 * Access the system preferred language list. 542 * 543 * @returns { Array<string> } a string Array represent the preferred language list. 544 * @syscap SystemCapability.Global.I18n 545 * @since 9 546 */ 547 /** 548 * Obtains the list of preferred languages. 549 * 550 * @returns { Array<string> } List of preferred languages. 551 * @syscap SystemCapability.Global.I18n 552 * @atomicservice 553 * @since arkts {'1.1':'12','1.2':'20'} 554 * @arkts 1.1&1.2 555 */ 556 static getPreferredLanguageList(): Array<string>; 557 558 /** 559 * Get the first preferred language of system. 560 * 561 * @returns { string } a string represent the first preferred language of system. 562 * @syscap SystemCapability.Global.I18n 563 * @since 9 564 */ 565 /** 566 * Obtains the first language in the preferred language list. 567 * 568 * @returns { string } First language in the preferred language list. 569 * @syscap SystemCapability.Global.I18n 570 * @atomicservice 571 * @since arkts {'1.1':'12','1.2':'20'} 572 * @arkts 1.1&1.2 573 */ 574 static getFirstPreferredLanguage(): string; 575 576 /** 577 * Set the preferred language of App. 578 * 579 * @param { string } language - the language to be set. It must be a valid language. 580 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 581 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 582 * @syscap SystemCapability.Global.I18n 583 * @since 11 584 */ 585 /** 586 * Sets the preferred language of the application. Resources are loaded in the preferred language when the 587 * application is launched. If the preferred language is set to default, the application's language will be the 588 * same as the system language, and the setting will take effect upon cold starting of the application. 589 * 590 * @param { string } language - Valid language ID or default. 591 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 592 * 2.Incorrect parameter types. 593 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 594 * @syscap SystemCapability.Global.I18n 595 * @atomicservice 596 * @since 12 597 */ 598 /** 599 * Sets the preferred language of the application. Resources are loaded in the preferred language when the 600 * application is launched. If the preferred language is set to default, the application's language will be the 601 * same as the system language, and the setting will take effect upon cold starting of the application. 602 * 603 * @param { string } language - Valid language ID or default. 604 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 605 * 2.Incorrect parameter types. 606 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 607 * @syscap SystemCapability.Global.I18n 608 * @crossplatform 609 * @atomicservice 610 * @since 20 611 * @arkts 1.1&1.2 612 */ 613 static setAppPreferredLanguage(language: string): void; 614 615 /** 616 * Get the preferred language of App. 617 * 618 * @returns { string } a string represent the preferred language of App. 619 * @syscap SystemCapability.Global.I18n 620 * @since 9 621 */ 622 /** 623 * Obtains the preferred language of an application. 624 * 625 * @returns { string } Preferred language of the application. 626 * @syscap SystemCapability.Global.I18n 627 * @atomicservice 628 * @since 12 629 */ 630 /** 631 * Obtains the preferred language of an application. 632 * 633 * @returns { string } Preferred language of the application. 634 * @syscap SystemCapability.Global.I18n 635 * @crossplatform 636 * @atomicservice 637 * @since 20 638 * @arkts 1.1&1.2 639 */ 640 static getAppPreferredLanguage(): string; 641 642 /** 643 * Specifies whether to enable use of local digits. 644 * 645 * @permission ohos.permission.UPDATE_CONFIGURATION 646 * @param { boolean } flag - Whether to turn on the local digit switch. The value "true" means to turn on the local 647 * digit switch, and the value "false" indicates the opposite. 648 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission 649 * required to call the API. 650 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 651 * 2.Incorrect parameter types. 652 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 653 * @syscap SystemCapability.Global.I18n 654 * @systemapi Hide this for inner system use. 655 * @since arkts {'1.1':'9','1.2':'20'} 656 * @arkts 1.1&1.2 657 */ 658 static setUsingLocalDigit(flag: boolean): void; 659 660 /** 661 * Get whether to use local digit. 662 * 663 * @returns { boolean } a boolean represents whether to use local digit. 664 * @syscap SystemCapability.Global.I18n 665 * @since 9 666 */ 667 /** 668 * Checks whether use of local digits is enabled. 669 * 670 * @returns { boolean } Whether use of local digits is enabled. The value "true" indicates that use of local digits 671 * is enabled, and the value "false" indicates the opposite. 672 * @syscap SystemCapability.Global.I18n 673 * @atomicservice 674 * @since arkts {'1.1':'12','1.2':'20'} 675 * @arkts 1.1&1.2 676 */ 677 static getUsingLocalDigit(): boolean; 678 679 /** 680 * Obtains the simplified representation of a language. For example, the simplified representation of "en-Latn-US" 681 * is "en", and that of "en-Latn-GB" is "en-GB". 682 * 683 * @param { string } [language] - Valid language ID. The default value is the system language. 684 * @returns { string } If language is not passed, the application checks for dialects supported by the system based 685 * on the system language and locale. If such a dialect is found, the simplified representation 686 * of the dialect is returned. Otherwise, the simplified representation of the system language 687 * is returned. If language is passed, the simplified representation of the specified language 688 * is returned. 689 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 690 * 2.Incorrect parameter types. 691 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 692 * @syscap SystemCapability.Global.I18n 693 * @atomicservice 694 * @since arkts {'1.1':'15','1.2':'20'} 695 * @arkts 1.1&1.2 696 */ 697 static getSimplifiedLanguage(language?: string): string; 698 699 /** 700 * Sets the temperature unit of the system. 701 * 702 * @permission ohos.permission.UPDATE_CONFIGURATION 703 * @param { TemperatureType } type - Temperature unit. 704 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission 705 * required to call the API. 706 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 707 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 708 * @syscap SystemCapability.Global.I18n 709 * @systemapi Hide this for inner system use. 710 * @since arkts {'1.1':'18','1.2':'20'} 711 * @arkts 1.1&1.2 712 */ 713 static setTemperatureType(type: TemperatureType): void; 714 715 /** 716 * Obtains the temperature unit of the system. 717 * 718 * @returns { TemperatureType } Temperature unit. 719 * @syscap SystemCapability.Global.I18n 720 * @atomicservice 721 * @since arkts {'1.1':'18','1.2':'20'} 722 * @arkts 1.1&1.2 723 */ 724 static getTemperatureType(): TemperatureType; 725 726 /** 727 * Obtains the name of a temperature unit. 728 * 729 * @param { TemperatureType } type - Temperature unit. 730 * @returns { string } Name of the temperature unit, which can be "celsius", "fahrenheit", and "kelvin". 731 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 732 * @syscap SystemCapability.Global.I18n 733 * @atomicservice 734 * @since arkts {'1.1':'18','1.2':'20'} 735 * @arkts 1.1&1.2 736 */ 737 static getTemperatureName(type: TemperatureType): string; 738 739 /** 740 * Sets the first day of a week. 741 * 742 * @permission ohos.permission.UPDATE_CONFIGURATION 743 * @param { WeekDay } type - Start day of a week. 744 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission 745 * required to call the API. 746 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 747 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 748 * @syscap SystemCapability.Global.I18n 749 * @systemapi Hide this for inner system use. 750 * @since arkts {'1.1':'18','1.2':'20'} 751 * @arkts 1.1&1.2 752 */ 753 static setFirstDayOfWeek(type: WeekDay): void; 754 755 /** 756 * Obtains the first day of a week in the system settings. 757 * 758 * @returns { WeekDay } Start day of a week. 759 * @syscap SystemCapability.Global.I18n 760 * @atomicservice 761 * @since arkts {'1.1':'18','1.2':'20'} 762 * @arkts 1.1&1.2 763 */ 764 static getFirstDayOfWeek(): WeekDay; 765 766 /** 767 * Gets collations supported by system locale. 768 * 769 * @returns { Map<string, string> } The map will containing the collation's identifier and name. 770 * If the map is empty of the collation for given locale does not need to be set. 771 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 772 * @static 773 * @syscap SystemCapability.Global.I18n 774 * @systemapi 775 * @since 20 776 */ 777 static getSystemCollations(): Map<string, string>; 778 779 /** 780 * Gets collation currently used by system locale. 781 * 782 * @returns { string } The identifier of the collation model used by system locale will be return. 783 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 784 * @static 785 * @syscap SystemCapability.Global.I18n 786 * @systemapi 787 * @since 20 788 */ 789 static getUsingCollation(): string; 790 791 /** 792 * Sets the system collation mode. 793 * 794 * @permission ohos.permission.UPDATE_CONFIGURATION 795 * @param { string } identifier - Identifier of the collation mode. 796 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 797 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 798 * @throws { BusinessError } 8900001 - Invalid parameter. Possible causes: Parameter verification failed. 799 * @static 800 * @syscap SystemCapability.Global.I18n 801 * @systemapi 802 * @since 20 803 */ 804 static setSystemCollation(identifier: string): void; 805 806 /** 807 * Gets measurements supported by system locale. 808 * 809 * @returns { Map<string, string> } a map will containing identifier and name of measurements supported by system locale. 810 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 811 * @static 812 * @syscap SystemCapability.Global.I18n 813 * @systemapi 814 * @since 20 815 */ 816 static getSystemMeasurements(): Map<string, string>; 817 818 /** 819 * Gets measurement currently used by system locale. 820 * 821 * @returns { string } The identifier of measurement system using by system locale 822 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 823 * @static 824 * @syscap SystemCapability.Global.I18n 825 * @systemapi 826 * @since 20 827 */ 828 static getUsingMeasurement(): string; 829 830 /** 831 * Sets the measurement system used by the system locale. 832 * 833 * @permission ohos.permission.UPDATE_CONFIGURATION 834 * @param { string } identifier - Identifier of the measurement system. 835 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission 836 * required to call the API. 837 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 838 * @throws { BusinessError } 8900001 - Invalid parameter. Possible causes: Parameter verification failed. 839 * @static 840 * @syscap SystemCapability.Global.I18n 841 * @systemapi 842 * @since 20 843 */ 844 static setSystemMeasurement(identifier: string): void; 845 846 /** 847 * Gets numbering system currently used by system locale. 848 * 849 * @returns { string } the numbering systems's identifier. 850 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 851 * @static 852 * @syscap SystemCapability.Global.I18n 853 * @systemapi 854 * @since 20 855 */ 856 static getUsingNumberingSystem(): string; 857 858 /** 859 * Sets the numbering system used by the system locale. 860 * 861 * @permission ohos.permission.UPDATE_CONFIGURATION 862 * @param { string } identifier - Identifier of the numbering system. 863 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission 864 * required to call the API. 865 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 866 * @throws { BusinessError } 8900001 - Invalid parameter. Possible causes: Parameter verification failed. 867 * @static 868 * @syscap SystemCapability.Global.I18n 869 * @systemapi 870 * @since 20 871 */ 872 static setSystemNumberingSystem(identifier: string): void; 873 874 /** 875 * Gets numbering systems supported by system locale. 876 * 877 * @returns { Map<string,string> } a map will containing the numbering system 's identifier and sample. 878 * If the map is empty, there is no local digit for given locale. 879 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 880 * @static 881 * @syscap SystemCapability.Global.I18n 882 * @systemapi 883 * @since 20 884 */ 885 static getSystemNumberingSystems(): Map<string, string>; 886 887 /** 888 * Gets commonly used number patterns for system locale. 889 * 890 * @returns { Map<string,string> } a map containing the used number patterns and example of system locale. 891 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 892 * @static 893 * @syscap SystemCapability.Global.I18n 894 * @systemapi 895 * @since 20 896 */ 897 static getSystemNumberPatterns(): Map<string, string>; 898 899 /** 900 * Sets the number pattern used by the system locale. 901 * 902 * @permission ohos.permission.UPDATE_CONFIGURATION 903 * @param { string } pattern - Identifier of the number pattern. 904 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission 905 * required to call the API. 906 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 907 * @throws { BusinessError } 8900001 - Invalid parameter. Possible causes: Parameter verification failed. 908 * @static 909 * @syscap SystemCapability.Global.I18n 910 * @systemapi 911 * @since 20 912 */ 913 static setSystemNumberPattern(pattern: string): void; 914 915 916 /** 917 * Gets number pattern used by system locale. 918 * 919 * @returns { string } The number pattern identifier used by system locale 920 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 921 * @static 922 * @syscap SystemCapability.Global.I18n 923 * @systemapi 924 * @since 20 925 */ 926 static getUsingNumberPattern(): string; 927 928 /** 929 * Gets numerical date patterns and examples supported by system locale. 930 * 931 * @returns { Map<string, string> } a map containing the date patterns and examples 932 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 933 * @static 934 * @syscap SystemCapability.Global.I18n 935 * @systemapi 936 * @since 20 937 */ 938 static getSystemNumericalDatePatterns(): Map<string, string>; 939 940 /** 941 * Sets the numerical date pattern used by the system locale. 942 * 943 * @permission ohos.permission.UPDATE_CONFIGURATION 944 * @param { string } identifier - Identifier of the numerical date pattern. 945 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission 946 * required to call the API. 947 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 948 * @throws { BusinessError } 8900001 - Invalid parameter. Possible causes: Parameter verification failed. 949 * @static 950 * @syscap SystemCapability.Global.I18n 951 * @systemapi 952 * @since 20 953 */ 954 static setSystemNumericalDatePattern(identifier : string): void; 955 956 /** 957 * Gets numerical date pattern currently used by system locale. 958 * 959 * @returns { string } The numerical date pattern used by system locale 960 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 961 * @static 962 * @syscap SystemCapability.Global.I18n 963 * @systemapi 964 * @since 20 965 */ 966 static getUsingNumericalDatePattern(): string; 967 } 968 969 /** 970 * Enumerates the first day of a week. The value ranges from Monday to Sunday. 971 * 972 * @enum { number } 973 * @syscap SystemCapability.Global.I18n 974 * @atomicservice 975 * @since arkts {'1.1':'18','1.2':'20'} 976 * @arkts 1.1&1.2 977 */ 978 export enum WeekDay { 979 /** 980 * Monday. 981 * 982 * @syscap SystemCapability.Global.I18n 983 * @atomicservice 984 * @since arkts {'1.1':'18','1.2':'20'} 985 * @arkts 1.1&1.2 986 */ 987 MON = 1, 988 989 /** 990 * Tuesday. 991 * 992 * @syscap SystemCapability.Global.I18n 993 * @atomicservice 994 * @since arkts {'1.1':'18','1.2':'20'} 995 * @arkts 1.1&1.2 996 */ 997 TUE = 2, 998 999 /** 1000 * Wednesday. 1001 * 1002 * @syscap SystemCapability.Global.I18n 1003 * @atomicservice 1004 * @since arkts {'1.1':'18','1.2':'20'} 1005 * @arkts 1.1&1.2 1006 */ 1007 WED = 3, 1008 1009 /** 1010 * Thursday. 1011 * 1012 * @syscap SystemCapability.Global.I18n 1013 * @atomicservice 1014 * @since arkts {'1.1':'18','1.2':'20'} 1015 * @arkts 1.1&1.2 1016 */ 1017 THU = 4, 1018 1019 /** 1020 * Friday. 1021 * 1022 * @syscap SystemCapability.Global.I18n 1023 * @atomicservice 1024 * @since arkts {'1.1':'18','1.2':'20'} 1025 * @arkts 1.1&1.2 1026 */ 1027 FRI = 5, 1028 1029 /** 1030 * Saturday. 1031 * 1032 * @syscap SystemCapability.Global.I18n 1033 * @atomicservice 1034 * @since arkts {'1.1':'18','1.2':'20'} 1035 * @arkts 1.1&1.2 1036 */ 1037 SAT = 6, 1038 1039 /** 1040 * Sunday. 1041 * 1042 * @syscap SystemCapability.Global.I18n 1043 * @atomicservice 1044 * @since arkts {'1.1':'18','1.2':'20'} 1045 * @arkts 1.1&1.2 1046 */ 1047 SUN = 7 1048 } 1049 1050 /** 1051 * Enumerates temperature units. 1052 * 1053 * @enum { number } 1054 * @syscap SystemCapability.Global.I18n 1055 * @atomicservice 1056 * @since arkts {'1.1':'18','1.2':'20'} 1057 * @arkts 1.1&1.2 1058 */ 1059 export enum TemperatureType { 1060 /** 1061 * Celesius. 1062 * 1063 * @syscap SystemCapability.Global.I18n 1064 * @atomicservice 1065 * @since arkts {'1.1':'18','1.2':'20'} 1066 * @arkts 1.1&1.2 1067 */ 1068 CELSIUS = 1, 1069 1070 /** 1071 * Fahrenheit. 1072 * 1073 * @syscap SystemCapability.Global.I18n 1074 * @atomicservice 1075 * @since arkts {'1.1':'18','1.2':'20'} 1076 * @arkts 1.1&1.2 1077 */ 1078 FAHRENHEIT = 2, 1079 1080 /** 1081 * Kelvin. 1082 * 1083 * @syscap SystemCapability.Global.I18n 1084 * @atomicservice 1085 * @since arkts {'1.1':'18','1.2':'20'} 1086 * @arkts 1.1&1.2 1087 */ 1088 KELVIN = 3 1089 } 1090 1091 /** 1092 * Provides util functions. 1093 * 1094 * @interface Util 1095 * @syscap SystemCapability.Global.I18n 1096 * @since 8 1097 * @deprecated since 9 1098 * @useinstead ohos.i18n/i18n.I18NUtil 1099 */ 1100 export interface Util { 1101 /** 1102 * Converts one measurement unit into another and formats the unit based on the specified locale and style. 1103 * 1104 * @param { UnitInfo } fromUnit - Measurement unit to be converted. 1105 * @param { UnitInfo } toUnit - Measurement unit to be converted to. 1106 * @param { number } value - Value of the measurement unit to be converted. 1107 * @param { string } locale - Locale ID used for formatting, for example, "zh-Hans-CN". 1108 * @param { string } [style] - Style used for formatting. The value can be "long", "short", or "narrow". The 1109 * default value is short. 1110 * @returns { string } String obtained after formatting based on the measurement unit specified by toUnit. 1111 * @syscap SystemCapability.Global.I18n 1112 * @since 8 1113 * @deprecated since 9 1114 * @useinstead ohos.i18n/i18n.I18NUtil#unitConvert 1115 */ 1116 unitConvert(fromUnit: UnitInfo, toUnit: UnitInfo, value: number, locale: string, style?: string): string; 1117 } 1118 1119 /** 1120 * Provides util functions. 1121 * 1122 * @syscap SystemCapability.Global.I18n 1123 * @since 9 1124 */ 1125 /** 1126 * Provides util functions. 1127 * 1128 * @syscap SystemCapability.Global.I18n 1129 * @crossplatform 1130 * @since 10 1131 */ 1132 /** 1133 * Provides util functions. 1134 * 1135 * @syscap SystemCapability.Global.I18n 1136 * @crossplatform 1137 * @atomicservice 1138 * @since arkts {'1.1':'12','1.2':'20'} 1139 * @arkts 1.1&1.2 1140 */ 1141 export class I18NUtil { 1142 /** 1143 * Convert from unit to unit and format according to the locale. 1144 * 1145 * @param { UnitInfo } fromUnit - Information of the unit to be converted. 1146 * @param { UnitInfo } toUnit - Information about the unit to be converted to. 1147 * @param { number } value - Indicates the number to be formatted. 1148 * @param { string } locale - The locale to be used. 1149 * @param { string } [style] - The style of format. 1150 * @returns { string } converted number and unit. 1151 * @syscap SystemCapability.Global.I18n 1152 * @since 9 1153 */ 1154 /** 1155 * Converts one measurement unit into another and formats the unit based on the specified locale and style. 1156 * 1157 * @param { UnitInfo } fromUnit - Measurement unit to be converted. 1158 * @param { UnitInfo } toUnit - Measurement unit to be converted to. 1159 * @param { number } value - Value of the measurement unit to be converted. 1160 * @param { string } locale - Locale ID, which consists of the language, script, and country/region, for example, 1161 * "zh-Hans-CN". 1162 * @param { string } [style] - Style used for formatting. The value can be long, short, or narrow. The default 1163 * value is short. For details about the meaning or display effect of different values, 1164 * see Number and Unit of Measurement Formatting. 1165 * @returns { string } String converted to the measurement unit after formatting. 1166 * @static 1167 * @syscap SystemCapability.Global.I18n 1168 * @atomicservice 1169 * @since arkts {'1.1':'12','1.2':'20'} 1170 * @arkts 1.1&1.2 1171 */ 1172 static unitConvert(fromUnit: UnitInfo, toUnit: UnitInfo, value: number, locale: string, style?: string): string; 1173 1174 /** 1175 * Get the order of year, month, day in the specified locale. Year, month, day are separated by '-'. 1176 * 'y' stands for year, 'L' stands for month, d stands for day. 1177 * 1178 * @param { string } locale - Information of the locale 1179 * @returns { string } the string of 'y', 'L', 'd' joined by '-'. 1180 * @syscap SystemCapability.Global.I18n 1181 * @since 9 1182 */ 1183 /** 1184 * Get the order of year, month, day in the specified locale. Year, month, day are separated by '-'. 1185 * 'y' stands for year, 'L' stands for month, d stands for day. 1186 * 1187 * @param { string } locale - Information of the locale. 1188 * @returns { string } the string of 'y', 'L', 'd' joined by '-'. 1189 * @syscap SystemCapability.Global.I18n 1190 * @crossplatform 1191 * @since 10 1192 */ 1193 /** 1194 * Obtains the sequence of the year, month, and day in the specified locale. 1195 * 1196 * @param { string } locale - Locale ID, which consists of the language, script, and country/region, for example, 1197 * "zh-Hans-CN". 1198 * @returns { string } Sequence of the year, month, and day in the locale. "y" indicates the year, "L" indicates 1199 * the month, and "d" indicates the day. 1200 * @syscap SystemCapability.Global.I18n 1201 * @crossplatform 1202 * @atomicservice 1203 * @since arkts {'1.1':'12','1.2':'20'} 1204 * @arkts 1.1&1.2 1205 */ 1206 static getDateOrder(locale: string): string; 1207 1208 /** 1209 * Get the time period name for the specified hour. 1210 * 1211 * @param { number } hour - the hour value. 1212 * @param { string } [locale] - specified the locale. Use current app locale by default. It must be a valid locale. 1213 * @returns { string } the string of time period name. The return value may be empty string 1214 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1215 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 1216 * @syscap SystemCapability.Global.I18n 1217 * @since 11 1218 */ 1219 /** 1220 * Obtains the localized expression of the specified time in the specified locale. 1221 * 1222 * @param { number } hour - Specified time, for example, 16. 1223 * @param { string } [locale] - System locale, which consists of the language, script, and country/region. for 1224 * example, "zh-Hans-CN". The default value is the current system locale. 1225 * @returns { string } Localized expression of the specified time in the specified locale. 1226 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 1227 * 2.Incorrect parameter types. 1228 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 1229 * @static 1230 * @syscap SystemCapability.Global.I18n 1231 * @atomicservice 1232 * @since arkts {'1.1':'12','1.2':'20'} 1233 * @arkts 1.1&1.2 1234 */ 1235 static getTimePeriodName(hour:number, locale?: string): string; 1236 1237 /** 1238 * Obtains the locale that best matches a region from the specified locale list. 1239 * 1240 * @param { string } locale - Locale ID, for example, "zh-Hans-CN". 1241 * @param { string[] } localeList - List of locale IDs. 1242 * @returns { string } ID of the locale that best matches a region. If no matching locale is found, an empty string 1243 * is returned. 1244 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 1245 * 2.Incorrect parameter types. 1246 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 1247 * @static 1248 * @syscap SystemCapability.Global.I18n 1249 * @crossplatform 1250 * @atomicservice 1251 * @since arkts {'1.1':'12','1.2':'20'} 1252 * @arkts 1.1&1.2 1253 */ 1254 static getBestMatchLocale(locale: string, localeList: string[]): string; 1255 1256 /** 1257 * Converts a language code from two letters to three letters. For example, the two-letter language code of Chinese 1258 * is "zh", and the corresponding three-letter language code is "zho". For details, see 1259 * [ISO 639](https://www.iso.org/iso-639-language-code). 1260 * 1261 * @param { string } locale - Two-letter code of the language to be converted, for example, "zh". 1262 * @returns { string } Language code after conversion. 1263 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 1264 * 2.Incorrect parameter types. 1265 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 1266 * @static 1267 * @syscap SystemCapability.Global.I18n 1268 * @atomicservice 1269 * @since arkts {'1.1':'12','1.2':'20'} 1270 * @arkts 1.1&1.2 1271 */ 1272 static getThreeLetterLanguage(locale: string): string; 1273 1274 /** 1275 * Converts a region code from two letters to three letters. For example, the two-letter region code of China is 1276 * "CN", and the corresponding three-letter region code is "CHN". For details, see 1277 * [ISO 3166](https://www.iso.org/iso-3166-country-codes.html). 1278 * 1279 * @param { string } locale - Two-letter country/region code to be converted, for example, "CN". 1280 * @returns { string } Region code after conversion. 1281 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 1282 * 2.Incorrect parameter types. 1283 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 1284 * @static 1285 * @syscap SystemCapability.Global.I18n 1286 * @atomicservice 1287 * @since arkts {'1.1':'12','1.2':'20'} 1288 * @arkts 1.1&1.2 1289 */ 1290 static getThreeLetterRegion(locale: string): string; 1291 1292 /** 1293 * Localizes a file path for the specified locale. For example, /data/out/tmp is changed to tmp/out/data/ after 1294 * localization. 1295 * 1296 * @param { string } path - Path to mirror, for example, "/data/out/tmp". 1297 * @param { string } [delimiter] - Path delimiter. The default value is "/"". 1298 * @param { intl.Locale } [locale] - Locale object. The default value is the current system locale. 1299 * @returns { string } File path after localization. If the specified locale object corresponds to an RTL language, 1300 * the processed file path contains a direction control character to ensure that the file path 1301 * is displayed in mirror mode. 1302 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 1303 * @static 1304 * @syscap SystemCapability.Global.I18n 1305 * @atomicservice 1306 * @since 18 1307 * @deprecated since 20 1308 * @useinstead getUnicodeWrappedFilePath 1309 */ 1310 static getUnicodeWrappedFilePath(path: string, delimiter?: string, locale?: intl.Locale): string; 1311 1312 /** 1313 * Localizes a file path for the specified locale. For example, /data/out/tmp is changed to tmp/out/data/ after 1314 * localization. 1315 * 1316 * @param { string } path - Path to mirror, for example, "/data/out/tmp". 1317 * @param { string } [delimiter] - Path delimiter. The default value is "/"". 1318 * @param { Intl.Locale } [locale] - Locale object. The default value is the current system locale. 1319 * @returns { string } File path after localization. If the specified locale object corresponds to an RTL language, 1320 * the processed file path contains a direction control character to ensure that the file path 1321 * is displayed in mirror mode. 1322 * @throws { BusinessError } 8900001 - Invalid parameter. Possible causes: Parameter verification failed. 1323 * @static 1324 * @syscap SystemCapability.Global.I18n 1325 * @atomicservice 1326 * @since 20 1327 */ 1328 static getUnicodeWrappedFilePath(path: string, delimiter?: string, locale?: Intl.Locale): string; 1329 } 1330 1331 /** 1332 * Provides the options of unit. 1333 * 1334 * @interface UnitInfo 1335 * @syscap SystemCapability.Global.I18n 1336 * @since 8 1337 */ 1338 /** 1339 * Defines the measurement unit information. 1340 * 1341 * @interface UnitInfo 1342 * @syscap SystemCapability.Global.I18n 1343 * @atomicservice 1344 * @since arkts {'1.1':'12','1.2':'20'} 1345 * @arkts 1.1&1.2 1346 */ 1347 export interface UnitInfo { 1348 /** 1349 * Unit name. 1350 * 1351 * @syscap SystemCapability.Global.I18n 1352 * @since 8 1353 */ 1354 /** 1355 * Name of the measurement unit, for example, "meter", "inch", or "cup". 1356 * 1357 * @type { string } 1358 * @syscap SystemCapability.Global.I18n 1359 * @atomicservice 1360 * @since arkts {'1.1':'12','1.2':'20'} 1361 * @arkts 1.1&1.2 1362 */ 1363 unit: string; 1364 1365 /** 1366 * The measurement system of the unit. 1367 * 1368 * @syscap SystemCapability.Global.I18n 1369 * @since 8 1370 */ 1371 /** 1372 * Measurement system. The value can be "SI", "US", or "UK". 1373 * 1374 * @type { string } 1375 * @syscap SystemCapability.Global.I18n 1376 * @atomicservice 1377 * @since arkts {'1.1':'12','1.2':'20'} 1378 * @arkts 1.1&1.2 1379 */ 1380 measureSystem: string; 1381 } 1382 1383 /** 1384 * Provides the options of PhoneNumberFormat. 1385 * 1386 * @interface PhoneNumberFormatOptions 1387 * @syscap SystemCapability.Global.I18n 1388 * @since 8 1389 */ 1390 /** 1391 * Provides the options of PhoneNumberFormat. 1392 * 1393 * @interface PhoneNumberFormatOptions 1394 * @syscap SystemCapability.Global.I18n 1395 * @crossplatform 1396 * @since 11 1397 */ 1398 /** 1399 * Options for PhoneNumberFormat object initialization. 1400 * 1401 * @interface PhoneNumberFormatOptions 1402 * @syscap SystemCapability.Global.I18n 1403 * @crossplatform 1404 * @atomicservice 1405 * @since arkts {'1.1':'12','1.2':'20'} 1406 * @arkts 1.1&1.2 1407 */ 1408 export interface PhoneNumberFormatOptions { 1409 /** 1410 * Indicates the type to format phone number. 1411 * 1412 * @type { string } 1413 * @syscap SystemCapability.Global.I18n 1414 * @since 8 1415 */ 1416 /** 1417 * Indicates the type to format phone number. 1418 * 1419 * @type { ?string } 1420 * @syscap SystemCapability.Global.I18n 1421 * @since 9 1422 */ 1423 /** 1424 * Indicates the type to format phone number. 1425 * 1426 * @type { ?string } 1427 * @syscap SystemCapability.Global.I18n 1428 * @crossplatform 1429 * @since 11 1430 */ 1431 /** 1432 * Type of the phone number. The value can be "E164", "INTERNATIONAL", "NATIONAL", "RFC3966", or "TYPING". 1433 * In API version 8, type is mandatory. In API version 9 or later, type is optional. 1434 * In API version 12 or later, "TYPING" is supported, which indicates that the dialed number is formatted in real 1435 * time. 1436 * 1437 * @type { ?string } 1438 * @syscap SystemCapability.Global.I18n 1439 * @crossplatform 1440 * @atomicservice 1441 * @since arkts {'1.1':'12','1.2':'20'} 1442 * @arkts 1.1&1.2 1443 */ 1444 type?: string; 1445 } 1446 1447 /** 1448 * Provides the API for formatting phone number strings 1449 * 1450 * @syscap SystemCapability.Global.I18n 1451 * @since 8 1452 */ 1453 /** 1454 * Provides the API for formatting phone number strings 1455 * 1456 * @syscap SystemCapability.Global.I18n 1457 * @crossplatform 1458 * @since 11 1459 */ 1460 /** 1461 * Provides the API for formatting phone number strings 1462 * 1463 * @syscap SystemCapability.Global.I18n 1464 * @crossplatform 1465 * @atomicservice 1466 * @since arkts {'1.1':'12','1.2':'20'} 1467 * @arkts 1.1&1.2 1468 */ 1469 export class PhoneNumberFormat { 1470 /** 1471 * A constructor used to create a PhoneNumberFormat object. 1472 * 1473 * @param { string } country - Indicates a character string containing the country information for the PhoneNumberFormat object. 1474 * @param { PhoneNumberFormatOptions } [options] - format types: "E164", "RFC3966", "INTERNATIONAL", "NATIONAL". 1475 * @syscap SystemCapability.Global.I18n 1476 * @since 8 1477 */ 1478 /** 1479 * A constructor used to create a PhoneNumberFormat object. 1480 * 1481 * @param { string } country - Indicates a character string containing the country information for the PhoneNumberFormat object. 1482 * @param { PhoneNumberFormatOptions } [options] - format types: "E164", "RFC3966", "INTERNATIONAL", "NATIONAL". 1483 * @syscap SystemCapability.Global.I18n 1484 * @crossplatform 1485 * @since 11 1486 */ 1487 /** 1488 * Creates a PhoneNumberFormat object. 1489 * 1490 * @param { string } country - Country/region to which the phone number to be formatted belongs. 1491 * @param { PhoneNumberFormatOptions } [options] - Options for PhoneNumberFormat object initialization. 1492 * The default value is "NATIONAL". 1493 * @syscap SystemCapability.Global.I18n 1494 * @crossplatform 1495 * @atomicservice 1496 * @since arkts {'1.1':'12','1.2':'20'} 1497 * @arkts 1.1&1.2 1498 */ 1499 constructor(country: string, options?: PhoneNumberFormatOptions); 1500 1501 /** 1502 * Judge whether phone number is valid. 1503 * 1504 * @param { string } number - Indicates the input phone number. 1505 * @returns { boolean } a boolean indicates whether the input phone number is valid. 1506 * @syscap SystemCapability.Global.I18n 1507 * @since 8 1508 */ 1509 /** 1510 * Judge whether phone number is valid. 1511 * 1512 * @param { string } number - Indicates the input phone number. 1513 * @returns { boolean } a boolean indicates whether the input phone number is valid. 1514 * @syscap SystemCapability.Global.I18n 1515 * @crossplatform 1516 * @since 11 1517 */ 1518 /** 1519 * Checks whether the phone number is valid for the country/region in the PhoneNumberFormat object. 1520 * 1521 * @param { string } phoneNumber - Phone number to be checked. 1522 * @returns { boolean } Whether the phone number is valid. The value "true" indicates that the phone number is 1523 * valid, and the value "false" indicates the opposite. 1524 * @syscap SystemCapability.Global.I18n 1525 * @crossplatform 1526 * @atomicservice 1527 * @since arkts {'1.1':'12','1.2':'20'} 1528 * @arkts 1.1&1.2 1529 */ 1530 isValidNumber(phoneNumber: string): boolean; 1531 1532 /** 1533 * Obtains the formatted phone number strings of number. 1534 * 1535 * @param { string } number - Indicates the input phone number to be formatted. 1536 * @returns { string } the formatted phone number. 1537 * @syscap SystemCapability.Global.I18n 1538 * @since 8 1539 */ 1540 /** 1541 * Obtains the formatted phone number strings of number. 1542 * 1543 * @param { string } number - Indicates the input phone number to be formatted. 1544 * @returns { string } the formatted phone number. 1545 * @syscap SystemCapability.Global.I18n 1546 * @crossplatform 1547 * @since 11 1548 */ 1549 /** 1550 * Formats a phone number. 1551 * 1552 * @param { string } phoneNumber - Phone number to be formatted. 1553 * @returns { string } Formatted phone number. 1554 * @syscap SystemCapability.Global.I18n 1555 * @crossplatform 1556 * @atomicservice 1557 * @since arkts {'1.1':'12','1.2':'20'} 1558 * @arkts 1.1&1.2 1559 */ 1560 format(phoneNumber: string): string; 1561 1562 /** 1563 * Determine the location by phone number, and return it according to the specified regional language. 1564 * 1565 * @param { string } number - input phone number. 1566 * @param { string } locale - locale ID. 1567 * @returns { string } a string represents phone number's location. 1568 * @syscap SystemCapability.Global.I18n 1569 * @since 9 1570 */ 1571 /** 1572 * Obtains the home location of a phone number. 1573 * 1574 * @param { string } phoneNumber - Phone number. To obtain the home location of a number in other countries/regions, 1575 * you need to prefix the number with 00 and the country code. 1576 * @param { string } locale - System locale, which consists of the language, script, and country/region. 1577 * @returns { string } Home location of the phone number. If the number is invalid, an empty string is returned. 1578 * @syscap SystemCapability.Global.I18n 1579 * @atomicservice 1580 * @since arkts {'1.1':'12','1.2':'20'} 1581 * @arkts 1.1&1.2 1582 */ 1583 getLocationName(phoneNumber: string, locale: string): string; 1584 } 1585 1586 /** 1587 * Get a Calendar instance specified by locale and type. 1588 * 1589 * @param { string } locale - The locale used to get calendar. 1590 * @param { string } [type] - If type is not specified, get locale's default Calendar, else get the specified type of Calendar. 1591 * such as buddhist, chinese, coptic, ethiopic, hebrew, gregory, indian, islamic_civil, islamic_tbla, islamic_umalqura, 1592 * japanese, persian. 1593 * @returns { Calendar } Calendar object 1594 * @syscap SystemCapability.Global.I18n 1595 * @since 8 1596 */ 1597 /** 1598 * Get a Calendar instance specified by locale and type. 1599 * 1600 * @param { string } locale - The locale used to get calendar. 1601 * @param { string } [type] - If type is not specified, get locale's default Calendar, else get the specified type of Calendar. 1602 * such as buddhist, chinese, coptic, ethiopic, hebrew, gregory, indian, islamic_civil, islamic_tbla, islamic_umalqura, 1603 * japanese, persian. 1604 * @returns { Calendar } Calendar object 1605 * @syscap SystemCapability.Global.I18n 1606 * @crossplatform 1607 * @since 10 1608 */ 1609 /** 1610 * Obtains the Calendar object for the specified locale and calendar type. 1611 * 1612 * @param { string } locale - Locale ID, which consists of the language, script, and country/region, 1613 * for example, zh-Hans-CN. 1614 * @param { string } [type] - Calendar. The value can be: "buddhist", "chinese", "coptic", "ethiopic", 1615 * "hebrew", "gregory", "indian", "islamic_civil", "islamic_tbla", 1616 * "islamic_umalqura", "japanese", or "persian". The default value is the default 1617 * calendar of the locale. For details about the meanings and application scenarios of 1618 * different values, see Calendar Setting. 1619 * @returns { Calendar } Calendar object 1620 * @syscap SystemCapability.Global.I18n 1621 * @crossplatform 1622 * @atomicservice 1623 * @since arkts {'1.1':'12','1.2':'20'} 1624 * @arkts 1.1&1.2 1625 */ 1626 export function getCalendar(locale: string, type?: string): Calendar; 1627 1628 /** 1629 * Provides the API for accessing Calendar name, time and date related information. 1630 * 1631 * @syscap SystemCapability.Global.I18n 1632 * @since 7 1633 */ 1634 /** 1635 * Provides the API for accessing Calendar name, time and date related information. 1636 * 1637 * @syscap SystemCapability.Global.I18n 1638 * @crossplatform 1639 * @since 10 1640 */ 1641 /** 1642 * Provides the API for accessing Calendar name, time and date related information. 1643 * 1644 * @syscap SystemCapability.Global.I18n 1645 * @crossplatform 1646 * @atomicservice 1647 * @since arkts {'1.1':'12','1.2':'20'} 1648 * @arkts 1.1&1.2 1649 */ 1650 export class Calendar { 1651 /** 1652 * set the date. 1653 * 1654 * @param { Date } date - Date object used to set the time and date. 1655 * @syscap SystemCapability.Global.I18n 1656 * @since 8 1657 */ 1658 /** 1659 * set the date. 1660 * 1661 * @param { Date } date - Date object used to set the time and date. 1662 * @syscap SystemCapability.Global.I18n 1663 * @crossplatform 1664 * @since 10 1665 */ 1666 /** 1667 * Sets the date and time for a Calendar object. 1668 * 1669 * @param { Date } date - Date and time. Note: The month starts from 0. For example, 0 indicates January. 1670 * @syscap SystemCapability.Global.I18n 1671 * @crossplatform 1672 * @atomicservice 1673 * @since arkts {'1.1':'12','1.2':'20'} 1674 * @arkts 1.1&1.2 1675 */ 1676 setTime(date: Date): void; 1677 1678 /** 1679 * set the time. 1680 * 1681 * @param { number } time - Indicates the elapsed milliseconds from 1970.1.1 00:00:00 GMT. 1682 * @syscap SystemCapability.Global.I18n 1683 * @since 8 1684 */ 1685 /** 1686 * set the time. 1687 * 1688 * @param { number } time - Indicates the elapsed milliseconds from 1970.1.1 00:00:00 GMT. 1689 * @syscap SystemCapability.Global.I18n 1690 * @crossplatform 1691 * @since 10 1692 */ 1693 /** 1694 * Sets the date and time for a Calendar object. 1695 * 1696 * @param { number } time - Unix timestamp, which indicates the number of milliseconds that have elapsed since the 1697 * Unix epoch. 1698 * @syscap SystemCapability.Global.I18n 1699 * @crossplatform 1700 * @atomicservice 1701 * @since arkts {'1.1':'12','1.2':'20'} 1702 * @arkts 1.1&1.2 1703 */ 1704 setTime(time: number): void; 1705 1706 /** 1707 * Set the time 1708 * 1709 * @param { number } year - The year field of the calendar, ranges from 0 to 9999. 1710 * @param { number } month - The month field of the calendar, ranges from 0 to 11. 1711 * @param { number } date - The day field of the calendar, ranges from 1 to 31. 1712 * @param { number } hour - The hour field of the calendar, ranges from 0 to 23. 1713 * @param { number } minute - The minute field of the calendar, ranges from 0 to 59. 1714 * @param { number } second - the second field of the calendar, ranges from 0 to 59. 1715 * @syscap SystemCapability.Global.I18n 1716 * @since 8 1717 */ 1718 /** 1719 * Set the time 1720 * 1721 * @param { number } year - The year field of the calendar, ranges from 0 to 9999. 1722 * @param { number } month - The month field of the calendar, ranges from 0 to 11. 1723 * @param { number } date - The day field of the calendar, ranges from 1 to 31. 1724 * @param { number } hour - The hour field of the calendar, ranges from 0 to 23. 1725 * @param { number } minute - The minute field of the calendar, ranges from 0 to 59. 1726 * @param { number } second - the second field of the calendar, ranges from 0 to 59. 1727 * @syscap SystemCapability.Global.I18n 1728 * @crossplatform 1729 * @since 10 1730 */ 1731 /** 1732 * Sets the year, month, day, hour, minute, and second for this Calendar object. 1733 * 1734 * @param { number } year - Year to set. 1735 * @param { number } month - Month to set. Note: The month starts from 0. For example, 0 indicates January. 1736 * @param { number } date - Day to set. 1737 * @param { number } hour - Hour to set. The default value is the current system time. 1738 * @param { number } minute - Minute to set. The default value is the current system time. 1739 * @param { number } second - Second to set. The default value is the current system time. 1740 * @syscap SystemCapability.Global.I18n 1741 * @crossplatform 1742 * @atomicservice 1743 * @since arkts {'1.1':'12','1.2':'20'} 1744 * @arkts 1.1&1.2 1745 */ 1746 set(year: number, month: number, date:number, hour?: number, minute?: number, second?: number): void; 1747 1748 /** 1749 * Set the timezone of this calendar. 1750 * 1751 * @param { string } timezone - The id of a timezone. 1752 * @syscap SystemCapability.Global.I18n 1753 * @since 8 1754 */ 1755 /** 1756 * Set the timezone of this calendar. 1757 * 1758 * @param { string } timezone - The id of a timezone. 1759 * @syscap SystemCapability.Global.I18n 1760 * @crossplatform 1761 * @since 10 1762 */ 1763 /** 1764 * Sets the time zone of this Calendar object. 1765 * 1766 * @param { string } timezone - Valid time zone ID, for example, Asia/Shanghai. 1767 * @syscap SystemCapability.Global.I18n 1768 * @crossplatform 1769 * @atomicservice 1770 * @since arkts {'1.1':'12','1.2':'20'} 1771 * @arkts 1.1&1.2 1772 */ 1773 setTimeZone(timezone: string): void; 1774 1775 /** 1776 * Get the timezone id of this calendar instance. 1777 * 1778 * @returns { string } the timezone id of this calendar. 1779 * @syscap SystemCapability.Global.I18n 1780 * @since 8 1781 */ 1782 /** 1783 * Get the timezone id of this calendar instance. 1784 * 1785 * @returns { string } the timezone id of this calendar. 1786 * @syscap SystemCapability.Global.I18n 1787 * @crossplatform 1788 * @since 10 1789 */ 1790 /** 1791 * Obtains the time zone ID of this Calendar object. 1792 * 1793 * @returns { string } Time zone ID. 1794 * @syscap SystemCapability.Global.I18n 1795 * @crossplatform 1796 * @atomicservice 1797 * @since arkts {'1.1':'12','1.2':'20'} 1798 * @arkts 1.1&1.2 1799 */ 1800 getTimeZone(): string; 1801 1802 /** 1803 * Get the start day of a week. 1 indicates Sunday, 7 indicates Saturday. 1804 * 1805 * @returns { number } start day of a week. 1806 * @syscap SystemCapability.Global.I18n 1807 * @since 8 1808 */ 1809 /** 1810 * Get the start day of a week. 1 indicates Sunday, 7 indicates Saturday. 1811 * 1812 * @returns { number } start day of a week. 1813 * @syscap SystemCapability.Global.I18n 1814 * @crossplatform 1815 * @since 10 1816 */ 1817 /** 1818 * Obtains the first day of a week for this Calendar object. 1819 * 1820 * @returns { number } First day of a week. The value 1 indicates Sunday, and the value 7 indicates Saturday. 1821 * @syscap SystemCapability.Global.I18n 1822 * @crossplatform 1823 * @atomicservice 1824 * @since arkts {'1.1':'12','1.2':'20'} 1825 * @arkts 1.1&1.2 1826 */ 1827 getFirstDayOfWeek(): number; 1828 1829 /** 1830 * Set the start day of a week. 1 indicates Sunday, 7 indicates Saturday. 1831 * 1832 * @param { number } value - Indicates the start day of a week. 1 indicates Sunday, 7 indicates Saturday. 1833 * @syscap SystemCapability.Global.I18n 1834 * @since 8 1835 */ 1836 /** 1837 * Set the start day of a week. 1 indicates Sunday, 7 indicates Saturday. 1838 * 1839 * @param { number } value - Indicates the start day of a week. 1 indicates Sunday, 7 indicates Saturday. 1840 * @syscap SystemCapability.Global.I18n 1841 * @crossplatform 1842 * @since 10 1843 */ 1844 /** 1845 * Sets the first day of a week for this Calendar object. 1846 * 1847 * @param { number } value - Start day of a week. The value 1 indicates Sunday, and the value 7 indicates Saturday. 1848 * @syscap SystemCapability.Global.I18n 1849 * @crossplatform 1850 * @atomicservice 1851 * @since arkts {'1.1':'12','1.2':'20'} 1852 * @arkts 1.1&1.2 1853 */ 1854 setFirstDayOfWeek(value: number): void; 1855 1856 /** 1857 * Get the minimal days of a week, which is needed for the first day of a year. 1858 * 1859 * @returns { number } the minimal days of a week. 1860 * @syscap SystemCapability.Global.I18n 1861 * @since 8 1862 */ 1863 /** 1864 * Get the minimal days of a week, which is needed for the first day of a year. 1865 * 1866 * @returns { number } the minimal days of a week. 1867 * @syscap SystemCapability.Global.I18n 1868 * @crossplatform 1869 * @since 10 1870 */ 1871 /** 1872 * Obtains the minimum number of days in the first week for this Calendar object. 1873 * 1874 * @returns { number } Minimum number of days in the first week of a year. 1875 * @syscap SystemCapability.Global.I18n 1876 * @crossplatform 1877 * @atomicservice 1878 * @since arkts {'1.1':'12','1.2':'20'} 1879 * @arkts 1.1&1.2 1880 */ 1881 getMinimalDaysInFirstWeek(): number; 1882 1883 /** 1884 * Set the minimal days of a week, which is needed for the first week of a year. 1885 * 1886 * @param { number } value - The value to be set. 1887 * @syscap SystemCapability.Global.I18n 1888 * @since 8 1889 */ 1890 /** 1891 * Set the minimal days of a week, which is needed for the first week of a year. 1892 * 1893 * @param { number } value - The value to be set. 1894 * @syscap SystemCapability.Global.I18n 1895 * @crossplatform 1896 * @since 10 1897 */ 1898 /** 1899 * Sets the minimum number of days in the first week for this Calendar object. 1900 * 1901 * @param { number } value - Minimum number of days in the first week of a year. 1902 * @syscap SystemCapability.Global.I18n 1903 * @crossplatform 1904 * @atomicservice 1905 * @since arkts {'1.1':'12','1.2':'20'} 1906 * @arkts 1.1&1.2 1907 */ 1908 setMinimalDaysInFirstWeek(value: number): void; 1909 1910 /** 1911 * Get the associated value with the field. 1912 * 1913 * @param { string } field - Field values such as era, year, month, week_of_year, week_of_month, date, day_of_year, day_of_week 1914 * day_of_week_in_month, hour, hour_of_day, minute, second, millisecond, zone_offset, dst_offset, year_woy, 1915 * dow_local, extended_year, julian_day, milliseconds_in_day, is_leap_month. 1916 * @returns { number } the associated value. 1917 * @syscap SystemCapability.Global.I18n 1918 * @since 8 1919 */ 1920 /** 1921 * Get the associated value with the field. 1922 * 1923 * @param { string } field - Field values such as era, year, month, week_of_year, week_of_month, date, day_of_year, day_of_week 1924 * day_of_week_in_month, hour, hour_of_day, minute, second, millisecond, zone_offset, dst_offset, year_woy, 1925 * dow_local, extended_year, julian_day, milliseconds_in_day, is_leap_month. 1926 * @returns { number } the associated value. 1927 * @syscap SystemCapability.Global.I18n 1928 * @crossplatform 1929 * @since 10 1930 */ 1931 /** 1932 * Obtains the values of the calendar attributes in this Calendar object. 1933 * 1934 * @param { string } field - Calendar attributes. The following table lists the supported attribute values. 1935 * @returns { number } Value of the calendar attribute. For example, if the year of the internal date of the 1936 * current Calendar object is 1990, get('year') returns 1990. 1937 * @syscap SystemCapability.Global.I18n 1938 * @crossplatform 1939 * @atomicservice 1940 * @since arkts {'1.1':'12','1.2':'20'} 1941 * @arkts 1.1&1.2 1942 */ 1943 get(field: string): number; 1944 1945 /** 1946 * Get calendar's name localized for display in the given locale. 1947 * 1948 * @param { string } locale - Locale used to get the localized name for this calendar. It must be a valid locale. 1949 * @returns { string } the localized name of this calendar. 1950 * @syscap SystemCapability.Global.I18n 1951 * @since 8 1952 */ 1953 /** 1954 * Obtains calendar display name in the specified language. 1955 * 1956 * @param { string } locale - System locale, which consists of the language, script, and country/region. 1957 * @returns { string } Calendar display name in the specified language. For example, buddhist is displayed as 1958 * Buddhist Calendar if the locale is en-US. 1959 * @syscap SystemCapability.Global.I18n 1960 * @atomicservice 1961 * @since arkts {'1.1':'12','1.2':'20'} 1962 * @arkts 1.1&1.2 1963 */ 1964 getDisplayName(locale: string): string; 1965 1966 /** 1967 * Returns true if the given date is a weekend day. If the date is not given, 1968 * the date object of this calendar is used. 1969 * 1970 * @param { Date } [date] - Date object whose attribute is desired. 1971 * @returns { boolean } whether the date is a weekend day. 1972 * @syscap SystemCapability.Global.I18n 1973 * @since 8 1974 */ 1975 /** 1976 * Returns true if the given date is a weekend day. If the date is not given, 1977 * the date object of this calendar is used. 1978 * 1979 * @param { Date } [date] - Date object whose attribute is desired. 1980 * @returns { boolean } whether the date is a weekend day. 1981 * @syscap SystemCapability.Global.I18n 1982 * @crossplatform 1983 * @since 10 1984 */ 1985 /** 1986 * Checks whether a given date is a weekend in this Calendar object. 1987 * 1988 * @param { Date } [date] - Date and time. Note: The month starts from 0. For example, 0 indicates January. 1989 * The default value is current date of the Calendar object. 1990 * @returns { boolean } The value "true" indicates that the specified date is a weekend, and the value "false" 1991 * indicates the opposite. 1992 * @syscap SystemCapability.Global.I18n 1993 * @crossplatform 1994 * @atomicservice 1995 * @since arkts {'1.1':'12','1.2':'20'} 1996 * @arkts 1.1&1.2 1997 */ 1998 isWeekend(date?: Date): boolean; 1999 2000 /** 2001 * Adds or subtract the specified amount of time to the given calendar field. 2002 * 2003 * @param { string } field - field values such as year, month, week_of_year, week_of_month, date, day_of_year, day_of_week 2004 * day_of_week_in_month, hour, hour_of_day, minute, second, millisecond 2005 * @param { number } amount - the amount of date or time to be added to the field. 2006 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 2007 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 2008 * @syscap SystemCapability.Global.I18n 2009 * @crossplatform 2010 * @since 11 2011 */ 2012 /** 2013 * Performs addition or subtraction on the calendar attributes of this Calendar object. 2014 * 2015 * @param { string } field - Calendar attribute. The value can be any of the following: year, month, week_of_year, 2016 * week_of_month, date, day_of_year, day_of_week, day_of_week_in_month, hour, 2017 * hour_of_day, minute, second, millisecond. For details about the values, see get. 2018 * @param { number } amount - Addition or subtraction amount. 2019 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2020 * 2.Incorrect parameter types. 2021 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 2022 * @syscap SystemCapability.Global.I18n 2023 * @crossplatform 2024 * @atomicservice 2025 * @since arkts {'1.1':'12','1.2':'20'} 2026 * @arkts 1.1&1.2 2027 */ 2028 add(field: string, amount: number): void; 2029 2030 /** 2031 * Get the UTC milliseconds. 2032 * 2033 * @returns { number } the calendar time as UTC milliseconds. 2034 * @syscap SystemCapability.Global.I18n 2035 * @crossplatform 2036 * @since 11 2037 */ 2038 /** 2039 * Obtains the timestamp of this Calendar object. 2040 * 2041 * @returns { number } Unix timestamp, which indicates the number of milliseconds that have elapsed since the 2042 * Unix epoch. 2043 * @syscap SystemCapability.Global.I18n 2044 * @crossplatform 2045 * @atomicservice 2046 * @since arkts {'1.1':'12','1.2':'20'} 2047 * @arkts 1.1&1.2 2048 */ 2049 getTimeInMillis(): number; 2050 2051 /** 2052 * Returns days comparison result. 2053 * 2054 * @param { Date } date - Date object to be compared. 2055 * @returns { number } value of of the comparison result. A positive value indicates that the date is later, 2056 * and a negative value indicates that the date is earlier. 2057 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 2058 * @syscap SystemCapability.Global.I18n 2059 * @crossplatform 2060 * @since 11 2061 */ 2062 /** 2063 * Compares the current date of this Calendar object with the specified date for the difference in the number of 2064 * days. 2065 * 2066 * @param { Date } date - Date and time. Note: The month starts from 0. For example, 0 indicates January. 2067 * @returns { number } Difference in the number of days. A positive number indicates that the calendar date is 2068 * earlier, and a negative number indicates the opposite. The value is accurate to 2069 * milliseconds. If the value is less than one day, it is considered as one day. 2070 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2071 * 2.Incorrect parameter types. 2072 * @syscap SystemCapability.Global.I18n 2073 * @crossplatform 2074 * @atomicservice 2075 * @since arkts {'1.1':'12','1.2':'20'} 2076 * @arkts 1.1&1.2 2077 */ 2078 compareDays(date: Date): number; 2079 } 2080 2081 /** 2082 * Judge whether the locale is RTL locale. 2083 * 2084 * @param { string } locale - The locale to be used. 2085 * @returns { boolean } true representing the locale is an RTL locale 2086 * @syscap SystemCapability.Global.I18n 2087 * @since 7 2088 */ 2089 /** 2090 * Judge whether the locale is RTL locale. 2091 * 2092 * @param { string } locale - The locale to be used. 2093 * @returns { boolean } true representing the locale is an RTL locale 2094 * @syscap SystemCapability.Global.I18n 2095 * @crossplatform 2096 * @since 10 2097 */ 2098 /** 2099 * Checks whether the input character is of the right to left (RTL) language. 2100 * 2101 * @param { string } locale - Input character. If the input is a string, only the type of the first character is checked. 2102 * @returns { boolean } true if the input character is of the RTL language, and false otherwise. 2103 * @syscap SystemCapability.Global.I18n 2104 * @crossplatform 2105 * @atomicservice 2106 * @since arkts {'1.1':'12','1.2':'20'} 2107 * @arkts 1.1&1.2 2108 */ 2109 export function isRTL(locale: string): boolean; 2110 2111 /** 2112 * Obtains a BreakIterator object for finding the location of break point in text. 2113 * 2114 * @param { string } locale - the returned BreakIterator will adapt the rule, specified by the locale, to break text. 2115 * @returns { BreakIterator } a newly constructed BreakIterator object. 2116 * @syscap SystemCapability.Global.I18n 2117 * @since 8 2118 */ 2119 /** 2120 * Obtains a BreakIterator object. The BreakIterator object maintains an internal break iterator that can be used to 2121 * access various line break points. 2122 * 2123 * @param { string } locale - System locale, which consists of the language, script, and country/region. The 2124 * generated BreakIterator object calculates the positions of line breaks based on 2125 * the rules of the specified locale. 2126 * @returns { BreakIterator } BreakIterator object. 2127 * @syscap SystemCapability.Global.I18n 2128 * @atomicservice 2129 * @since arkts {'1.1':'12','1.2':'20'} 2130 * @arkts 1.1&1.2 2131 */ 2132 export function getLineInstance(locale: string): BreakIterator; 2133 2134 /** 2135 * The BreakIterator class is used for finding the location of break point in text. 2136 * 2137 * @syscap SystemCapability.Global.I18n 2138 * @since 8 2139 */ 2140 /** 2141 * The BreakIterator class is used for finding the location of break point in text. 2142 * 2143 * @syscap SystemCapability.Global.I18n 2144 * @atomicservice 2145 * @since arkts {'1.1':'12','1.2':'20'} 2146 * @arkts 1.1&1.2 2147 */ 2148 export class BreakIterator { 2149 /** 2150 * Obtains the current position of the BreakIterator instance. 2151 * 2152 * @returns { number } the current position of the BreakIterator instance. 2153 * @syscap SystemCapability.Global.I18n 2154 * @since 8 2155 */ 2156 /** 2157 * Obtains the position of the break iterator in the text. 2158 * 2159 * @returns { number } Position of the break iterator in the text. 2160 * @syscap SystemCapability.Global.I18n 2161 * @atomicservice 2162 * @since arkts {'1.1':'12','1.2':'20'} 2163 * @arkts 1.1&1.2 2164 */ 2165 current(): number; 2166 2167 /** 2168 * Set the BreakIterator's position to the first break point, the first break point is always the beginning of the 2169 * processed text. 2170 * 2171 * @returns { number } the index of the first break point. 2172 * @syscap SystemCapability.Global.I18n 2173 * @since 8 2174 */ 2175 /** 2176 * Moves the break iterator to the first line break point, which is always at the beginning of the processed text. 2177 * 2178 * @returns { number } Offset of the first line break point in the processed text. 2179 * @syscap SystemCapability.Global.I18n 2180 * @atomicservice 2181 * @since arkts {'1.1':'12','1.2':'20'} 2182 * @arkts 1.1&1.2 2183 */ 2184 first(): number; 2185 2186 /** 2187 * Set the BreakIterator's position to the last break point. the last break point is always the index beyond the 2188 * last character of the processed text. 2189 * 2190 * @returns { number } the index of the last break point. 2191 * @syscap SystemCapability.Global.I18n 2192 * @since 8 2193 */ 2194 /** 2195 * Moves the break iterator to the last line break point, which is always the next position after the end of the 2196 * processed text. 2197 * 2198 * @returns { number } Offset of the last line break point in the processed text. 2199 * @syscap SystemCapability.Global.I18n 2200 * @atomicservice 2201 * @since arkts {'1.1':'12','1.2':'20'} 2202 * @arkts 1.1&1.2 2203 */ 2204 last(): number; 2205 2206 /** 2207 * Set the BreakIterator's position to the nth break point from the current break point. 2208 * 2209 * @param { number } [index] - indicates the number of break points to advance. If index is not given, n is treated as 1. 2210 * @returns { number } the index of the BreakIterator after moving. If there is not enough break points, returns -1. 2211 * @syscap SystemCapability.Global.I18n 2212 * @since 8 2213 */ 2214 /** 2215 * Moves the break iterator backward by the specified number of line break points. 2216 * 2217 * @param { number } [index] - Number of line break points for moving the break iterator. The value is an integer. 2218 * A positive number means to move the break iterator backward, and a negative number 2219 * means to move the break iterator forward. The default value is 1. 2220 * @returns { number } Position of the break iterator in the text after movement. The value -1 is returned if the 2221 * position of the break iterator is outside of the processed text after movement. 2222 * @syscap SystemCapability.Global.I18n 2223 * @atomicservice 2224 * @since arkts {'1.1':'12','1.2':'20'} 2225 * @arkts 1.1&1.2 2226 */ 2227 next(index?: number): number; 2228 2229 /** 2230 * Set the BreakIterator's position to the break point preceding the current break point. 2231 * 2232 * @returns { number } the index of the BreakIterator after moving. If there is not enough break points, returns -1. 2233 * @syscap SystemCapability.Global.I18n 2234 * @since 8 2235 */ 2236 /** 2237 * Moves the break iterator foreward by one line break point. 2238 * 2239 * @returns { number } Position of the break iterator in the text after movement. The value -1 is returned if the 2240 * position of the break iterator is outside of the processed text after movement. 2241 * @syscap SystemCapability.Global.I18n 2242 * @atomicservice 2243 * @since arkts {'1.1':'12','1.2':'20'} 2244 * @arkts 1.1&1.2 2245 */ 2246 previous(): number; 2247 2248 /** 2249 * Set the text to be processed. 2250 * 2251 * @param { string } text - Indicates the text to be processed by the BreakIterator. 2252 * @syscap SystemCapability.Global.I18n 2253 * @since 8 2254 */ 2255 /** 2256 * Sets the text to be processed by the BreakIterator object. 2257 * 2258 * @param { string } text - Input text. 2259 * @syscap SystemCapability.Global.I18n 2260 * @atomicservice 2261 * @since arkts {'1.1':'12','1.2':'20'} 2262 * @arkts 1.1&1.2 2263 */ 2264 setLineBreakText(text: string): void; 2265 2266 /** 2267 * Set the BreakIterator's position to the first break point following the specified offset. 2268 * 2269 * @param { number } offset 2270 * @returns { number } the index of the BreakIterator after moving. If there is not enough break points, returns -1. 2271 * @syscap SystemCapability.Global.I18n 2272 * @since 8 2273 */ 2274 /** 2275 * Moves the line break iterator to the line break point after the specified position. 2276 * 2277 * @param { number } offset - Offset of the line break point. 2278 * @returns { number } Position of the break iterator in the text after movement. The value -1 is returned if the 2279 * position of the break iterator is outside of the processed text after movement. 2280 * @syscap SystemCapability.Global.I18n 2281 * @atomicservice 2282 * @since arkts {'1.1':'12','1.2':'20'} 2283 * @arkts 1.1&1.2 2284 */ 2285 following(offset: number): number; 2286 2287 /** 2288 * Obtains the text being processed. 2289 * 2290 * @returns { string } the text that is processed by the BreakIterator. 2291 * @syscap SystemCapability.Global.I18n 2292 * @since 8 2293 */ 2294 /** 2295 * Obtains the text processed by the BreakIterator object. 2296 * 2297 * @returns { string } Text being processed by the BreakIterator object. 2298 * @syscap SystemCapability.Global.I18n 2299 * @atomicservice 2300 * @since arkts {'1.1':'12','1.2':'20'} 2301 * @arkts 1.1&1.2 2302 */ 2303 getLineBreakText(): string; 2304 2305 /** 2306 * Returns true if the position indicated by the offset is a break point, otherwise false. The BreakIterator's 2307 * position will be set to the position indicated by the offset if it returns true, otherwise the BreakIterator 2308 * will be moved to the break point following the offset. 2309 * 2310 * @param { number } offset The offset to be checked. 2311 * @returns { boolean } true if the offset is a break point. 2312 * @syscap SystemCapability.Global.I18n 2313 * @since 8 2314 */ 2315 /** 2316 * Checks whether the specified position is a line break point. 2317 * 2318 * @param { number } offset - Specified position in the text. 2319 * @returns { boolean } Whether the specified position is a line break point. The value "true" indicates that the 2320 * specified position is a line break point, and the value "false" indicates the opposite. 2321 * If true is returned, the break iterator is moved to the position specified by offset. 2322 * Otherwise, the break iterator is moved to the text line break point after the position 2323 * specified by offset, which is equivalent to calling following. 2324 * @syscap SystemCapability.Global.I18n 2325 * @atomicservice 2326 * @since arkts {'1.1':'12','1.2':'20'} 2327 * @arkts 1.1&1.2 2328 */ 2329 isBoundary(offset: number): boolean; 2330 } 2331 2332 /** 2333 * Get IndexUtil object. 2334 * 2335 * @param { string } [locale] - Indicates a character string containing the locale information, including 2336 * the language and optionally the script and region, for the NumberFormat object. 2337 * @returns { IndexUtil } IndexUtil object. 2338 * @syscap SystemCapability.Global.I18n 2339 * @since 8 2340 */ 2341 /** 2342 * Creates an IndexUtil object. 2343 * 2344 * @param { string } [locale] - System locale, which consists of the language, script, and country/region. 2345 * The default value is the current system locale. 2346 * @returns { IndexUtil } IndexUtil object created based on the specified locale ID. 2347 * @syscap SystemCapability.Global.I18n 2348 * @atomicservice 2349 * @since arkts {'1.1':'12','1.2':'20'} 2350 * @arkts 1.1&1.2 2351 */ 2352 export function getInstance(locale?:string): IndexUtil; 2353 2354 /** 2355 * Sequence text can be grouped under the specified area, 2356 * and grouping index with different lengths can be specified. 2357 * 2358 * @syscap SystemCapability.Global.I18n 2359 * @since 8 2360 */ 2361 /** 2362 * Sequence text can be grouped under the specified area, 2363 * and grouping index with different lengths can be specified. 2364 * 2365 * @syscap SystemCapability.Global.I18n 2366 * @atomicservice 2367 * @since arkts {'1.1':'12','1.2':'20'} 2368 * @arkts 1.1&1.2 2369 */ 2370 export class IndexUtil { 2371 /** 2372 * Get a list of labels for use as a UI index 2373 * 2374 * @returns { Array<string> } a list of labels 2375 * @syscap SystemCapability.Global.I18n 2376 * @since 8 2377 */ 2378 /** 2379 * Obtains the index list of the current locale. 2380 * 2381 * @returns { Array<string> } Index list of the current locale. The first and last elements are "...". 2382 * @syscap SystemCapability.Global.I18n 2383 * @atomicservice 2384 * @since arkts {'1.1':'12','1.2':'20'} 2385 * @arkts 1.1&1.2 2386 */ 2387 getIndexList(): Array<string>; 2388 2389 /** 2390 * Add the index characters from a Locale to the index. 2391 * 2392 * @param { string } locale - The locale whose index characters are to be added. 2393 * @syscap SystemCapability.Global.I18n 2394 * @since 8 2395 */ 2396 /** 2397 * Adds the index list of a new locale to the index list of the current locale to form a composite list. 2398 * 2399 * @param { string } locale - System locale, which consists of the language, script, and country/region. 2400 * @syscap SystemCapability.Global.I18n 2401 * @atomicservice 2402 * @since arkts {'1.1':'12','1.2':'20'} 2403 * @arkts 1.1&1.2 2404 */ 2405 addLocale(locale: string): void; 2406 2407 /** 2408 * Get corresponding index of the input text. 2409 * 2410 * @param { string } text - input text 2411 * @returns { string } index of the input text 2412 * @syscap SystemCapability.Global.I18n 2413 * @since 8 2414 */ 2415 /** 2416 * Obtains the index of the text object. 2417 * 2418 * @param { string } text - text object. 2419 * @returns { string } Index of the text object. If no proper index is found, an empty string is returned. 2420 * @syscap SystemCapability.Global.I18n 2421 * @atomicservice 2422 * @since arkts {'1.1':'12','1.2':'20'} 2423 * @arkts 1.1&1.2 2424 */ 2425 getIndex(text: string): string; 2426 } 2427 2428 /** 2429 * Provides the API for accessing unicode character properties. For example, determine whether a character is a number. 2430 * 2431 * @syscap SystemCapability.Global.I18n 2432 * @since 8 2433 * @deprecated since 9 2434 * @useinstead Unicode 2435 */ 2436 export class Character { 2437 /** 2438 * Checks whether the input character is a digit. 2439 * 2440 * @param { string } ch - Input character. If the input is a string, only the type of the first character is 2441 * checked. 2442 * @returns { boolean } true if the input character is a digit, and false otherwise. 2443 * @syscap SystemCapability.Global.I18n 2444 * @since 8 2445 * @deprecated since 9 2446 * @useinstead Unicode.isDigit 2447 */ 2448 isDigit(ch: string): boolean; 2449 2450 /** 2451 * Checks whether the input character is a space. 2452 * 2453 * @param { string } ch - Input character. If the input is a string, only the type of the first character is 2454 * checked. 2455 * @returns { boolean } true if the input character is a space, and false otherwise. 2456 * @syscap SystemCapability.Global.I18n 2457 * @since 8 2458 * @deprecated since 9 2459 * @useinstead Unicode.isSpaceChar 2460 */ 2461 isSpaceChar(ch: string): boolean; 2462 2463 /** 2464 * Checks whether the input character is a whitespace. 2465 * 2466 * @param { string } ch - Input character. If the input is a string, only the type of the first character is 2467 * checked. 2468 * @returns { boolean } true if the input character is a white space, and false otherwise. 2469 * @syscap SystemCapability.Global.I18n 2470 * @since 8 2471 * @deprecated since 9 2472 * @useinstead Unicode.isWhitespace 2473 */ 2474 isWhitespace(ch: string): boolean; 2475 2476 /** 2477 * Checks whether the input character is of the right to left (RTL) language. 2478 * 2479 * @param { string } ch - Input character. If the input is a string, only the type of the first character is 2480 * checked. 2481 * @returns { boolean } true if the input character is of the RTL language, and false otherwise. 2482 * @syscap SystemCapability.Global.I18n 2483 * @since 8 2484 * @deprecated since 9 2485 * @useinstead Unicode.isRTL 2486 */ 2487 isRTL(ch: string): boolean; 2488 2489 /** 2490 * Checks whether the input character is an ideographic character. 2491 * 2492 * @param { string } ch - Input character. If the input is a string, only the type of the first character is 2493 * checked. 2494 * @returns { boolean } true if the input character an ideographic character, and false otherwise. 2495 * @syscap SystemCapability.Global.I18n 2496 * @since 8 2497 * @deprecated since 9 2498 * @useinstead Unicode.isIdeograph 2499 */ 2500 isIdeograph(ch: string): boolean; 2501 2502 /** 2503 * Checks whether the input character is a letter. 2504 * 2505 * @param { string } ch - Input character. If the input is a string, only the type of the first character is 2506 * checked. 2507 * @returns { boolean } true if the input character a letter, and false otherwise. 2508 * @syscap SystemCapability.Global.I18n 2509 * @since 8 2510 * @deprecated since 9 2511 * @useinstead Unicode.isLetter 2512 */ 2513 isLetter(ch: string): boolean; 2514 2515 /** 2516 * Checks whether the input character is a lowercase letter. 2517 * 2518 * @param { string } ch - Input character. If the input is a string, only the type of the first character is 2519 * checked. 2520 * @returns { boolean } true if the input character a lowercase letter, and false otherwise. 2521 * @syscap SystemCapability.Global.I18n 2522 * @since 8 2523 * @deprecated since 9 2524 * @useinstead Unicode.isLowerCase 2525 */ 2526 isLowerCase(ch: string): boolean; 2527 2528 /** 2529 * Checks whether the input character is an uppercase letter. 2530 * 2531 * @param { string } ch - Input character. If the input is a string, only the type of the first character is 2532 * checked. 2533 * @returns { boolean } true if the input character an uppercase letter, and false otherwise. 2534 * @syscap SystemCapability.Global.I18n 2535 * @since 8 2536 * @deprecated since 9 2537 * @useinstead Unicode.isUpperCase 2538 */ 2539 isUpperCase(ch: string): boolean; 2540 2541 /** 2542 * Obtains the type of the input character. 2543 * 2544 * @param { string } ch - Input character. If the input is a string, only the type of the first character is 2545 * checked. 2546 * @returns { string } Type of the input character. 2547 * @syscap SystemCapability.Global.I18n 2548 * @since 8 2549 * @deprecated since 9 2550 * @useinstead Unicode.getType 2551 */ 2552 getType(ch: string): string; 2553 } 2554 2555 /** 2556 * Provides the API for accessing unicode character properties. For example, determine whether a character is a number. 2557 * 2558 * @syscap SystemCapability.Global.I18n 2559 * @since 9 2560 */ 2561 /** 2562 * Provides the API for accessing unicode character properties. For example, determine whether a character is a number. 2563 * 2564 * @syscap SystemCapability.Global.I18n 2565 * @crossplatform 2566 * @since 10 2567 */ 2568 /** 2569 * Provides the API for accessing unicode character properties. For example, determine whether a character is a number. 2570 * 2571 * @syscap SystemCapability.Global.I18n 2572 * @crossplatform 2573 * @atomicservice 2574 * @since arkts {'1.1':'12','1.2':'20'} 2575 * @arkts 1.1&1.2 2576 */ 2577 export class Unicode { 2578 /** 2579 * Determines whether the specified code point is a digit character 2580 * 2581 * @param { string } char - the character to be tested 2582 * @returns { boolean } true if the character is a digit character 2583 * @syscap SystemCapability.Global.I18n 2584 * @since 9 2585 */ 2586 /** 2587 * Determines whether the specified code point is a digit character 2588 * 2589 * @param { string } char - the character to be tested 2590 * @returns { boolean } true if the character is a digit character 2591 * @syscap SystemCapability.Global.I18n 2592 * @crossplatform 2593 * @since 10 2594 */ 2595 /** 2596 * Checks whether the input character is a digit. 2597 * 2598 * @param { string } ch - Input character. If the input is a string, only the type of the first character is 2599 * checked. 2600 * @returns { boolean } true if the input character is a digit, and false otherwise. 2601 * @static 2602 * @syscap SystemCapability.Global.I18n 2603 * @crossplatform 2604 * @atomicservice 2605 * @since arkts {'1.1':'12','1.2':'20'} 2606 * @arkts 1.1&1.2 2607 */ 2608 static isDigit(ch: string): boolean; 2609 2610 /** 2611 * Determines if the specified character is a space character or not. 2612 * 2613 * @param { string } char - the character to be tested 2614 * @returns { boolean } true if the character is a space character 2615 * @syscap SystemCapability.Global.I18n 2616 * @since 9 2617 */ 2618 /** 2619 * Determines if the specified character is a space character or not. 2620 * 2621 * @param { string } char - the character to be tested 2622 * @returns { boolean } true if the character is a space character 2623 * @syscap SystemCapability.Global.I18n 2624 * @crossplatform 2625 * @since 10 2626 */ 2627 /** 2628 * Checks whether the input character is a space. 2629 * 2630 * @param { string } ch - Input character. If the input is a string, only the type of the first character is 2631 * checked. 2632 * @returns { boolean } true if the input character is a space, and false otherwise. 2633 * @static 2634 * @syscap SystemCapability.Global.I18n 2635 * @crossplatform 2636 * @atomicservice 2637 * @since arkts {'1.1':'12','1.2':'20'} 2638 * @arkts 1.1&1.2 2639 */ 2640 static isSpaceChar(ch: string): boolean; 2641 2642 /** 2643 * Determines if the specified character is a whitespace character 2644 * 2645 * @param { string } char - the character to be tested 2646 * @returns { boolean } true if the character is a whitespace character 2647 * @syscap SystemCapability.Global.I18n 2648 * @since 9 2649 */ 2650 /** 2651 * Determines if the specified character is a whitespace character 2652 * 2653 * @param { string } char - the character to be tested 2654 * @returns { boolean } true if the character is a whitespace character 2655 * @syscap SystemCapability.Global.I18n 2656 * @crossplatform 2657 * @since 10 2658 */ 2659 /** 2660 * Checks whether the input character is a whitespace. 2661 * 2662 * @param { string } ch - Input character. If the input is a string, only the type of the first character is 2663 * checked. 2664 * @returns { boolean } true if the input character is a white space, and false otherwise. 2665 * @static 2666 * @syscap SystemCapability.Global.I18n 2667 * @crossplatform 2668 * @atomicservice 2669 * @since arkts {'1.1':'12','1.2':'20'} 2670 * @arkts 1.1&1.2 2671 */ 2672 static isWhitespace(ch: string): boolean; 2673 2674 /** 2675 * Determines if the specified character is a RTL character or not. 2676 * 2677 * @param { string } char - the character to be tested 2678 * @returns { boolean } true if the character is a RTL character 2679 * @syscap SystemCapability.Global.I18n 2680 * @since 9 2681 */ 2682 /** 2683 * Determines if the specified character is a RTL character or not. 2684 * 2685 * @param { string } char - the character to be tested 2686 * @returns { boolean } true if the character is a RTL character 2687 * @syscap SystemCapability.Global.I18n 2688 * @crossplatform 2689 * @since 10 2690 */ 2691 /** 2692 * Checks whether the input character is of the right to left (RTL) language. 2693 * 2694 * @param { string } ch - Input character. If the input is a string, only the type of the first character is 2695 * checked. 2696 * @returns { boolean } true if the input character is of the RTL language, and false otherwise. 2697 * @static 2698 * @syscap SystemCapability.Global.I18n 2699 * @crossplatform 2700 * @atomicservice 2701 * @since arkts {'1.1':'12','1.2':'20'} 2702 * @arkts 1.1&1.2 2703 */ 2704 static isRTL(ch: string): boolean; 2705 2706 /** 2707 * Determines if the specified character is a Ideographic character or not. 2708 * 2709 * @param { string } char - the character to be tested 2710 * @returns { boolean } true if the character is a Ideographic character 2711 * @syscap SystemCapability.Global.I18n 2712 * @since 9 2713 */ 2714 /** 2715 * Determines if the specified character is a Ideographic character or not. 2716 * 2717 * @param { string } char - the character to be tested 2718 * @returns { boolean } true if the character is a Ideographic character 2719 * @syscap SystemCapability.Global.I18n 2720 * @crossplatform 2721 * @since 10 2722 */ 2723 /** 2724 * Checks whether the input character is an ideographic character. 2725 * 2726 * @param { string } ch - Input character. If the input is a string, only the type of the first character is 2727 * checked. 2728 * @returns { boolean } true if the input character an ideographic character, and false otherwise. 2729 * @static 2730 * @syscap SystemCapability.Global.I18n 2731 * @crossplatform 2732 * @atomicservice 2733 * @since arkts {'1.1':'12','1.2':'20'} 2734 * @arkts 1.1&1.2 2735 */ 2736 static isIdeograph(ch: string): boolean; 2737 2738 /** 2739 * Determines if the specified character is a Letter or not. 2740 * 2741 * @param { string } char - the character to be tested 2742 * @returns { boolean } true if the character is a Letter 2743 * @syscap SystemCapability.Global.I18n 2744 * @since 9 2745 */ 2746 /** 2747 * Determines if the specified character is a Letter or not. 2748 * 2749 * @param { string } char - the character to be tested 2750 * @returns { boolean } true if the character is a Letter 2751 * @syscap SystemCapability.Global.I18n 2752 * @crossplatform 2753 * @since 10 2754 */ 2755 /** 2756 * Checks whether the input character is a letter. 2757 * 2758 * @param { string } ch - Input character. If the input is a string, only the type of the first character is 2759 * checked. 2760 * @returns { boolean } true if the input character a letter, and false otherwise. 2761 * @static 2762 * @syscap SystemCapability.Global.I18n 2763 * @crossplatform 2764 * @atomicservice 2765 * @since arkts {'1.1':'12','1.2':'20'} 2766 * @arkts 1.1&1.2 2767 */ 2768 static isLetter(ch: string): boolean; 2769 2770 /** 2771 * Determines if the specified character is a LowerCase character or not. 2772 * 2773 * @param { string } char - the character to be tested 2774 * @returns { boolean } true if the character is a LowerCase character 2775 * @syscap SystemCapability.Global.I18n 2776 * @since 9 2777 */ 2778 /** 2779 * Determines if the specified character is a LowerCase character or not. 2780 * 2781 * @param { string } char - the character to be tested 2782 * @returns { boolean } true if the character is a LowerCase character 2783 * @syscap SystemCapability.Global.I18n 2784 * @crossplatform 2785 * @since 10 2786 */ 2787 /** 2788 * Checks whether the input character is a lowercase letter. 2789 * 2790 * @param { string } ch - Input character. If the input is a string, only the type of the first character is 2791 * checked. 2792 * @returns { boolean } true if the input character a lowercase letter, and false otherwise. 2793 * @static 2794 * @syscap SystemCapability.Global.I18n 2795 * @crossplatform 2796 * @atomicservice 2797 * @since arkts {'1.1':'12','1.2':'20'} 2798 * @arkts 1.1&1.2 2799 */ 2800 static isLowerCase(ch: string): boolean; 2801 2802 /** 2803 * Determines if the specified character is a UpperCase character or not. 2804 * 2805 * @param { string } char - the character to be tested 2806 * @returns { boolean } true if the character is a UpperCase character 2807 * @syscap SystemCapability.Global.I18n 2808 * @since 9 2809 */ 2810 /** 2811 * Determines if the specified character is a UpperCase character or not. 2812 * 2813 * @param { string } char - the character to be tested 2814 * @returns { boolean } true if the character is a UpperCase character 2815 * @syscap SystemCapability.Global.I18n 2816 * @crossplatform 2817 * @since 10 2818 */ 2819 /** 2820 * Checks whether the input character is an uppercase letter. 2821 * 2822 * @param { string } ch - Input character. If the input is a string, only the type of the first character is 2823 * checked. 2824 * @returns { boolean } true if the input character an uppercase letter, and false otherwise. 2825 * @static 2826 * @syscap SystemCapability.Global.I18n 2827 * @crossplatform 2828 * @atomicservice 2829 * @since arkts {'1.1':'12','1.2':'20'} 2830 * @arkts 1.1&1.2 2831 */ 2832 static isUpperCase(ch: string): boolean; 2833 2834 /** 2835 * Get the general category value of the specified character. 2836 * 2837 * @param { string } char - the character to be tested 2838 * @returns { string } the general category of the specified character. 2839 * @syscap SystemCapability.Global.I18n 2840 * @since 9 2841 */ 2842 /** 2843 * Get the general category value of the specified character. 2844 * 2845 * @param { string } char - the character to be tested 2846 * @returns { string } the general category of the specified character. 2847 * @syscap SystemCapability.Global.I18n 2848 * @crossplatform 2849 * @since 10 2850 */ 2851 /** 2852 * Obtains the type of the input character. 2853 * 2854 * @param { string } ch - Input character. If the input is a string, only the type of the first character is 2855 * checked. 2856 * @returns { string } Type of the input character. 2857 * @static 2858 * @syscap SystemCapability.Global.I18n 2859 * @crossplatform 2860 * @atomicservice 2861 * @since arkts {'1.1':'12','1.2':'20'} 2862 * @arkts 1.1&1.2 2863 */ 2864 static getType(ch: string): string; 2865 } 2866 2867 /** 2868 * Checks whether the 24-hour clock is used. 2869 * 2870 * @returns { boolean } true if the 24-hour clock is used, and false otherwise. 2871 * @syscap SystemCapability.Global.I18n 2872 * @since 7 2873 * @deprecated since 9 2874 * @useinstead ohos.i18n/i18n.System#is24HourClock 2875 */ 2876 export function is24HourClock(): boolean; 2877 2878 /** 2879 * Sets the 24-hour clock. 2880 * 2881 * @permission ohos.permission.UPDATE_CONFIGURATION 2882 * @param { boolean } option - Whether to enable the 24-hour clock. The value "true" means to enable the 24-hour 2883 * clock, and the value "false" means the opposite. 2884 * @returns { boolean } true if the setting is successful, and false otherwise. 2885 * @syscap SystemCapability.Global.I18n 2886 * @since 7 2887 * @deprecated since 9 2888 * @useinstead ohos.i18n/i18n.System#set24HourClock 2889 */ 2890 export function set24HourClock(option: boolean): boolean; 2891 2892 /** 2893 * Adds a preferred language to the specified position on the preferred language list. 2894 * 2895 * @permission ohos.permission.UPDATE_CONFIGURATION 2896 * @param { string } language - Preferred language to add. 2897 * @param { number } [index] - Position to which the preferred language is added. The default value is the length of 2898 * the preferred language list. 2899 * @returns { boolean } true if the operation is successful, and false otherwise. 2900 * @syscap SystemCapability.Global.I18n 2901 * @since 8 2902 * @deprecated since 9 2903 * @useinstead ohos.i18n/i18n.System#addPreferredLanguage 2904 */ 2905 export function addPreferredLanguage(language: string, index?: number): boolean; 2906 2907 /** 2908 * Removes a preferred language from the specified position on the preferred language list. 2909 * 2910 * @permission ohos.permission.UPDATE_CONFIGURATION 2911 * @param { number } index - Position of the preferred language to delete. 2912 * @returns { boolean } Whether the operation is successful. The value "true" indicates that the operation is 2913 * successful, and the value "false" indicates the opposite. 2914 * @syscap SystemCapability.Global.I18n 2915 * @since 8 2916 * @deprecated since 9 2917 * @useinstead ohos.i18n/i18n.System#removePreferredLanguage 2918 */ 2919 export function removePreferredLanguage(index: number): boolean; 2920 2921 /** 2922 * Obtains the list of preferred languages. 2923 * 2924 * @returns { Array<string> } List of preferred languages. 2925 * @syscap SystemCapability.Global.I18n 2926 * @since 8 2927 * @deprecated since 9 2928 * @useinstead ohos.i18n/i18n.System#getPreferredLanguageList 2929 */ 2930 export function getPreferredLanguageList(): Array<string>; 2931 2932 /** 2933 * Obtains the first language in the preferred language list. 2934 * 2935 * @returns { string } First language in the preferred language list. 2936 * @syscap SystemCapability.Global.I18n 2937 * @since 8 2938 * @deprecated since 9 2939 * @useinstead ohos.i18n/i18n.System#getFirstPreferredLanguage 2940 */ 2941 export function getFirstPreferredLanguage(): string; 2942 2943 /** 2944 * Get the default TimeZone object or the TimeZone object corresponds to zoneID. 2945 * 2946 * @param { string } [zoneID] - TimeZone ID used to create TimeZone Object. 2947 * @returns { TimeZone } a TimeZone object corresponds to zoneID. 2948 * @syscap SystemCapability.Global.I18n 2949 * @since 7 2950 */ 2951 /** 2952 * Get the default TimeZone object or the TimeZone object corresponds to zoneID. 2953 * 2954 * @param { string } [zoneID] - TimeZone ID used to create TimeZone Object. 2955 * @returns { TimeZone } a TimeZone object corresponds to zoneID. 2956 * @syscap SystemCapability.Global.I18n 2957 * @crossplatform 2958 * @since 10 2959 */ 2960 /** 2961 * Obtains the TimeZone object corresponding to the specified time zone ID. 2962 * 2963 * @param { string } [zoneID] - Time zone ID. The default value is the system time zone. 2964 * @returns { TimeZone } TimeZone object corresponding to the time zone ID. 2965 * @syscap SystemCapability.Global.I18n 2966 * @crossplatform 2967 * @atomicservice 2968 * @since arkts {'1.1':'12','1.2':'20'} 2969 * @arkts 1.1&1.2 2970 */ 2971 export function getTimeZone(zoneID?: string): TimeZone; 2972 2973 /** 2974 * Provides the API for accessing TimeZone name, rawOffset and offset information. 2975 * 2976 * @syscap SystemCapability.Global.I18n 2977 * @since 7 2978 */ 2979 /** 2980 * Provides the API for accessing TimeZone name, rawOffset and offset information. 2981 * 2982 * @syscap SystemCapability.Global.I18n 2983 * @crossplatform 2984 * @since 10 2985 */ 2986 /** 2987 * Provides the API for accessing TimeZone name, rawOffset and offset information. 2988 * 2989 * @syscap SystemCapability.Global.I18n 2990 * @crossplatform 2991 * @atomicservice 2992 * @since arkts {'1.1':'12','1.2':'20'} 2993 * @arkts 1.1&1.2 2994 */ 2995 export class TimeZone { 2996 /** 2997 * Get the id of the TimeZone object. 2998 * 2999 * @returns { string } a string represents the timezone id. 3000 * @syscap SystemCapability.Global.I18n 3001 * @since 7 3002 */ 3003 /** 3004 * Get the id of the TimeZone object. 3005 * 3006 * @returns { string } a string represents the timezone id. 3007 * @syscap SystemCapability.Global.I18n 3008 * @crossplatform 3009 * @since 10 3010 */ 3011 /** 3012 * Obtains the ID of the specified TimeZone object. 3013 * 3014 * @returns { string } Time zone ID corresponding to the TimeZone object. 3015 * @syscap SystemCapability.Global.I18n 3016 * @crossplatform 3017 * @atomicservice 3018 * @since arkts {'1.1':'12','1.2':'20'} 3019 * @arkts 1.1&1.2 3020 */ 3021 getID(): string; 3022 3023 /** 3024 * Get the displayName of the TimeZone Object under the locale. 3025 * 3026 * @param { string } [locale] - the locale tag use to display timezone object's name. 3027 * @param { boolean } [isDST] - wether consider daylight saving time when display timezone object's name. 3028 * @returns { string } a string represents the display name. 3029 * @syscap SystemCapability.Global.I18n 3030 * @since 7 3031 */ 3032 /** 3033 * Obtains time zone display name in the specified language. 3034 * 3035 * @param { string } [locale] - System locale, which consists of the language, script, and country/region. 3036 * The default value is the current system locale. 3037 * @param { boolean } [isDST] - Whether DST information is displayed. The value "true" indicates that DST 3038 * information is displayed, and the value "false" indicates the opposite. 3039 * The default value is false. 3040 * @returns { string } Time zone display name in the specified language. 3041 * @syscap SystemCapability.Global.I18n 3042 * @atomicservice 3043 * @since arkts {'1.1':'12','1.2':'20'} 3044 * @arkts 1.1&1.2 3045 */ 3046 getDisplayName(locale?: string, isDST?: boolean): string; 3047 3048 /** 3049 * Get the raw offset of the TimeZone object. 3050 * 3051 * @returns { number } a number represents the raw offset. 3052 * @syscap SystemCapability.Global.I18n 3053 * @since 7 3054 */ 3055 /** 3056 * Get the raw offset of the TimeZone object. 3057 * 3058 * @returns { number } a number represents the raw offset. 3059 * @syscap SystemCapability.Global.I18n 3060 * @crossplatform 3061 * @since 10 3062 */ 3063 /** 3064 * Obtains the raw offset of the specified time zone. 3065 * 3066 * @returns { number } Raw offset of the time zone, in milliseconds. 3067 * @syscap SystemCapability.Global.I18n 3068 * @crossplatform 3069 * @atomicservice 3070 * @since arkts {'1.1':'12','1.2':'20'} 3071 * @arkts 1.1&1.2 3072 */ 3073 getRawOffset(): number; 3074 3075 /** 3076 * Get the offset of the TimeZone object. 3077 * 3078 * @param { number } [date] - Indicates a date use to compute offset. 3079 * @returns { number } a number represents the offset with date. 3080 * @syscap SystemCapability.Global.I18n 3081 * @since 7 3082 */ 3083 /** 3084 * Get the offset of the TimeZone object. 3085 * 3086 * @param { number } [date] - Indicates a date use to compute offset. 3087 * @returns { number } a number represents the offset with date. 3088 * @syscap SystemCapability.Global.I18n 3089 * @crossplatform 3090 * @since 10 3091 */ 3092 /** 3093 * Obtains the offset of the specified time zone at the specified time. 3094 * 3095 * @param { number } [date] - Specified time, in milliseconds. The default value is the system time. 3096 * @returns { number } Time zone offset, in milliseconds. When the DST is used, the time zone offset 3097 * is the raw time zone offset plus the DST offset. 3098 * @syscap SystemCapability.Global.I18n 3099 * @crossplatform 3100 * @atomicservice 3101 * @since arkts {'1.1':'12','1.2':'20'} 3102 * @arkts 1.1&1.2 3103 */ 3104 getOffset(date?: number): number; 3105 3106 /** 3107 * Get available TimeZone ID list. 3108 * 3109 * @returns { Array<string> } a string array represents the available TimeZone ID list. 3110 * @syscap SystemCapability.Global.I18n 3111 * @since 9 3112 */ 3113 /** 3114 * Get available TimeZone ID list. 3115 * 3116 * @returns { Array<string> } a string array represents the available TimeZone ID list. 3117 * @syscap SystemCapability.Global.I18n 3118 * @crossplatform 3119 * @since 10 3120 */ 3121 /** 3122 * Obtains the list of time zone IDs supported by the system. 3123 * 3124 * @returns { Array<string> } List of time zone IDs supported by the system. 3125 * @syscap SystemCapability.Global.I18n 3126 * @crossplatform 3127 * @atomicservice 3128 * @since arkts {'1.1':'12','1.2':'20'} 3129 * @arkts 1.1&1.2 3130 */ 3131 static getAvailableIDs(): Array<string>; 3132 3133 /** 3134 * Get available Zone City ID list. 3135 * 3136 * @returns { Array<string> } a string array represents the available Zone City ID list. 3137 * @syscap SystemCapability.Global.I18n 3138 * @since 9 3139 */ 3140 /** 3141 * Obtains the list of time zone city IDs supported by the system. 3142 * 3143 * @returns { Array<string> } List of time zone city IDs supported by the system. 3144 * @syscap SystemCapability.Global.I18n 3145 * @atomicservice 3146 * @since arkts {'1.1':'12','1.2':'20'} 3147 * @arkts 1.1&1.2 3148 */ 3149 static getAvailableZoneCityIDs(): Array<string>; 3150 3151 /** 3152 * Get City display name in a certain locale. 3153 * 3154 * @param { string } cityID - Zone City ID. 3155 * @param { string } locale - locale used to display city name. 3156 * @returns { string } a string represents the display name of City in locale. 3157 * @syscap SystemCapability.Global.I18n 3158 * @since 9 3159 */ 3160 /** 3161 * Obtains time zone city display name in the specified language. 3162 * 3163 * @param { string } cityID - Time zone city ID. 3164 * @param { string } locale - System locale, which consists of the language, script, and country/region. 3165 * @returns { string } Time zone city display name in the specified language. 3166 * @syscap SystemCapability.Global.I18n 3167 * @atomicservice 3168 * @since arkts {'1.1':'12','1.2':'20'} 3169 * @arkts 1.1&1.2 3170 */ 3171 static getCityDisplayName(cityID: string, locale: string): string; 3172 3173 /** 3174 * Get TimeZone Object from city ID. 3175 * 3176 * @param { string } cityID - Zone City ID. 3177 * @returns { TimeZone } a TimeZone Object from city ID. 3178 * @syscap SystemCapability.Global.I18n 3179 * @since 9 3180 */ 3181 /** 3182 * Creates a TimeZone object corresponding to the specified time zone city. 3183 * 3184 * @param { string } cityID - Time zone city ID. The value must be a time zone city ID supported by the system. 3185 * @returns { TimeZone } TimeZone object corresponding to the specified time zone city ID. 3186 * @syscap SystemCapability.Global.I18n 3187 * @atomicservice 3188 * @since arkts {'1.1':'12','1.2':'20'} 3189 * @arkts 1.1&1.2 3190 */ 3191 static getTimezoneFromCity(cityID: string): TimeZone; 3192 3193 /** 3194 * Get the possible time zones from the specified longitude and latitude. 3195 * 3196 * @param { number } longitude value 3197 * @param { number } latitude value 3198 * @returns { Array<TimeZone> } Returns a TimeZone array from the specified longitude and latitude. 3199 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 3200 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 3201 * @syscap SystemCapability.Global.I18n 3202 * @since 10 3203 */ 3204 /** 3205 * Creates an array of TimeZone objects corresponding to the specified location. 3206 * 3207 * @param { number } longitude - Longitude. The value range is [-180, 179.9). A positive value is used for east 3208 * longitude and a negative value is used for west longitude. 3209 * @param { number } latitude - Latitude. The value range is [-90, 89.9). A positive value is used for north 3210 * latitude and a negative value is used for south latitude. 3211 * @returns { Array<TimeZone> } TimeZone objects corresponding to the specified location. 3212 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 3213 * 2.Incorrect parameter types. 3214 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 3215 * @static 3216 * @syscap SystemCapability.Global.I18n 3217 * @atomicservice 3218 * @since arkts {'1.1':'12','1.2':'20'} 3219 * @arkts 1.1&1.2 3220 */ 3221 static getTimezonesByLocation(longitude: number, latitude: number): Array<TimeZone>; 3222 3223 /** 3224 * Get the zone rules object corresponds to the timezone objects. 3225 * 3226 * @returns { ZoneRules } Returns a ZoneRuels object which defines timezone offset changing rule. 3227 * @syscap SystemCapability.Global.I18n 3228 * @atomicservice 3229 * @since 20 3230 */ 3231 public getZoneRules(): ZoneRules; 3232 } 3233 3234 /** 3235 * Provides the API for obtaining timezone offset changing rules information. 3236 * 3237 * @syscap SystemCapability.Global.I18n 3238 * @atomicservice 3239 * @since 20 3240 */ 3241 export class ZoneRules { 3242 /** 3243 * Get the next timezone offset transition after date. 3244 * 3245 * @param { number } [ date ] - Indicates milliseconds. 3246 * @returns { ZoneOffsetTransition } Returns a timezone offset transition after date. 3247 * @syscap SystemCapability.Global.I18n 3248 * @atomicservice 3249 * @since 20 3250 */ 3251 public nextTransition(date?: number): ZoneOffsetTransition; 3252 } 3253 3254 /** 3255 * Provides the API for obtaining a timezone transition information. 3256 * 3257 * @syscap SystemCapability.Global.I18n 3258 * @atomicservice 3259 * @since 20 3260 */ 3261 export class ZoneOffsetTransition { 3262 /** 3263 * Obtains the timestamp of the change in the time zone offset. 3264 * 3265 * @returns { number } Timestamp of the change in the time zone offset. 3266 * @syscap SystemCapability.Global.I18n 3267 * @atomicservice 3268 * @since 20 3269 */ 3270 public getMilliseconds(): number; 3271 3272 /** 3273 * Get the offset after time zone offset trasition. 3274 * 3275 * @returns { number } Returns the offset after time zone offset trasition. 3276 * @syscap SystemCapability.Global.I18n 3277 * @atomicservice 3278 * @since 20 3279 */ 3280 public getOffsetAfter(): number; 3281 3282 /** 3283 * Get the offset before time zone offset trasition. 3284 * 3285 * @returns { number } Returns the offset before time zone offset trasition. 3286 * @syscap SystemCapability.Global.I18n 3287 * @atomicservice 3288 * @since 20 3289 */ 3290 public getOffsetBefore(): number; 3291 } 3292 3293 /** 3294 * Provides the API for transliterate text from one format to another. 3295 * 3296 * @syscap SystemCapability.Global.I18n 3297 * @since 9 3298 */ 3299 /** 3300 * Provides the API for transliterate text from one format to another. 3301 * 3302 * @syscap SystemCapability.Global.I18n 3303 * @atomicservice 3304 * @since arkts {'1.1':'12','1.2':'20'} 3305 * @arkts 1.1&1.2 3306 */ 3307 export class Transliterator { 3308 /** 3309 * Get a string array of all available transliterator ids. 3310 * 3311 * @returns { string[] } a string array of all available transliterator ids. 3312 * @syscap SystemCapability.Global.I18n 3313 * @since 9 3314 */ 3315 /** 3316 * Obtains a list of IDs supported by the Transliterator object. 3317 * 3318 * @returns { string[] } List of IDs supported by the Transliterator object. 3319 * @syscap SystemCapability.Global.I18n 3320 * @atomicservice 3321 * @since arkts {'1.1':'12','1.2':'20'} 3322 * @arkts 1.1&1.2 3323 */ 3324 static getAvailableIDs(): string[]; 3325 3326 /** 3327 * Get a Transliterator that is specified by id name. 3328 * 3329 * @param { string } id - specified the type of Transliterator. id is formed by source and dest. Transliterator will transliterate 3330 * the input string from source format to the dest format. For example, a Simplified Chinese to Latn 3331 * Transliterator will transform the text written in Chinese to Latn characters. 3332 * @returns { Transliterator } Transliterator that is specified by id name. 3333 * @syscap SystemCapability.Global.I18n 3334 * @since 9 3335 */ 3336 /** 3337 * Creates a Transliterator object based on the specified ID. 3338 * 3339 * @param { string } id - ID supported by the Transliterator object. 3340 * @returns { Transliterator } Transliterator object. 3341 * @syscap SystemCapability.Global.I18n 3342 * @atomicservice 3343 * @since arkts {'1.1':'12','1.2':'20'} 3344 * @arkts 1.1&1.2 3345 */ 3346 static getInstance(id: string): Transliterator; 3347 3348 /** 3349 * Transform the input text. 3350 * 3351 * @param { string } text - text to be transliterated. 3352 * @returns { string } the output text that is transliterated from source format to the dest format. 3353 * @syscap SystemCapability.Global.I18n 3354 * @since 9 3355 */ 3356 /** 3357 * Converts the input text from the source format to the target format. 3358 * 3359 * @param { string } text - Input text. 3360 * @returns { string } Text after conversion. 3361 * @syscap SystemCapability.Global.I18n 3362 * @atomicservice 3363 * @since arkts {'1.1':'12','1.2':'20'} 3364 * @arkts 1.1&1.2 3365 */ 3366 transform(text: string): string; 3367 } 3368 3369 /** 3370 * Enumerates the Normalizer modes. 3371 * 3372 * @enum { number } 3373 * @syscap SystemCapability.Global.I18n 3374 * @since 10 3375 */ 3376 /** 3377 * Enumerates text normalization modes. 3378 * 3379 * @enum { number } 3380 * @syscap SystemCapability.Global.I18n 3381 * @atomicservice 3382 * @since arkts {'1.1':'12','1.2':'20'} 3383 * @arkts 1.1&1.2 3384 */ 3385 export enum NormalizerMode { 3386 /** 3387 * Normalization form C, characters are decomposed and then re-composed by canonical equivalence 3388 * 3389 * @syscap SystemCapability.Global.I18n 3390 * @since 10 3391 */ 3392 /** 3393 * Normalization form C, characters are decomposed and then re-composed by canonical equivalence 3394 * 3395 * @syscap SystemCapability.Global.I18n 3396 * @atomicservice 3397 * @since arkts {'1.1':'12','1.2':'20'} 3398 * @arkts 1.1&1.2 3399 */ 3400 NFC = 1, 3401 /** 3402 * Normalization form D, characters are decomposed by canonical equivalence 3403 * 3404 * @syscap SystemCapability.Global.I18n 3405 * @since 10 3406 */ 3407 /** 3408 * Normalization form D, characters are decomposed by canonical equivalence 3409 * 3410 * @syscap SystemCapability.Global.I18n 3411 * @atomicservice 3412 * @since arkts {'1.1':'12','1.2':'20'} 3413 * @arkts 1.1&1.2 3414 */ 3415 NFD = 2, 3416 /** 3417 * Normalization form KC, characters are decomposed by compatibility, then re-composed by canonical equivalence 3418 * 3419 * @syscap SystemCapability.Global.I18n 3420 * @since 10 3421 */ 3422 /** 3423 * Normalization form KC, characters are decomposed by compatibility, then re-composed by canonical equivalence 3424 * 3425 * @syscap SystemCapability.Global.I18n 3426 * @atomicservice 3427 * @since arkts {'1.1':'12','1.2':'20'} 3428 * @arkts 1.1&1.2 3429 */ 3430 NFKC = 3, 3431 /** 3432 * Normalization form KD, characters are decomposed by compatibility 3433 * 3434 * @syscap SystemCapability.Global.I18n 3435 * @since 10 3436 */ 3437 /** 3438 * Normalization form KD, characters are decomposed by compatibility 3439 * 3440 * @syscap SystemCapability.Global.I18n 3441 * @atomicservice 3442 * @since arkts {'1.1':'12','1.2':'20'} 3443 * @arkts 1.1&1.2 3444 */ 3445 NFKD = 4 3446 } 3447 3448 /** 3449 * Provides the API for text encoding normalization. 3450 * 3451 * @syscap SystemCapability.Global.I18n 3452 * @since 10 3453 */ 3454 /** 3455 * Provides the API for text encoding normalization. 3456 * 3457 * @syscap SystemCapability.Global.I18n 3458 * @atomicservice 3459 * @since arkts {'1.1':'12','1.2':'20'} 3460 * @arkts 1.1&1.2 3461 */ 3462 export class Normalizer { 3463 /** 3464 * Get a Normalizer that is specified by normalize mode. 3465 * 3466 * @param { NormalizerMode } mode - specified the mode of Normalizer. It must be a valid mode. 3467 * @returns { Normalizer } Transliterator that is specified by id name. 3468 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 3469 * @syscap SystemCapability.Global.I18n 3470 * @since 10 3471 */ 3472 /** 3473 * Obtains a Normalizer object. 3474 * 3475 * @param { NormalizerMode } mode - Text normalization mode. 3476 * @returns { Normalizer } Normalizer object for text normalization. 3477 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 3478 * 2.Incorrect parameter types. 3479 * @syscap SystemCapability.Global.I18n 3480 * @atomicservice 3481 * @since arkts {'1.1':'12','1.2':'20'} 3482 * @arkts 1.1&1.2 3483 */ 3484 static getInstance(mode: NormalizerMode): Normalizer; 3485 3486 /** 3487 * Get a normalized string of specified mode. 3488 * 3489 * @param { string } text - text to normalized. 3490 * @returns { string } a normalized string from source. 3491 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 3492 * @syscap SystemCapability.Global.I18n 3493 * @since 10 3494 */ 3495 /** 3496 * Normalizes input strings. 3497 * 3498 * @param { string } text - Input strings. 3499 * @returns { string } Normalized strings. 3500 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 3501 * 2.Incorrect parameter types. 3502 * @syscap SystemCapability.Global.I18n 3503 * @atomicservice 3504 * @since arkts {'1.1':'12','1.2':'20'} 3505 * @arkts 1.1&1.2 3506 */ 3507 normalize(text: string): string; 3508 } 3509 3510 /** 3511 * Represents the language or country/region suggestion type. 3512 * 3513 * @enum { number } 3514 * @syscap SystemCapability.Global.I18n 3515 * @systemapi Hide this for inner system use. 3516 * @since arkts {'1.1':'10','1.2':'20'} 3517 * @arkts 1.1&1.2 3518 */ 3519 export enum SuggestionType { 3520 /** 3521 * Not a recommended language or country/region. 3522 * 3523 * @syscap SystemCapability.Global.I18n 3524 * @systemapi Hide this for inner system use. 3525 * @since arkts {'1.1':'10','1.2':'20'} 3526 * @arkts 1.1&1.2 3527 */ 3528 SUGGESTION_TYPE_NONE = 0, 3529 /** 3530 * Country/region recommended by the system language or language recommended by the system country/region. 3531 * 3532 * @syscap SystemCapability.Global.I18n 3533 * @systemapi Hide this for inner system use. 3534 * @since arkts {'1.1':'10','1.2':'20'} 3535 * @arkts 1.1&1.2 3536 */ 3537 SUGGESTION_TYPE_RELATED = 1, 3538 /** 3539 * Language recommended by the country/region of the SIM card. 3540 * 3541 * @syscap SystemCapability.Global.I18n 3542 * @systemapi Hide this for inner system use. 3543 * @since arkts {'1.1':'10','1.2':'20'} 3544 * @arkts 1.1&1.2 3545 */ 3546 SUGGESTION_TYPE_SIM = 2, 3547 } 3548 3549 /** 3550 * Represents the language or country/region sorting option. 3551 * 3552 * @interface SortOptions 3553 * @syscap SystemCapability.Global.I18n 3554 * @systemapi Hide this for inner system use. 3555 * @since arkts {'1.1':'10','1.2':'20'} 3556 * @arkts 1.1&1.2 3557 */ 3558 export interface SortOptions { 3559 /** 3560 * Locale information, which consists of the language, script, and country/region, for example, "zh-Hans-CN". 3561 * The default value is the current system locale. 3562 * 3563 * @type { ?string } 3564 * @syscap SystemCapability.Global.I18n 3565 * @systemapi Hide this for inner system use. 3566 * @since arkts {'1.1':'10','1.2':'20'} 3567 * @arkts 1.1&1.2 3568 */ 3569 locale?: string; 3570 3571 /** 3572 * Whether to use the local name for sorting. The value "true" means to use the local name for sorting, and the 3573 * value "false" means the opposite. If getLanguageInfoArray is called, the default value of isUseLocalName is 3574 * true. If getRegionInfoArray is called, the default value of isUseLocalName is false. 3575 * 3576 * @type { ?boolean } 3577 * @syscap SystemCapability.Global.I18n 3578 * @systemapi Hide this for inner system use. 3579 * @since arkts {'1.1':'10','1.2':'20'} 3580 * @arkts 1.1&1.2 3581 */ 3582 isUseLocalName?: boolean; 3583 3584 /** 3585 * Whether to move the recommended language or country/region to the top in the sorting result. The value "true" 3586 * means to move the recommended language or country/region to the top, and the value "false" means the opposite. 3587 * The default value is true. 3588 * 3589 * @type { ?boolean } 3590 * @syscap SystemCapability.Global.I18n 3591 * @systemapi Hide this for inner system use. 3592 * @since arkts {'1.1':'10','1.2':'20'} 3593 * @arkts 1.1&1.2 3594 */ 3595 isSuggestedFirst?: boolean; 3596 } 3597 3598 /** 3599 * Represents the locale information, which consists of the language, script, and country/region. 3600 * 3601 * @interface LocaleItem 3602 * @syscap SystemCapability.Global.I18n 3603 * @systemapi Hide this for inner system use. 3604 * @since arkts {'1.1':'10','1.2':'20'} 3605 * @arkts 1.1&1.2 3606 */ 3607 export interface LocaleItem { 3608 /** 3609 * Language code or country/region code, for example, "zh" or "CN". 3610 * 3611 * @type { string } 3612 * @syscap SystemCapability.Global.I18n 3613 * @systemapi Hide this for inner system use. 3614 * @since arkts {'1.1':'10','1.2':'20'} 3615 * @arkts 1.1&1.2 3616 */ 3617 id: string; 3618 3619 /** 3620 * Language or country/region suggestion type. 3621 * 3622 * @type { SuggestionType } 3623 * @syscap SystemCapability.Global.I18n 3624 * @systemapi Hide this for inner system use. 3625 * @since arkts {'1.1':'10','1.2':'20'} 3626 * @arkts 1.1&1.2 3627 */ 3628 suggestionType: SuggestionType; 3629 3630 /** 3631 * Representation of ID in the specified locale in SystemLocaleManager. 3632 * 3633 * @type { string } 3634 * @syscap SystemCapability.Global.I18n 3635 * @systemapi Hide this for inner system use. 3636 * @since arkts {'1.1':'10','1.2':'20'} 3637 * @arkts 1.1&1.2 3638 */ 3639 displayName: string; 3640 3641 /** 3642 * Local name of the ID. 3643 * 3644 * @type { ?string } 3645 * @syscap SystemCapability.Global.I18n 3646 * @systemapi Hide this for inner system use. 3647 * @since arkts {'1.1':'10','1.2':'20'} 3648 * @arkts 1.1&1.2 3649 */ 3650 localName?: string; 3651 } 3652 3653 /** 3654 * Represents a time zone and city combination item. 3655 * 3656 * @interface TimeZoneCityItem 3657 * @syscap SystemCapability.Global.I18n 3658 * @systemapi Hide this for inner system use. 3659 * @since arkts {'1.1':'10','1.2':'20'} 3660 * @arkts 1.1&1.2 3661 */ 3662 export interface TimeZoneCityItem { 3663 /** 3664 * Time zone ID, for example, "Asia/Shanghai". 3665 * 3666 * @type { string } 3667 * @syscap SystemCapability.Global.I18n 3668 * @systemapi Hide this for inner system use. 3669 * @since arkts {'1.1':'10','1.2':'20'} 3670 * @arkts 1.1&1.2 3671 */ 3672 zoneId: string; 3673 3674 /** 3675 * City ID, for example, "Shanghai". 3676 * 3677 * @type { string } 3678 * @syscap SystemCapability.Global.I18n 3679 * @systemapi Hide this for inner system use. 3680 * @since arkts {'1.1':'10','1.2':'20'} 3681 * @arkts 1.1&1.2 3682 */ 3683 cityId: string; 3684 3685 /** 3686 * City display name in the system locale. 3687 * 3688 * @type { string } 3689 * @syscap SystemCapability.Global.I18n 3690 * @systemapi Hide this for inner system use. 3691 * @since arkts {'1.1':'10','1.2':'20'} 3692 * @arkts 1.1&1.2 3693 */ 3694 cityDisplayName: string; 3695 3696 /** 3697 * Offset of the time zone ID. 3698 * 3699 * @type { number } 3700 * @syscap SystemCapability.Global.I18n 3701 * @systemapi Hide this for inner system use. 3702 * @since arkts {'1.1':'10','1.2':'20'} 3703 * @arkts 1.1&1.2 3704 */ 3705 offset: number; 3706 3707 /** 3708 * Time zone display name in the system locale. 3709 * 3710 * @type { string } 3711 * @syscap SystemCapability.Global.I18n 3712 * @systemapi Hide this for inner system use. 3713 * @since arkts {'1.1':'10','1.2':'20'} 3714 * @arkts 1.1&1.2 3715 */ 3716 zoneDisplayName: string; 3717 3718 /** 3719 * Fixed offset of the time zone ID. 3720 * 3721 * @type { ?number } 3722 * @syscap SystemCapability.Global.I18n 3723 * @systemapi Hide this for inner system use. 3724 * @since arkts {'1.1':'10','1.2':'20'} 3725 * @arkts 1.1&1.2 3726 */ 3727 rawOffset?: number; 3728 } 3729 3730 /** 3731 * Provide some functions for settings and startup guide to select language or region. 3732 * 3733 * @syscap SystemCapability.Global.I18n 3734 * @systemapi Hide this for inner system use. 3735 * @since arkts {'1.1':'10','1.2':'20'} 3736 * @arkts 1.1&1.2 3737 */ 3738 export class SystemLocaleManager { 3739 /** 3740 * Creates a SystemLocaleManager object. 3741 * 3742 * @syscap SystemCapability.Global.I18n 3743 * @systemapi Hide this for inner system use. 3744 * @since arkts {'1.1':'10','1.2':'20'} 3745 * @arkts 1.1&1.2 3746 */ 3747 constructor(); 3748 3749 /** 3750 * Obtains sorted language array for setting or startup guide app. 3751 * 3752 * @param { Array<string> } languages - The languages whose name will be sorted and displayed. 3753 * @param { SortOptions } options - Sort options for locale item. 3754 * @returns { Array<LocaleItem> } Locale Informations sorted for specified options. 3755 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 3756 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 3757 * @syscap SystemCapability.Global.I18n 3758 * @systemapi Hide this for inner system use. 3759 * @since 10 3760 */ 3761 /** 3762 * Obtains the list of languages after sorting. 3763 * 3764 * @param { Array<string> } languages - Valid IDs of the languages to be sorted. 3765 * @param { SortOptions } options - Language sorting option. 3766 * @returns { Array<LocaleItem> } Language list after sorting. 3767 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 3768 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 3769 * 2.Incorrect parameter types. 3770 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 3771 * @syscap SystemCapability.Global.I18n 3772 * @systemapi Hide this for inner system use. 3773 * @since arkts {'1.1':'12','1.2':'20'} 3774 * @arkts 1.1&1.2 3775 */ 3776 getLanguageInfoArray(languages: Array<string>, options?: SortOptions): Array<LocaleItem>; 3777 3778 /** 3779 * Obtains sorted region array for setting or startup guide app. 3780 * 3781 * @param { Array<string> } regions - The regions whose name will be sorted and displayed. 3782 * @param { SortOptions } options - Sort options for locale item. 3783 * @returns { Array<LocaleItem> } Locale Informations sorted for specified options. 3784 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 3785 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 3786 * @syscap SystemCapability.Global.I18n 3787 * @systemapi Hide this for inner system use. 3788 * @since 10 3789 */ 3790 /** 3791 * Obtains the IDs of the countries or regions after sorting. 3792 * 3793 * @param { Array<string> } regions - Valid IDs of the countries or regions to be sorted. 3794 * @param { SortOptions } options - Country/region sorting option. By default, locale is the current system 3795 * locale, isUseLocalName is false, and isSuggestedFirst is true. 3796 * @returns { Array<LocaleItem> } IDs of the countries or regions after sorting. 3797 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 3798 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 3799 * 2.Incorrect parameter types. 3800 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 3801 * @syscap SystemCapability.Global.I18n 3802 * @systemapi Hide this for inner system use. 3803 * @since arkts {'1.1':'12','1.2':'20'} 3804 * @arkts 1.1&1.2 3805 */ 3806 getRegionInfoArray(regions: Array<string>, options?: SortOptions): Array<LocaleItem>; 3807 3808 /** 3809 * Obtains sorted time zone city info array for showing time zone list 3810 * 3811 * @returns { Array<TimeZoneCityItem> } Time zone city information sorted by city name. 3812 * @syscap SystemCapability.Global.I18n 3813 * @systemapi Hide this for inner system use. 3814 * @since 10 3815 */ 3816 /** 3817 * Obtains list of time zone city items after sorting. 3818 * 3819 * @returns { Array<TimeZoneCityItem> } List of time zone city items after sorting. 3820 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 3821 * @syscap SystemCapability.Global.I18n 3822 * @systemapi Hide this for inner system use. 3823 * @since arkts {'1.1':'12','1.2':'20'} 3824 * @arkts 1.1&1.2 3825 */ 3826 static getTimeZoneCityItemArray(): Array<TimeZoneCityItem>; 3827 } 3828 3829 /** 3830 * Provides the informations of one holiday. 3831 * 3832 * @interface HolidayInfoItem 3833 * @syscap SystemCapability.Global.I18n 3834 * @since 11 3835 */ 3836 /** 3837 * Represents the holiday information. 3838 * 3839 * @interface HolidayInfoItem 3840 * @syscap SystemCapability.Global.I18n 3841 * @atomicservice 3842 * @since arkts {'1.1':'12','1.2':'20'} 3843 * @arkts 1.1&1.2 3844 */ 3845 export interface HolidayInfoItem { 3846 /** 3847 * Holiday base name. 3848 * 3849 * @type { string } 3850 * @syscap SystemCapability.Global.I18n 3851 * @since 11 3852 */ 3853 /** 3854 * Holiday name. 3855 * 3856 * @type { string } 3857 * @syscap SystemCapability.Global.I18n 3858 * @atomicservice 3859 * @since arkts {'1.1':'12','1.2':'20'} 3860 * @arkts 1.1&1.2 3861 */ 3862 baseName: string; 3863 3864 /** 3865 * Holiday start year. 3866 * 3867 * @type { number } 3868 * @syscap SystemCapability.Global.I18n 3869 * @since 11 3870 */ 3871 /** 3872 * Year of the holiday. 3873 * 3874 * @type { number } 3875 * @syscap SystemCapability.Global.I18n 3876 * @atomicservice 3877 * @since arkts {'1.1':'12','1.2':'20'} 3878 * @arkts 1.1&1.2 3879 */ 3880 year: number; 3881 3882 /** 3883 * Holiday start month. 3884 * 3885 * @type { number } 3886 * @syscap SystemCapability.Global.I18n 3887 * @since 11 3888 */ 3889 /** 3890 * Month of the holiday. 3891 * 3892 * @type { number } 3893 * @syscap SystemCapability.Global.I18n 3894 * @atomicservice 3895 * @since arkts {'1.1':'12','1.2':'20'} 3896 * @arkts 1.1&1.2 3897 */ 3898 month: number; 3899 3900 /** 3901 * Holiday start day. 3902 * 3903 * @type { number } 3904 * @syscap SystemCapability.Global.I18n 3905 * @since 11 3906 */ 3907 /** 3908 * Day of the holiday. 3909 * 3910 * @type { number } 3911 * @syscap SystemCapability.Global.I18n 3912 * @atomicservice 3913 * @since arkts {'1.1':'12','1.2':'20'} 3914 * @arkts 1.1&1.2 3915 */ 3916 day: number; 3917 3918 /** 3919 * Holiday local name array. 3920 * 3921 * @type { ?Array<HolidayLocalName> } 3922 * @syscap SystemCapability.Global.I18n 3923 * @since 11 3924 */ 3925 /** 3926 * Local names of the holiday. 3927 * 3928 * @type { ?Array<HolidayLocalName> } 3929 * @syscap SystemCapability.Global.I18n 3930 * @atomicservice 3931 * @since arkts {'1.1':'12','1.2':'20'} 3932 * @arkts 1.1&1.2 3933 */ 3934 localNames?: Array<HolidayLocalName>; 3935 } 3936 3937 /** 3938 * Provides the informations holiday locale name. 3939 * 3940 * @interface HolidayLocalName 3941 * @syscap SystemCapability.Global.I18n 3942 * @since 11 3943 */ 3944 /** 3945 * Represents the name of a holiday in different languages. 3946 * 3947 * @interface HolidayLocalName 3948 * @syscap SystemCapability.Global.I18n 3949 * @atomicservice 3950 * @since arkts {'1.1':'12','1.2':'20'} 3951 * @arkts 1.1&1.2 3952 */ 3953 export interface HolidayLocalName { 3954 /** 3955 * Holiday locale name language id. 3956 * 3957 * @type { string } 3958 * @syscap SystemCapability.Global.I18n 3959 * @since 11 3960 */ 3961 /** 3962 * Language, for example, "ar", "en", or "tr". 3963 * 3964 * @type { string } 3965 * @syscap SystemCapability.Global.I18n 3966 * @atomicservice 3967 * @since arkts {'1.1':'12','1.2':'20'} 3968 * @arkts 1.1&1.2 3969 */ 3970 language: string; 3971 3972 /** 3973 * Holiday local name. 3974 * 3975 * @type { string } 3976 * @syscap SystemCapability.Global.I18n 3977 * @since 11 3978 */ 3979 /** 3980 * Local name of a holiday. For example, the Turkish name of Sacrifice Feast is Kurban Bayrami. 3981 * 3982 * @type { string } 3983 * @syscap SystemCapability.Global.I18n 3984 * @atomicservice 3985 * @since arkts {'1.1':'12','1.2':'20'} 3986 * @arkts 1.1&1.2 3987 */ 3988 name: string; 3989 } 3990 3991 /** 3992 * Provide some functions to manage holidays in a country or region. Partly follows the RFC2445 standard. 3993 * 3994 * @syscap SystemCapability.Global.I18n 3995 * @since 11 3996 */ 3997 /** 3998 * Provide some functions to manage holidays in a country or region. Partly follows the RFC2445 standard. 3999 * 4000 * @syscap SystemCapability.Global.I18n 4001 * @atomicservice 4002 * @since arkts {'1.1':'12','1.2':'20'} 4003 * @arkts 1.1&1.2 4004 */ 4005 export class HolidayManager { 4006 /** 4007 * A constructor used to create a HolidayManager object. 4008 * 4009 * @param { String } icsPath - the path of the iCalendar format file to create HolidayManager object. 4010 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 4011 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 4012 * @syscap SystemCapability.Global.I18n 4013 * @since 11 4014 */ 4015 /** 4016 * Creates a HolidayManager object for parsing holiday data. 4017 * 4018 * @param { String } icsPath - Path of the .ics file with the read permission granted for applications. 4019 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 4020 * 2.Incorrect parameter types. 4021 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 4022 * @syscap SystemCapability.Global.I18n 4023 * @atomicservice 4024 * @since arkts {'1.1':'12','1.2':'20'} 4025 * @arkts 1.1&1.2 4026 */ 4027 constructor(icsPath: String); 4028 4029 /** 4030 * Returns true if the given date is a holiday. If the date is not given, 4031 * the date object of current time is used. 4032 * 4033 * @param { Date } [date] - Date object whose attribute is desired. 4034 * @returns { boolean } whether the date is a holiday day. 4035 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 4036 * @syscap SystemCapability.Global.I18n 4037 * @since 11 4038 */ 4039 /** 4040 * Determines whether the specified date is a holiday. 4041 * 4042 * @param { Date } [date] - Date and time. Note: The month starts from 0. For example, 0 indicates January. 4043 * The default value is the current date. 4044 * @returns { boolean } true if the specified date is a holiday, and false otherwise. 4045 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 4046 * 2.Incorrect parameter types. 4047 * @syscap SystemCapability.Global.I18n 4048 * @atomicservice 4049 * @since arkts {'1.1':'12','1.2':'20'} 4050 * @arkts 1.1&1.2 4051 */ 4052 isHoliday(date?: Date): boolean; 4053 4054 /** 4055 * Obtains holiday info array for a specified year 4056 * 4057 * @param { number } [year] - specified holiday year. If the year is not given, 4058 * the current year is used. 4059 * @returns { Array<HolidayInfoItem> } holiday information array for one year. 4060 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 4061 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 4062 * @syscap SystemCapability.Global.I18n 4063 * @since 11 4064 */ 4065 /** 4066 * Obtains the holiday information list of the specified year. 4067 * 4068 * @param { number } [year] - Specified year, for example, 2023.<br>The default value is the current year. 4069 * @returns { Array<HolidayInfoItem> } Holiday information list. 4070 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 4071 * 2.Incorrect parameter types. 4072 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 4073 * @syscap SystemCapability.Global.I18n 4074 * @atomicservice 4075 * @since arkts {'1.1':'12','1.2':'20'} 4076 * @arkts 1.1&1.2 4077 */ 4078 getHolidayInfoItemArray(year?: number): Array<HolidayInfoItem>; 4079 } 4080 4081 /** 4082 * Provides the informations of one entity. 4083 * 4084 * @interface EntityInfoItem 4085 * @syscap SystemCapability.Global.I18n 4086 * @since 11 4087 */ 4088 /** 4089 * Defines a list of entities. 4090 * 4091 * @interface EntityInfoItem 4092 * @syscap SystemCapability.Global.I18n 4093 * @atomicservice 4094 * @since arkts {'1.1':'12','1.2':'20'} 4095 * @arkts 1.1&1.2 4096 */ 4097 export interface EntityInfoItem { 4098 /** 4099 * Entity begin position. 4100 * 4101 * @type { number } 4102 * @syscap SystemCapability.Global.I18n 4103 * @since 11 4104 */ 4105 /** 4106 * Start position of the entity in the input string. 4107 * 4108 * @type { number } 4109 * @syscap SystemCapability.Global.I18n 4110 * @atomicservice 4111 * @since arkts {'1.1':'12','1.2':'20'} 4112 * @arkts 1.1&1.2 4113 */ 4114 begin: number; 4115 4116 /** 4117 * Entity end position. 4118 * 4119 * @type { number } 4120 * @syscap SystemCapability.Global.I18n 4121 * @since 11 4122 */ 4123 /** 4124 * End position of the entity the input string. 4125 * 4126 * @type { number } 4127 * @syscap SystemCapability.Global.I18n 4128 * @atomicservice 4129 * @since arkts {'1.1':'12','1.2':'20'} 4130 * @arkts 1.1&1.2 4131 */ 4132 end: number; 4133 4134 /** 4135 * Entity type. Field values such as phone_number, date 4136 * 4137 * @type { string } 4138 * @syscap SystemCapability.Global.I18n 4139 * @since 11 4140 */ 4141 /** 4142 * Entity type. The value can be "phone_number" or "date". "phone_number" indicates that the entity is a phone 4143 * number, and "date" indicates that the entity is a date. 4144 * 4145 * @type { string } 4146 * @syscap SystemCapability.Global.I18n 4147 * @atomicservice 4148 * @since arkts {'1.1':'12','1.2':'20'} 4149 * @arkts 1.1&1.2 4150 */ 4151 type: string; 4152 } 4153 4154 /** 4155 * Provide some functions to find named entity in text. 4156 * 4157 * @syscap SystemCapability.Global.I18n 4158 * @since 11 4159 */ 4160 /** 4161 * Provide some functions to find named entity in text. 4162 * 4163 * @syscap SystemCapability.Global.I18n 4164 * @atomicservice 4165 * @since arkts {'1.1':'12','1.2':'20'} 4166 * @arkts 1.1&1.2 4167 */ 4168 export class EntityRecognizer { 4169 /** 4170 * A constructor used to create a EntityRecognizer object. 4171 * 4172 * @param { string } [locale] - specified the locale. Use current app locale by default. It must be a valid locale. 4173 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 4174 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 4175 * @syscap SystemCapability.Global.I18n 4176 * @since 11 4177 */ 4178 /** 4179 * Creates an entityRecognizer object. This object is used to recognize entities in the text for the specified 4180 * locale. 4181 * 4182 * @param { string } [locale] - Locale ID, which consists of the language, script, and country/region, for example, 4183 * "zh-Hans-CN". The default value is the current system locale. 4184 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 4185 * 2.Incorrect parameter types. 4186 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 4187 * @syscap SystemCapability.Global.I18n 4188 * @atomicservice 4189 * @since arkts {'1.1':'12','1.2':'20'} 4190 * @arkts 1.1&1.2 4191 */ 4192 constructor(locale?: string); 4193 4194 /** 4195 * Obtains holiday info array for a specified text 4196 * 4197 * @param { string } text - the text to find entities. 4198 * @returns { Array<EntityInfoItem> } entity information array found. 4199 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 4200 * @syscap SystemCapability.Global.I18n 4201 * @since 11 4202 */ 4203 /** 4204 * Obtains entity information in the text object. 4205 * 4206 * @param { string } text - text object. 4207 * @returns { Array<EntityInfoItem> } List of entities in the text. 4208 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 4209 * 2.Incorrect parameter types. 4210 * @syscap SystemCapability.Global.I18n 4211 * @atomicservice 4212 * @since arkts {'1.1':'12','1.2':'20'} 4213 * @arkts 1.1&1.2 4214 */ 4215 findEntityInfo(text: string): Array<EntityInfoItem>; 4216 } 4217 4218 /** 4219 * Obtains a SimpleDateTimeFormat object based on the specified pattern string. For details about the display 4220 * differences between the objects obtained by this API and getSimpleDateTimeFormatBySkeleton, 4221 * see SimpleDateTimeFormat. 4222 * 4223 * @param { string } pattern - Valid pattern. For details about the supported characters and their meanings, see 4224 * [Date Field Symbol Table](https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table). 4225 * This parameter also supports custom text enclosed in single quotation marks (''). 4226 * @param { intl.Locale } [locale] - Locale object. The default value is the current system locale. 4227 * @returns { SimpleDateTimeFormat } SimpleDateTimeFormat object. 4228 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 4229 * @syscap SystemCapability.Global.I18n 4230 * @atomicservice 4231 * @since 18 4232 * @deprecated since 20 4233 * @useinstead getSimpleDateTimeFormatByPattern 4234 */ 4235 export function getSimpleDateTimeFormatByPattern(pattern: string, locale?: intl.Locale): SimpleDateTimeFormat; 4236 4237 /** 4238 * Obtains a SimpleDateTimeFormat object based on the specified pattern string. For details about the display 4239 * differences between the objects obtained by this API and getSimpleDateTimeFormatBySkeleton, 4240 * see SimpleDateTimeFormat. 4241 * 4242 * @param { string } pattern - Valid pattern. For details about the supported characters and their meanings, see 4243 * [Date Field Symbol Table](https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table). 4244 * This parameter also supports custom text enclosed in single quotation marks (''). 4245 * @param { Intl.Locale } [locale] - Locale object. The default value is the current system locale. 4246 * @returns { SimpleDateTimeFormat } SimpleDateTimeFormat object. 4247 * @throws { BusinessError } 8900001 - Invalid parameter. Possible causes: Parameter verification failed. 4248 * @syscap SystemCapability.Global.I18n 4249 * @atomicservice 4250 * @since 20 4251 */ 4252 export function getSimpleDateTimeFormatByPattern(pattern: string, locale?: Intl.Locale): SimpleDateTimeFormat; 4253 4254 /** 4255 * Obtains a SimpleDateTimeFormat object based on the specified skeleton. For details about the display differences 4256 * between the objects obtained by this API and getSimpleDateTimeFormatByPattern, see SimpleDateTimeFormat. 4257 * 4258 * @param { string } skeleton - Valid skeleton. For details about the supported characters and their meanings, see 4259 * [Date Field Symbol Table](https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table). 4260 * This parameter does not support custom text. 4261 * @param { intl.Locale } [locale] - Locale object. The default value is the current system locale. 4262 * @returns { SimpleDateTimeFormat } SimpleDateTimeFormat object. 4263 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 4264 * @syscap SystemCapability.Global.I18n 4265 * @atomicservice 4266 * @since 18 4267 * @deprecated since 20 4268 * @useinstead getSimpleDateTimeFormatBySkeleton 4269 */ 4270 export function getSimpleDateTimeFormatBySkeleton(skeleton: string, locale?: intl.Locale): SimpleDateTimeFormat; 4271 4272 /** 4273 * Obtains a SimpleDateTimeFormat object based on the specified skeleton. For details about the display differences 4274 * between the objects obtained by this API and getSimpleDateTimeFormatByPattern, see SimpleDateTimeFormat. 4275 * 4276 * @param { string } skeleton - Valid skeleton. For details about the supported characters and their meanings, see 4277 * [Date Field Symbol Table](https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table). 4278 * This parameter does not support custom text. 4279 * @param { Intl.Locale } [locale] - Locale object. The default value is the current system locale. 4280 * @returns { SimpleDateTimeFormat } SimpleDateTimeFormat object. 4281 * @throws { BusinessError } 8900001 - Invalid parameter. Possible causes: Parameter verification failed. 4282 * @syscap SystemCapability.Global.I18n 4283 * @atomicservice 4284 * @since 20 4285 */ 4286 export function getSimpleDateTimeFormatBySkeleton(skeleton: string, locale?: Intl.Locale): SimpleDateTimeFormat; 4287 4288 /** 4289 * Provide a simple date time formatting interface. 4290 * 4291 * @syscap SystemCapability.Global.I18n 4292 * @atomicservice 4293 * @since arkts {'1.1':'18','1.2':'20'} 4294 * @arkts 1.1&1.2 4295 */ 4296 export class SimpleDateTimeFormat { 4297 /** 4298 * Formats the date and time. 4299 * 4300 * @param { Date } date - Date and time. Note: The month starts from 0. For example, 0 indicates January. 4301 * @returns { string } A string containing the formatted date and time. 4302 * @syscap SystemCapability.Global.I18n 4303 * @atomicservice 4304 * @since arkts {'1.1':'18','1.2':'20'} 4305 * @arkts 1.1&1.2 4306 */ 4307 format(date: Date): string; 4308 } 4309 4310 /** 4311 * Obtains a SimpleNumberFormat object based on the specified skeleton. 4312 * 4313 * @param { string } skeleton - Valid skeleton. For details about the supported characters and their meanings, see 4314 * [Number Skeletons](https://unicode-org.github.io/icu/userguide/format_parse/numbers/skeletons.html#number-skeletons). 4315 * @param { intl.Locale } [locale] - Locale object. The default value is the current system locale. 4316 * @returns { SimpleNumberFormat } SimpleNumberFormat object. 4317 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 4318 * @syscap SystemCapability.Global.I18n 4319 * @crossplatform 4320 * @atomicservice 4321 * @since 18 4322 * @deprecated since 20 4323 * @useinstead getSimpleNumberFormatBySkeleton 4324 */ 4325 export function getSimpleNumberFormatBySkeleton(skeleton: string, locale?: intl.Locale): SimpleNumberFormat; 4326 4327 /** 4328 * Obtains a SimpleNumberFormat object based on the specified skeleton. 4329 * 4330 * @param { string } skeleton - Valid skeleton. For details about the supported characters and their meanings, see 4331 * [Number Skeletons](https://unicode-org.github.io/icu/userguide/format_parse/numbers/skeletons.html#number-skeletons). 4332 * @param { Intl.Locale } [locale] - Locale object. The default value is the current system locale. 4333 * @returns { SimpleNumberFormat } SimpleNumberFormat object. 4334 * @throws { BusinessError } 8900001 - Invalid parameter. Possible causes: Parameter verification failed. 4335 * @syscap SystemCapability.Global.I18n 4336 * @crossplatform 4337 * @atomicservice 4338 * @since 20 4339 */ 4340 export function getSimpleNumberFormatBySkeleton(skeleton: string, locale?: Intl.Locale): SimpleNumberFormat; 4341 4342 /** 4343 * Provide a simple number formatting interface. 4344 * 4345 * @syscap SystemCapability.Global.I18n 4346 * @atomicservice 4347 * @since arkts {'1.1':'18','1.2':'20'} 4348 * @arkts 1.1&1.2 4349 */ 4350 export class SimpleNumberFormat { 4351 /** 4352 * Formats a number. 4353 * 4354 * @param { number } value - Number to be formatted. 4355 * @returns { string } Formatted number. 4356 * @syscap SystemCapability.Global.I18n 4357 * @atomicservice 4358 * @since arkts {'1.1':'18','1.2':'20'} 4359 * @arkts 1.1&1.2 4360 */ 4361 format(value: number): string; 4362 } 4363 4364 /** 4365 * Provide a number formatting interface which could format number to StyleString. 4366 * 4367 * @syscap SystemCapability.Global.I18n 4368 * @atomicservice 4369 * @since 18 4370 */ 4371 export class StyledNumberFormat { 4372 /** 4373 * Creates a NumberFormat object for rich text display. 4374 * 4375 * @param { intl.NumberFormat | SimpleNumberFormat } numberFormat - NumberFormat object. 4376 * @param { StyledNumberFormatOptions } [ options ] - Configuration options of the NumberFormat object. 4377 * The default value is the default text style. 4378 * @syscap SystemCapability.Global.I18n 4379 * @atomicservice 4380 * @since 18 4381 * @deprecated since 20 4382 * @useinstead constructor 4383 */ 4384 constructor(numberFormat: intl.NumberFormat | SimpleNumberFormat, options?: StyledNumberFormatOptions); 4385 4386 /** 4387 * A constructor used to create a StyledNumberFormat object. 4388 * 4389 * @param { Intl.NumberFormat | SimpleNumberFormat } numberFormat - Indicates the number format object that used to format number. 4390 * @param { StyledNumberFormatOptions } [ options ] - Indicates the options used to format the number. 4391 * @syscap SystemCapability.Global.I18n 4392 * @atomicservice 4393 * @since 20 4394 */ 4395 constructor(numberFormat: Intl.NumberFormat | SimpleNumberFormat, options?: StyledNumberFormatOptions); 4396 4397 4398 /** 4399 * Formats a number as a rich text object. 4400 * 4401 * @param { number } value - Number to be formatted. 4402 * @returns { StyledString } Rich text object after formatting. 4403 * @syscap SystemCapability.Global.I18n 4404 * @atomicservice 4405 * @since 18 4406 */ 4407 format(value: number): StyledString; 4408 } 4409 4410 /** 4411 * Represents optional configuration items for the NumberFormat object. 4412 * 4413 * @interface StyledNumberFormatOptions 4414 * @syscap SystemCapability.Global.I18n 4415 * @atomicservice 4416 * @since 18 4417 */ 4418 export interface StyledNumberFormatOptions { 4419 /** 4420 * Text style for the integer part. The default value is the default text style. 4421 * 4422 * @type { ?TextStyle } 4423 * @syscap SystemCapability.Global.I18n 4424 * @atomicservice 4425 * @since 18 4426 */ 4427 integer?: TextStyle; 4428 4429 /** 4430 * Text style for the decimal point. The default value is the default text style. 4431 * 4432 * @type { ?TextStyle } 4433 * @syscap SystemCapability.Global.I18n 4434 * @atomicservice 4435 * @since 18 4436 */ 4437 decimal?: TextStyle; 4438 4439 /** 4440 * Text style for the fraction part. The default value is the default text style. 4441 * 4442 * @type { ?TextStyle } 4443 * @syscap SystemCapability.Global.I18n 4444 * @atomicservice 4445 * @since 18 4446 */ 4447 fraction?: TextStyle; 4448 4449 /** 4450 * Text style for the unit. The default value is the default text style. 4451 * 4452 * @type { ?TextStyle } 4453 * @syscap SystemCapability.Global.I18n 4454 * @atomicservice 4455 * @since 18 4456 */ 4457 unit?: TextStyle; 4458 } 4459} 4460export default i18n; 4461