1/* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/** 17 * @file 18 * @kit LocalizationKit 19 */ 20 21import { BusinessError } from './@ohos.base'; 22 23/** 24 * Provides international settings related APIs. 25 * 26 * @namespace i18n 27 * @syscap SystemCapability.Global.I18n 28 * @since 7 29 */ 30/** 31 * Provides international settings related APIs. 32 * 33 * @namespace i18n 34 * @syscap SystemCapability.Global.I18n 35 * @crossplatform 36 * @form 37 * @atomicservice 38 * @since 11 39 */ 40declare namespace i18n { 41 /** 42 * Obtains the country or region name localized for display on a given locale. 43 * 44 * @param { string } country - The locale whose country or region name will be displayed. 45 * @param { string } locale - The locale used to display the country or region. 46 * @param { boolean } [sentenceCase] - Specifies whether the country or region name is displayed in sentence case. 47 * @returns { string } the country or region name localized for display on a given locale. 48 * @syscap SystemCapability.Global.I18n 49 * @since 7 50 * @deprecated since 9 51 * @useinstead ohos.System.getDisplayCountry 52 */ 53 export function getDisplayCountry(country: string, locale: string, sentenceCase?: boolean): string; 54 55 /** 56 * Obtains the language name localized for display on a given locale. 57 * 58 * @param { string } language - The locale whose language name will be displayed. 59 * @param { string } locale - The locale used to display the language. 60 * @param { boolean } [sentenceCase] - Specifies whether the language name is displayed in sentence case. 61 * @returns { string } the language name localized for display on a given locale. 62 * @syscap SystemCapability.Global.I18n 63 * @since 7 64 * @deprecated since 9 65 * @useinstead ohos.System.getDisplayLanguage 66 */ 67 export function getDisplayLanguage(language: string, locale: string, sentenceCase?: boolean): string; 68 69 /** 70 * Obtains the language currently used by the system. 71 * 72 * @returns { string } the language currently used by the system. 73 * @syscap SystemCapability.Global.I18n 74 * @since 7 75 * @deprecated since 9 76 * @useinstead ohos.System.getSystemLanguage 77 */ 78 export function getSystemLanguage(): string; 79 80 /** 81 * Obtains the region currently used by the system. 82 * 83 * @returns { string } the region currently used by the system. 84 * @syscap SystemCapability.Global.I18n 85 * @since 7 86 * @deprecated since 9 87 * @useinstead ohos.System.getSystemRegion 88 */ 89 export function getSystemRegion(): string; 90 91 /** 92 * Obtains the locale currently used by the system. 93 * 94 * @returns { string } the locale currently used by the system. 95 * @syscap SystemCapability.Global.I18n 96 * @since 7 97 * @deprecated since 9 98 * @useinstead ohos.System.getSystemLocale 99 */ 100 export function getSystemLocale(): string; 101 102 /** 103 * Provides system functions. 104 * 105 * @syscap SystemCapability.Global.I18n 106 * @since 9 107 */ 108 /** 109 * Provides system functions. 110 * 111 * @syscap SystemCapability.Global.I18n 112 * @crossplatform 113 * @since 10 114 */ 115 /** 116 * Provides system functions. 117 * 118 * @syscap SystemCapability.Global.I18n 119 * @crossplatform 120 * @form 121 * @atomicservice 122 * @since 11 123 */ 124 export class System { 125 /** 126 * Obtains the country or region name localized for display on a given locale. 127 * 128 * @param { string } country - The locale whose country or region name will be displayed. 129 * @param { string } locale - The locale used to display the country or region. 130 * @param { boolean } [sentenceCase] - Specifies whether the country or region name is displayed in sentence case. 131 * @returns { string } the country or region name localized for display on a given locale. 132 * @throws { BusinessError } 401 - check param failed 133 * @throws { BusinessError } 890001 - param value not valid 134 * @syscap SystemCapability.Global.I18n 135 * @since 9 136 */ 137 /** 138 * Obtains the country or region name localized for display on a given locale. 139 * 140 * @param { string } country - The locale whose country or region name will be displayed. It must be a valid country. 141 * @param { string } locale - The locale used to display the country or region. It must be a valid locale. 142 * @param { boolean } [sentenceCase] - Specifies whether the country or region name is displayed in sentence case. 143 * @returns { string } the country or region name localized for display on a given locale. 144 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 145 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 146 * @syscap SystemCapability.Global.I18n 147 * @crossplatform 148 * @since 10 149 */ 150 /** 151 * Obtains the country or region name localized for display on a given locale. 152 * 153 * @param { string } country - The locale whose country or region name will be displayed. It must be a valid country. 154 * @param { string } locale - The locale used to display the country or region. It must be a valid locale. 155 * @param { boolean } [sentenceCase] - Specifies whether the country or region name is displayed in sentence case. 156 * @returns { string } the country or region name localized for display on a given locale. 157 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 158 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 159 * @syscap SystemCapability.Global.I18n 160 * @crossplatform 161 * @atomicservice 162 * @since 12 163 */ 164 static getDisplayCountry(country: string, locale: string, sentenceCase?: boolean): string; 165 166 /** 167 * Obtains the language name localized for display on a given locale. 168 * 169 * @param { string } language - The locale whose language name will be displayed. 170 * @param { string } locale - The locale used to display the language. 171 * @param { boolean } [sentenceCase] - Specifies whether the language name is displayed in sentence case. 172 * @returns { string } the language name localized for display on a given locale. 173 * @throws { BusinessError } 401 - check param failed 174 * @throws { BusinessError } 890001 - param value not valid 175 * @syscap SystemCapability.Global.I18n 176 * @since 9 177 */ 178 /** 179 * Obtains the language name localized for display on a given locale. 180 * 181 * @param { string } language - The locale whose language name will be displayed. 182 * @param { string } locale - The locale used to display the language. 183 * @param { boolean } [sentenceCase] - Specifies whether the language name is displayed in sentence case. 184 * @returns { string } the language name localized for display on a given locale. 185 * @throws { BusinessError } 401 - check param failed 186 * @throws { BusinessError } 890001 - param value not valid 187 * @syscap SystemCapability.Global.I18n 188 * @crossplatform 189 * @since 10 190 */ 191 /** 192 * Obtains the language name localized for display on a given locale. 193 * 194 * @param { string } language - The locale whose language name will be displayed. It must be a valid language. 195 * @param { string } locale - The locale used to display the language. It must be a valid locale. 196 * @param { boolean } [sentenceCase] - Specifies whether the language name is displayed in sentence case. 197 * @returns { string } the language name localized for display on a given locale. 198 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 199 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 200 * @syscap SystemCapability.Global.I18n 201 * @crossplatform 202 * @atomicservice 203 * @since 11 204 */ 205 static getDisplayLanguage(language: string, locale: string, sentenceCase?: boolean): string; 206 207 /** 208 * Obtains all languages supported by the system. 209 * 210 * @returns { Array<string> } all languages supported by the system. 211 * @syscap SystemCapability.Global.I18n 212 * @since 9 213 */ 214 /** 215 * Obtains all languages supported by the system. 216 * 217 * @returns { Array<string> } all languages supported by the system. 218 * @syscap SystemCapability.Global.I18n 219 * @atomicservice 220 * @since 12 221 */ 222 static getSystemLanguages(): Array<string>; 223 224 /** 225 * Obtains all regions supported by the system in the language. 226 * 227 * @param { string } language - The language used to get the list of regions. It must be a valid language. 228 * @returns { Array<string> } all countries or regions supported by the system in the language. 229 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 230 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 231 * @syscap SystemCapability.Global.I18n 232 * @since 9 233 */ 234 /** 235 * Obtains all regions supported by the system in the language. 236 * 237 * @param { string } language - The language used to get the list of regions. It must be a valid language. 238 * @returns { Array<string> } all countries or regions supported by the system in the language. 239 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 240 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 241 * @syscap SystemCapability.Global.I18n 242 * @atomicservice 243 * @since 12 244 */ 245 static getSystemCountries(language: string): Array<string>; 246 247 /** 248 * Determine whether the current language or region is recommended. 249 * 250 * @param { string } language - The language code. It must be a valid language. 251 * @param { string } [region] - The region code. It must be a valid region. 252 * @returns { boolean } whether the current language or region is recommended. 253 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 254 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 255 * @syscap SystemCapability.Global.I18n 256 * @since 9 257 */ 258 /** 259 * Determine whether the current language or region is recommended. 260 * 261 * @param { string } language - The language code. It must be a valid language. 262 * @param { string } [region] - The region code. It must be a valid region. 263 * @returns { boolean } whether the current language or region is recommended. 264 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 265 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 266 * @syscap SystemCapability.Global.I18n 267 * @atomicservice 268 * @since 12 269 */ 270 static isSuggested(language: string, region?: string): boolean; 271 272 /** 273 * Obtains the language currently used by the system. 274 * 275 * @returns { string } the language currently used by the system. 276 * @syscap SystemCapability.Global.I18n 277 * @since 9 278 */ 279 /** 280 * Obtains the language currently used by the system. 281 * 282 * @returns { string } the language currently used by the system. 283 * @syscap SystemCapability.Global.I18n 284 * @crossplatform 285 * @since 10 286 */ 287 /** 288 * Obtains the language currently used by the system. 289 * 290 * @returns { string } the language currently used by the system. 291 * @syscap SystemCapability.Global.I18n 292 * @crossplatform 293 * @form 294 * @atomicservice 295 * @since 11 296 */ 297 static getSystemLanguage(): string; 298 299 /** 300 * Set the language currently used by the system. 301 * 302 * @permission ohos.permission.UPDATE_CONFIGURATION 303 * @param { string } language - The language to be used. It must be a valid language. 304 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 305 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 306 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 307 * @syscap SystemCapability.Global.I18n 308 * @systemapi Hide this for inner system use. 309 * @since 9 310 */ 311 static setSystemLanguage(language: string): void; 312 313 /** 314 * Obtains the region currently used by the system. 315 * 316 * @returns { string } the region currently used by the system. 317 * @syscap SystemCapability.Global.I18n 318 * @since 9 319 */ 320 /** 321 * Obtains the region currently used by the system. 322 * 323 * @returns { string } the region currently used by the system. 324 * @syscap SystemCapability.Global.I18n 325 * @crossplatform 326 * @since 10 327 */ 328 /** 329 * Obtains the region currently used by the system. 330 * 331 * @returns { string } the region currently used by the system. 332 * @syscap SystemCapability.Global.I18n 333 * @crossplatform 334 * @atomicservice 335 * @since 12 336 */ 337 static getSystemRegion(): string; 338 339 /** 340 * Set the region currently used by the system. 341 * 342 * @permission ohos.permission.UPDATE_CONFIGURATION 343 * @param { string } region - The region to be used. It must be a valid region. 344 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 345 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 346 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 347 * @syscap SystemCapability.Global.I18n 348 * @systemapi Hide this for inner system use. 349 * @since 9 350 */ 351 static setSystemRegion(region: string): void; 352 353 /** 354 * Obtains the locale currently used by the system. 355 * 356 * @returns { string } the locale currently used by the system. 357 * @syscap SystemCapability.Global.I18n 358 * @since 9 359 */ 360 /** 361 * Obtains the locale currently used by the system. 362 * 363 * @returns { string } the locale currently used by the system. 364 * @syscap SystemCapability.Global.I18n 365 * @crossplatform 366 * @since 10 367 */ 368 /** 369 * Obtains the locale currently used by the system. 370 * 371 * @returns { string } the locale currently used by the system. 372 * @syscap SystemCapability.Global.I18n 373 * @crossplatform 374 * @atomicservice 375 * @since 11 376 */ 377 static getSystemLocale(): string; 378 379 /** 380 * Set the locale currently used by the system. 381 * 382 * @permission ohos.permission.UPDATE_CONFIGURATION 383 * @param { string } locale - The locale to be used. It must be a valid locale. 384 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 385 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 386 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 387 * @syscap SystemCapability.Global.I18n 388 * @systemapi Hide this for inner system use. 389 * @since 9 390 */ 391 static setSystemLocale(locale: string): void; 392 393 /** 394 * Check out whether system is 24-hour system. 395 * 396 * @returns { boolean } a boolean represent whether system is 24-hour system. 397 * @syscap SystemCapability.Global.I18n 398 * @since 9 399 */ 400 /** 401 * Check out whether system is 24-hour system. 402 * 403 * @returns { boolean } a boolean represent whether system is 24-hour system. 404 * @syscap SystemCapability.Global.I18n 405 * @crossplatform 406 * @since 10 407 */ 408 /** 409 * Check out whether system is 24-hour system. 410 * 411 * @returns { boolean } a boolean represent whether system is 24-hour system. 412 * @syscap SystemCapability.Global.I18n 413 * @crossplatform 414 * @form 415 * @since 11 416 */ 417 /** 418 * Check out whether system is 24-hour system. 419 * 420 * @returns { boolean } a boolean represent whether system is 24-hour system. 421 * @syscap SystemCapability.Global.I18n 422 * @crossplatform 423 * @form 424 * @atomicservice 425 * @since 12 426 */ 427 static is24HourClock(): boolean; 428 429 /** 430 * Set 24-hour system. 431 * 432 * @permission ohos.permission.UPDATE_CONFIGURATION 433 * @param { boolean } option - represent the boolean to be set. 434 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 435 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 436 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 437 * @syscap SystemCapability.Global.I18n 438 * @systemapi Hide this for inner system use. 439 * @since 9 440 */ 441 static set24HourClock(option: boolean): void; 442 443 /** 444 * Add one language to preferred language List. 445 * 446 * @permission ohos.permission.UPDATE_CONFIGURATION 447 * @param { string } language - the language to be added. It must be a valid language. 448 * @param { number } [index] - the position of preferred language list to be inserted. 449 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 450 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 451 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 452 * @syscap SystemCapability.Global.I18n 453 * @systemapi Hide this for inner system use. 454 * @since 9 455 */ 456 static addPreferredLanguage(language: string, index?: number): void; 457 458 /** 459 * Remove one language from preferred language list. 460 * 461 * @permission ohos.permission.UPDATE_CONFIGURATION 462 * @param { number } index - the position of removed language in preferred language list. 463 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 464 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 465 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 466 * @syscap SystemCapability.Global.I18n 467 * @systemapi Hide this for inner system use. 468 * @since 9 469 */ 470 static removePreferredLanguage(index: number): void; 471 472 /** 473 * Access the system preferred language list. 474 * 475 * @returns { Array<string> } a string Array represent the preferred language list. 476 * @syscap SystemCapability.Global.I18n 477 * @since 9 478 */ 479 /** 480 * Access the system preferred language list. 481 * 482 * @returns { Array<string> } a string Array represent the preferred language list. 483 * @syscap SystemCapability.Global.I18n 484 * @atomicservice 485 * @since 12 486 */ 487 static getPreferredLanguageList(): Array<string>; 488 489 /** 490 * Get the first preferred language of system. 491 * 492 * @returns { string } a string represent the first preferred language of system. 493 * @syscap SystemCapability.Global.I18n 494 * @since 9 495 */ 496 /** 497 * Get the first preferred language of system. 498 * 499 * @returns { string } a string represent the first preferred language of system. 500 * @syscap SystemCapability.Global.I18n 501 * @atomicservice 502 * @since 12 503 */ 504 static getFirstPreferredLanguage(): string; 505 506 /** 507 * Set the preferred language of App. 508 * 509 * @param { string } language - the language to be set. It must be a valid language. 510 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 511 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 512 * @syscap SystemCapability.Global.I18n 513 * @since 11 514 */ 515 /** 516 * Set the preferred language of App. 517 * 518 * @param { string } language - the language to be set. It must be a valid language. 519 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 520 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 521 * @syscap SystemCapability.Global.I18n 522 * @atomicservice 523 * @since 12 524 */ 525 static setAppPreferredLanguage(language: string): void; 526 527 /** 528 * Get the preferred language of App. 529 * 530 * @returns { string } a string represent the preferred language of App. 531 * @syscap SystemCapability.Global.I18n 532 * @since 9 533 */ 534 /** 535 * Get the preferred language of App. 536 * 537 * @returns { string } a string represent the preferred language of App. 538 * @syscap SystemCapability.Global.I18n 539 * @atomicservice 540 * @since 12 541 */ 542 static getAppPreferredLanguage(): string; 543 544 /** 545 * Set whether to use local digit. 546 * 547 * @permission ohos.permission.UPDATE_CONFIGURATION 548 * @param { boolean } flag - a boolean variable represents whether to use local digit 549 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 550 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 551 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 552 * @syscap SystemCapability.Global.I18n 553 * @systemapi Hide this for inner system use. 554 * @since 9 555 */ 556 static setUsingLocalDigit(flag: boolean): void; 557 558 /** 559 * Get whether to use local digit. 560 * 561 * @returns { boolean } a boolean represents whether to use local digit. 562 * @syscap SystemCapability.Global.I18n 563 * @since 9 564 */ 565 /** 566 * Get whether to use local digit. 567 * 568 * @returns { boolean } a boolean represents whether to use local digit. 569 * @syscap SystemCapability.Global.I18n 570 * @atomicservice 571 * @since 12 572 */ 573 static getUsingLocalDigit(): boolean; 574 575 /** 576 * Gets the equivalent simplest representation of input language id. 577 * When no parameter is passed in, current system language's simplest representation will be returned. 578 * If current system language is a dialect language, then system language's simplest representation will be returned; 579 * If current system language is not a dialect language, but it has a dialect language which is supported by system, 580 * then the dialect language's simplest representation will be returned; 581 * If current system language is not a dialect language, and it doesn't have a dialect language which is supported by system, 582 * then the system language's simplest representation will be returned; 583 * 584 * @param { string } [language] - The language code. It must be a valid language. 585 * @returns { string } The equivalent simplest representation of language. 586 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 587 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 588 * @syscap SystemCapability.Global.I18n 589 * @atomicservice 590 * @since 15 591 */ 592 static getSimplifiedLanguage(language?: string): string; 593 } 594 595 /** 596 * Provides util functions. 597 * 598 * @interface Util 599 * @syscap SystemCapability.Global.I18n 600 * @since 8 601 * @deprecated since 9 602 * @useinstead ohos.i18n/i18n.I18NUtil 603 */ 604 export interface Util { 605 /** 606 * Convert from unit to unit and format according to the locale. 607 * 608 * @param { UnitInfo } fromUnit - Information of the unit to be converted. 609 * @param { UnitInfo } toUnit - Information about the unit to be converted to. 610 * @param { number } value - Indicates the number to be formatted. 611 * @param { string } locale - The locale to be used. 612 * @param { string } [style] - The style of format. 613 * @returns { string } converted number and unit. 614 * @syscap SystemCapability.Global.I18n 615 * @since 8 616 * @deprecated since 9 617 * @useinstead ohos.i18n/i18n.I18NUtil#unitConvert 618 */ 619 unitConvert(fromUnit: UnitInfo, toUnit: UnitInfo, value: number, locale: string, style?: string): string; 620 } 621 622 /** 623 * Provides util functions. 624 * 625 * @syscap SystemCapability.Global.I18n 626 * @since 9 627 */ 628 /** 629 * Provides util functions. 630 * 631 * @syscap SystemCapability.Global.I18n 632 * @crossplatform 633 * @since 10 634 */ 635 /** 636 * Provides util functions. 637 * 638 * @syscap SystemCapability.Global.I18n 639 * @crossplatform 640 * @atomicservice 641 * @since 12 642 */ 643 export class I18NUtil { 644 /** 645 * Convert from unit to unit and format according to the locale. 646 * 647 * @param { UnitInfo } fromUnit - Information of the unit to be converted. 648 * @param { UnitInfo } toUnit - Information about the unit to be converted to. 649 * @param { number } value - Indicates the number to be formatted. 650 * @param { string } locale - The locale to be used. 651 * @param { string } [style] - The style of format. 652 * @returns { string } converted number and unit. 653 * @syscap SystemCapability.Global.I18n 654 * @since 9 655 */ 656 /** 657 * Convert from unit to unit and format according to the locale. 658 * 659 * @param { UnitInfo } fromUnit - Information of the unit to be converted. 660 * @param { UnitInfo } toUnit - Information about the unit to be converted to. 661 * @param { number } value - Indicates the number to be formatted. 662 * @param { string } locale - The locale to be used. 663 * @param { string } [style] - The style of format. 664 * @returns { string } converted number and unit. 665 * @syscap SystemCapability.Global.I18n 666 * @atomicservice 667 * @since 12 668 */ 669 static unitConvert(fromUnit: UnitInfo, toUnit: UnitInfo, value: number, locale: string, style?: string): string; 670 671 /** 672 * Get the order of year, month, day in the specified locale. Year, month, day are separated by '-'. 673 * 'y' stands for year, 'L' stands for month, d stands for day. 674 * 675 * @param { string } locale - Information of the locale 676 * @returns { string } the string of 'y', 'L', 'd' joined by '-'. 677 * @syscap SystemCapability.Global.I18n 678 * @since 9 679 */ 680 /** 681 * Get the order of year, month, day in the specified locale. Year, month, day are separated by '-'. 682 * 'y' stands for year, 'L' stands for month, d stands for day. 683 * 684 * @param { string } locale - Information of the locale. 685 * @returns { string } the string of 'y', 'L', 'd' joined by '-'. 686 * @syscap SystemCapability.Global.I18n 687 * @crossplatform 688 * @since 10 689 */ 690 /** 691 * Get the order of year, month, day in the specified locale. Year, month, day are separated by '-'. 692 * 'y' stands for year, 'L' stands for month, d stands for day. 693 * 694 * @param { string } locale - Information of the locale. 695 * @returns { string } the string of 'y', 'L', 'd' joined by '-'. 696 * @syscap SystemCapability.Global.I18n 697 * @crossplatform 698 * @atomicservice 699 * @since 12 700 */ 701 static getDateOrder(locale: string): string; 702 703 /** 704 * Get the time period name for the specified hour. 705 * 706 * @param { number } hour - the hour value. 707 * @param { string } [locale] - specified the locale. Use current app locale by default. It must be a valid locale. 708 * @returns { string } the string of time period name. The return value may be empty string 709 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 710 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 711 * @syscap SystemCapability.Global.I18n 712 * @since 11 713 */ 714 /** 715 * Get the time period name for the specified hour. 716 * 717 * @param { number } hour - the hour value. 718 * @param { string } [locale] - specified the locale. Use current app locale by default. It must be a valid locale. 719 * @returns { string } the string of time period name. The return value may be empty string 720 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 721 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 722 * @syscap SystemCapability.Global.I18n 723 * @atomicservice 724 * @since 12 725 */ 726 static getTimePeriodName(hour:number, locale?: string): string; 727 728 /** 729 * Get the best matched locale in the specified list. 730 * 731 * @param { string } locale - the origin locale. It must be a valid locale. 732 * @param { string[] } localeList - a list of locales to be matched. It must be a valid locale. 733 * @returns { string } the string of the best matched locale name. 734 * The return value may be empty string due to none is matched. 735 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 736 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 737 * @static 738 * @syscap SystemCapability.Global.I18n 739 * @crossplatform 740 * @atomicservice 741 * @since 12 742 */ 743 static getBestMatchLocale(locale: string, localeList: string[]): string; 744 745 /** 746 * Get a three-letter abbreviation of the specified language. 747 * 748 * @param { string } locale - the origin locale or language code. It must be a valid locale. 749 * @returns { string } 3 letter language code. 750 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 751 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 752 * @static 753 * @syscap SystemCapability.Global.I18n 754 * @atomicservice 755 * @since 12 756 */ 757 static getThreeLetterLanguage(locale: string): string; 758 759 /** 760 * Get a three-letter abbreviation of the specified region. 761 * 762 * @param { string } locale - the origin locale or region code. It must be a valid locale. 763 * @returns { string } 3 letter region code. 764 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 765 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 766 * @static 767 * @syscap SystemCapability.Global.I18n 768 * @atomicservice 769 * @since 12 770 */ 771 static getThreeLetterRegion(locale: string): string; 772 } 773 774 /** 775 * Provides the options of unit. 776 * 777 * @interface UnitInfo 778 * @syscap SystemCapability.Global.I18n 779 * @since 8 780 */ 781 /** 782 * Provides the options of unit. 783 * 784 * @interface UnitInfo 785 * @syscap SystemCapability.Global.I18n 786 * @atomicservice 787 * @since 12 788 */ 789 export interface UnitInfo { 790 /** 791 * Unit name. 792 * 793 * @syscap SystemCapability.Global.I18n 794 * @since 8 795 */ 796 /** 797 * Unit name. 798 * 799 * @type { string } 800 * @syscap SystemCapability.Global.I18n 801 * @atomicservice 802 * @since 12 803 */ 804 unit: string; 805 806 /** 807 * The measurement system of the unit. 808 * 809 * @syscap SystemCapability.Global.I18n 810 * @since 8 811 */ 812 /** 813 * The measurement system of the unit. 814 * 815 * @type { string } 816 * @syscap SystemCapability.Global.I18n 817 * @atomicservice 818 * @since 12 819 */ 820 measureSystem: string; 821 } 822 823 /** 824 * Provides the options of PhoneNumberFormat. 825 * 826 * @interface PhoneNumberFormatOptions 827 * @syscap SystemCapability.Global.I18n 828 * @since 8 829 */ 830 /** 831 * Provides the options of PhoneNumberFormat. 832 * 833 * @interface PhoneNumberFormatOptions 834 * @syscap SystemCapability.Global.I18n 835 * @crossplatform 836 * @since 11 837 */ 838 /** 839 * Provides the options of PhoneNumberFormat. 840 * 841 * @interface PhoneNumberFormatOptions 842 * @syscap SystemCapability.Global.I18n 843 * @crossplatform 844 * @atomicservice 845 * @since 12 846 */ 847 export interface PhoneNumberFormatOptions { 848 /** 849 * Indicates the type to format phone number. 850 * 851 * @type { string } 852 * @syscap SystemCapability.Global.I18n 853 * @since 8 854 */ 855 /** 856 * Indicates the type to format phone number. 857 * 858 * @type { ?string } 859 * @syscap SystemCapability.Global.I18n 860 * @since 9 861 */ 862 /** 863 * Indicates the type to format phone number. 864 * 865 * @type { ?string } 866 * @syscap SystemCapability.Global.I18n 867 * @crossplatform 868 * @since 11 869 */ 870 /** 871 * Indicates the type to format phone number. 872 * 873 * @type { ?string } 874 * @syscap SystemCapability.Global.I18n 875 * @crossplatform 876 * @atomicservice 877 * @since 12 878 */ 879 type?: string; 880 } 881 882 /** 883 * Provides the API for formatting phone number strings 884 * 885 * @syscap SystemCapability.Global.I18n 886 * @since 8 887 */ 888 /** 889 * Provides the API for formatting phone number strings 890 * 891 * @syscap SystemCapability.Global.I18n 892 * @crossplatform 893 * @since 11 894 */ 895 /** 896 * Provides the API for formatting phone number strings 897 * 898 * @syscap SystemCapability.Global.I18n 899 * @crossplatform 900 * @atomicservice 901 * @since 12 902 */ 903 export class PhoneNumberFormat { 904 /** 905 * A constructor used to create a PhoneNumberFormat object. 906 * 907 * @param { string } country - Indicates a character string containing the country information for the PhoneNumberFormat object. 908 * @param { PhoneNumberFormatOptions } [options] - format types: "E164", "RFC3966", "INTERNATIONAL", "NATIONAL". 909 * @syscap SystemCapability.Global.I18n 910 * @since 8 911 */ 912 /** 913 * A constructor used to create a PhoneNumberFormat object. 914 * 915 * @param { string } country - Indicates a character string containing the country information for the PhoneNumberFormat object. 916 * @param { PhoneNumberFormatOptions } [options] - format types: "E164", "RFC3966", "INTERNATIONAL", "NATIONAL". 917 * @syscap SystemCapability.Global.I18n 918 * @crossplatform 919 * @since 11 920 */ 921 /** 922 * A constructor used to create a PhoneNumberFormat object. 923 * 924 * @param { string } country - Indicates a character string containing the country information for the PhoneNumberFormat object. 925 * @param { PhoneNumberFormatOptions } [options] - format types: "E164", "RFC3966", "INTERNATIONAL", "NATIONAL". 926 * @syscap SystemCapability.Global.I18n 927 * @crossplatform 928 * @atomicservice 929 * @since 12 930 */ 931 constructor(country: string, options?: PhoneNumberFormatOptions); 932 933 /** 934 * Judge whether phone number is valid. 935 * 936 * @param { string } number - Indicates the input phone number. 937 * @returns { boolean } a boolean indicates whether the input phone number is valid. 938 * @syscap SystemCapability.Global.I18n 939 * @since 8 940 */ 941 /** 942 * Judge whether phone number is valid. 943 * 944 * @param { string } number - Indicates the input phone number. 945 * @returns { boolean } a boolean indicates whether the input phone number is valid. 946 * @syscap SystemCapability.Global.I18n 947 * @crossplatform 948 * @since 11 949 */ 950 /** 951 * Judge whether phone number is valid. 952 * 953 * @param { string } number - Indicates the input phone number. 954 * @returns { boolean } a boolean indicates whether the input phone number is valid. 955 * @syscap SystemCapability.Global.I18n 956 * @crossplatform 957 * @atomicservice 958 * @since 12 959 */ 960 isValidNumber(number: string): boolean; 961 962 /** 963 * Obtains the formatted phone number strings of number. 964 * 965 * @param { string } number - Indicates the input phone number to be formatted. 966 * @returns { string } the formatted phone number. 967 * @syscap SystemCapability.Global.I18n 968 * @since 8 969 */ 970 /** 971 * Obtains the formatted phone number strings of number. 972 * 973 * @param { string } number - Indicates the input phone number to be formatted. 974 * @returns { string } the formatted phone number. 975 * @syscap SystemCapability.Global.I18n 976 * @crossplatform 977 * @since 11 978 */ 979 /** 980 * Obtains the formatted phone number strings of number. 981 * 982 * @param { string } number - Indicates the input phone number to be formatted. 983 * @returns { string } the formatted phone number. 984 * @syscap SystemCapability.Global.I18n 985 * @crossplatform 986 * @atomicservice 987 * @since 12 988 */ 989 format(number: string): string; 990 991 /** 992 * Determine the location by phone number, and return it according to the specified regional language. 993 * 994 * @param { string } number - input phone number. 995 * @param { string } locale - locale ID. 996 * @returns { string } a string represents phone number's location. 997 * @syscap SystemCapability.Global.I18n 998 * @since 9 999 */ 1000 /** 1001 * Determine the location by phone number, and return it according to the specified regional language. 1002 * 1003 * @param { string } number - input phone number. 1004 * @param { string } locale - locale ID. 1005 * @returns { string } a string represents phone number's location. 1006 * @syscap SystemCapability.Global.I18n 1007 * @atomicservice 1008 * @since 12 1009 */ 1010 getLocationName(number: string, locale: string): string; 1011 } 1012 1013 /** 1014 * Get a Calendar instance specified by locale and type. 1015 * 1016 * @param { string } locale - The locale used to get calendar. 1017 * @param { string } [type] - If type is not specified, get locale's default Calendar, else get the specified type of Calendar. 1018 * such as buddhist, chinese, coptic, ethiopic, hebrew, gregory, indian, islamic_civil, islamic_tbla, islamic_umalqura, 1019 * japanese, persian. 1020 * @returns { Calendar } Calendar object 1021 * @syscap SystemCapability.Global.I18n 1022 * @since 8 1023 */ 1024 /** 1025 * Get a Calendar instance specified by locale and type. 1026 * 1027 * @param { string } locale - The locale used to get calendar. 1028 * @param { string } [type] - If type is not specified, get locale's default Calendar, else get the specified type of Calendar. 1029 * such as buddhist, chinese, coptic, ethiopic, hebrew, gregory, indian, islamic_civil, islamic_tbla, islamic_umalqura, 1030 * japanese, persian. 1031 * @returns { Calendar } Calendar object 1032 * @syscap SystemCapability.Global.I18n 1033 * @crossplatform 1034 * @since 10 1035 */ 1036 /** 1037 * Get a Calendar instance specified by locale and type. 1038 * 1039 * @param { string } locale - The locale used to get calendar. 1040 * @param { string } [type] - If type is not specified, get locale's default Calendar, else get the specified type of Calendar. 1041 * such as buddhist, chinese, coptic, ethiopic, hebrew, gregory, indian, islamic_civil, islamic_tbla, islamic_umalqura, 1042 * japanese, persian. 1043 * @returns { Calendar } Calendar object 1044 * @syscap SystemCapability.Global.I18n 1045 * @crossplatform 1046 * @atomicservice 1047 * @since 12 1048 */ 1049 export function getCalendar(locale: string, type?: string): Calendar; 1050 1051 /** 1052 * Provides the API for accessing Calendar name, time and date related information. 1053 * 1054 * @syscap SystemCapability.Global.I18n 1055 * @since 7 1056 */ 1057 /** 1058 * Provides the API for accessing Calendar name, time and date related information. 1059 * 1060 * @syscap SystemCapability.Global.I18n 1061 * @crossplatform 1062 * @since 10 1063 */ 1064 /** 1065 * Provides the API for accessing Calendar name, time and date related information. 1066 * 1067 * @syscap SystemCapability.Global.I18n 1068 * @crossplatform 1069 * @atomicservice 1070 * @since 12 1071 */ 1072 export class Calendar { 1073 /** 1074 * set the date. 1075 * 1076 * @param { Date } date - Date object used to set the time and date. 1077 * @syscap SystemCapability.Global.I18n 1078 * @since 8 1079 */ 1080 /** 1081 * set the date. 1082 * 1083 * @param { Date } date - Date object used to set the time and date. 1084 * @syscap SystemCapability.Global.I18n 1085 * @crossplatform 1086 * @since 10 1087 */ 1088 /** 1089 * set the date. 1090 * 1091 * @param { Date } date - Date object used to set the time and date. 1092 * @syscap SystemCapability.Global.I18n 1093 * @crossplatform 1094 * @atomicservice 1095 * @since 12 1096 */ 1097 setTime(date: Date): void; 1098 1099 /** 1100 * set the time. 1101 * 1102 * @param { number } time - Indicates the elapsed milliseconds from 1970.1.1 00:00:00 GMT. 1103 * @syscap SystemCapability.Global.I18n 1104 * @since 8 1105 */ 1106 /** 1107 * set the time. 1108 * 1109 * @param { number } time - Indicates the elapsed milliseconds from 1970.1.1 00:00:00 GMT. 1110 * @syscap SystemCapability.Global.I18n 1111 * @crossplatform 1112 * @since 10 1113 */ 1114 /** 1115 * set the time. 1116 * 1117 * @param { number } time - Indicates the elapsed milliseconds from 1970.1.1 00:00:00 GMT. 1118 * @syscap SystemCapability.Global.I18n 1119 * @crossplatform 1120 * @atomicservice 1121 * @since 12 1122 */ 1123 setTime(time: number): void; 1124 1125 /** 1126 * Set the time 1127 * 1128 * @param { number } year - The year field of the calendar, ranges from 0 to 9999. 1129 * @param { number } month - The month field of the calendar, ranges from 0 to 11. 1130 * @param { number } date - The day field of the calendar, ranges from 1 to 31. 1131 * @param { number } hour - The hour field of the calendar, ranges from 0 to 23. 1132 * @param { number } minute - The minute field of the calendar, ranges from 0 to 59. 1133 * @param { number } second - the second field of the calendar, ranges from 0 to 59. 1134 * @syscap SystemCapability.Global.I18n 1135 * @since 8 1136 */ 1137 /** 1138 * Set the time 1139 * 1140 * @param { number } year - The year field of the calendar, ranges from 0 to 9999. 1141 * @param { number } month - The month field of the calendar, ranges from 0 to 11. 1142 * @param { number } date - The day field of the calendar, ranges from 1 to 31. 1143 * @param { number } hour - The hour field of the calendar, ranges from 0 to 23. 1144 * @param { number } minute - The minute field of the calendar, ranges from 0 to 59. 1145 * @param { number } second - the second field of the calendar, ranges from 0 to 59. 1146 * @syscap SystemCapability.Global.I18n 1147 * @crossplatform 1148 * @since 10 1149 */ 1150 /** 1151 * Set the time 1152 * 1153 * @param { number } year - The year field of the calendar, ranges from 0 to 9999. 1154 * @param { number } month - The month field of the calendar, ranges from 0 to 11. 1155 * @param { number } date - The day field of the calendar, ranges from 1 to 31. 1156 * @param { number } hour - The hour field of the calendar, ranges from 0 to 23. 1157 * @param { number } minute - The minute field of the calendar, ranges from 0 to 59. 1158 * @param { number } second - the second field of the calendar, ranges from 0 to 59. 1159 * @syscap SystemCapability.Global.I18n 1160 * @crossplatform 1161 * @atomicservice 1162 * @since 12 1163 */ 1164 set(year: number, month: number, date: number, hour?: number, minute?: number, second?: number): void; 1165 1166 /** 1167 * Set the timezone of this calendar. 1168 * 1169 * @param { string } timezone - The id of a timezone. 1170 * @syscap SystemCapability.Global.I18n 1171 * @since 8 1172 */ 1173 /** 1174 * Set the timezone of this calendar. 1175 * 1176 * @param { string } timezone - The id of a timezone. 1177 * @syscap SystemCapability.Global.I18n 1178 * @crossplatform 1179 * @since 10 1180 */ 1181 /** 1182 * Set the timezone of this calendar. 1183 * 1184 * @param { string } timezone - The id of a timezone. 1185 * @syscap SystemCapability.Global.I18n 1186 * @crossplatform 1187 * @atomicservice 1188 * @since 12 1189 */ 1190 setTimeZone(timezone: string): void; 1191 1192 /** 1193 * Get the timezone id of this calendar instance. 1194 * 1195 * @returns { string } the timezone id of this calendar. 1196 * @syscap SystemCapability.Global.I18n 1197 * @since 8 1198 */ 1199 /** 1200 * Get the timezone id of this calendar instance. 1201 * 1202 * @returns { string } the timezone id of this calendar. 1203 * @syscap SystemCapability.Global.I18n 1204 * @crossplatform 1205 * @since 10 1206 */ 1207 /** 1208 * Get the timezone id of this calendar instance. 1209 * 1210 * @returns { string } the timezone id of this calendar. 1211 * @syscap SystemCapability.Global.I18n 1212 * @crossplatform 1213 * @atomicservice 1214 * @since 12 1215 */ 1216 getTimeZone(): string; 1217 1218 /** 1219 * Get the start day of a week. 1 indicates Sunday, 7 indicates Saturday. 1220 * 1221 * @returns { number } start day of a week. 1222 * @syscap SystemCapability.Global.I18n 1223 * @since 8 1224 */ 1225 /** 1226 * Get the start day of a week. 1 indicates Sunday, 7 indicates Saturday. 1227 * 1228 * @returns { number } start day of a week. 1229 * @syscap SystemCapability.Global.I18n 1230 * @crossplatform 1231 * @since 10 1232 */ 1233 /** 1234 * Get the start day of a week. 1 indicates Sunday, 7 indicates Saturday. 1235 * 1236 * @returns { number } start day of a week. 1237 * @syscap SystemCapability.Global.I18n 1238 * @crossplatform 1239 * @atomicservice 1240 * @since 12 1241 */ 1242 getFirstDayOfWeek(): number; 1243 1244 /** 1245 * Set the start day of a week. 1 indicates Sunday, 7 indicates Saturday. 1246 * 1247 * @param { number } value - Indicates the start day of a week. 1 indicates Sunday, 7 indicates Saturday. 1248 * @syscap SystemCapability.Global.I18n 1249 * @since 8 1250 */ 1251 /** 1252 * Set the start day of a week. 1 indicates Sunday, 7 indicates Saturday. 1253 * 1254 * @param { number } value - Indicates the start day of a week. 1 indicates Sunday, 7 indicates Saturday. 1255 * @syscap SystemCapability.Global.I18n 1256 * @crossplatform 1257 * @since 10 1258 */ 1259 /** 1260 * Set the start day of a week. 1 indicates Sunday, 7 indicates Saturday. 1261 * 1262 * @param { number } value - Indicates the start day of a week. 1 indicates Sunday, 7 indicates Saturday. 1263 * @syscap SystemCapability.Global.I18n 1264 * @crossplatform 1265 * @atomicservice 1266 * @since 12 1267 */ 1268 setFirstDayOfWeek(value: number): void; 1269 1270 /** 1271 * Get the minimal days of a week, which is needed for the first day of a year. 1272 * 1273 * @returns { number } the minimal days of a week. 1274 * @syscap SystemCapability.Global.I18n 1275 * @since 8 1276 */ 1277 /** 1278 * Get the minimal days of a week, which is needed for the first day of a year. 1279 * 1280 * @returns { number } the minimal days of a week. 1281 * @syscap SystemCapability.Global.I18n 1282 * @crossplatform 1283 * @since 10 1284 */ 1285 /** 1286 * Get the minimal days of a week, which is needed for the first day of a year. 1287 * 1288 * @returns { number } the minimal days of a week. 1289 * @syscap SystemCapability.Global.I18n 1290 * @crossplatform 1291 * @atomicservice 1292 * @since 12 1293 */ 1294 getMinimalDaysInFirstWeek(): number; 1295 1296 /** 1297 * Set the minimal days of a week, which is needed for the first week of a year. 1298 * 1299 * @param { number } value - The value to be set. 1300 * @syscap SystemCapability.Global.I18n 1301 * @since 8 1302 */ 1303 /** 1304 * Set the minimal days of a week, which is needed for the first week of a year. 1305 * 1306 * @param { number } value - The value to be set. 1307 * @syscap SystemCapability.Global.I18n 1308 * @crossplatform 1309 * @since 10 1310 */ 1311 /** 1312 * Set the minimal days of a week, which is needed for the first week of a year. 1313 * 1314 * @param { number } value - The value to be set. 1315 * @syscap SystemCapability.Global.I18n 1316 * @crossplatform 1317 * @atomicservice 1318 * @since 12 1319 */ 1320 setMinimalDaysInFirstWeek(value: number): void; 1321 1322 /** 1323 * Get the associated value with the field. 1324 * 1325 * @param { string } field - Field values such as era, year, month, week_of_year, week_of_month, date, day_of_year, day_of_week 1326 * day_of_week_in_month, hour, hour_of_day, minute, second, millisecond, zone_offset, dst_offset, year_woy, 1327 * dow_local, extended_year, julian_day, milliseconds_in_day, is_leap_month. 1328 * @returns { number } the associated value. 1329 * @syscap SystemCapability.Global.I18n 1330 * @since 8 1331 */ 1332 /** 1333 * Get the associated value with the field. 1334 * 1335 * @param { string } field - Field values such as era, year, month, week_of_year, week_of_month, date, day_of_year, day_of_week 1336 * day_of_week_in_month, hour, hour_of_day, minute, second, millisecond, zone_offset, dst_offset, year_woy, 1337 * dow_local, extended_year, julian_day, milliseconds_in_day, is_leap_month. 1338 * @returns { number } the associated value. 1339 * @syscap SystemCapability.Global.I18n 1340 * @crossplatform 1341 * @since 10 1342 */ 1343 /** 1344 * Get the associated value with the field. 1345 * 1346 * @param { string } field - Field values such as era, year, month, week_of_year, week_of_month, date, day_of_year, day_of_week 1347 * day_of_week_in_month, hour, hour_of_day, minute, second, millisecond, zone_offset, dst_offset, year_woy, 1348 * dow_local, extended_year, julian_day, milliseconds_in_day, is_leap_month. 1349 * @returns { number } the associated value. 1350 * @syscap SystemCapability.Global.I18n 1351 * @crossplatform 1352 * @atomicservice 1353 * @since 12 1354 */ 1355 get(field: string): number; 1356 1357 /** 1358 * Get calendar's name localized for display in the given locale. 1359 * 1360 * @param { string } locale - Locale used to get the localized name for this calendar. It must be a valid locale. 1361 * @returns { string } the localized name of this calendar. 1362 * @syscap SystemCapability.Global.I18n 1363 * @since 8 1364 */ 1365 /** 1366 * Get calendar's name localized for display in the given locale. 1367 * 1368 * @param { string } locale - Locale used to get the localized name for this calendar. It must be a valid locale. 1369 * @returns { string } the localized name of this calendar. 1370 * @syscap SystemCapability.Global.I18n 1371 * @atomicservice 1372 * @since 12 1373 */ 1374 getDisplayName(locale: string): string; 1375 1376 /** 1377 * Returns true if the given date is a weekend day. If the date is not given, 1378 * the date object of this calendar is used. 1379 * 1380 * @param { Date } [date] - Date object whose attribute is desired. 1381 * @returns { boolean } whether the date is a weekend day. 1382 * @syscap SystemCapability.Global.I18n 1383 * @since 8 1384 */ 1385 /** 1386 * Returns true if the given date is a weekend day. If the date is not given, 1387 * the date object of this calendar is used. 1388 * 1389 * @param { Date } [date] - Date object whose attribute is desired. 1390 * @returns { boolean } whether the date is a weekend day. 1391 * @syscap SystemCapability.Global.I18n 1392 * @crossplatform 1393 * @since 10 1394 */ 1395 /** 1396 * Returns true if the given date is a weekend day. If the date is not given, 1397 * the date object of this calendar is used. 1398 * 1399 * @param { Date } [date] - Date object whose attribute is desired. 1400 * @returns { boolean } whether the date is a weekend day. 1401 * @syscap SystemCapability.Global.I18n 1402 * @crossplatform 1403 * @atomicservice 1404 * @since 12 1405 */ 1406 isWeekend(date?: Date): boolean; 1407 1408 /** 1409 * Adds or subtract the specified amount of time to the given calendar field. 1410 * 1411 * @param { string } field - field values such as year, month, week_of_year, week_of_month, date, day_of_year, day_of_week 1412 * day_of_week_in_month, hour, hour_of_day, minute, second, millisecond 1413 * @param { number } amount - the amount of date or time to be added to the field. 1414 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1415 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 1416 * @syscap SystemCapability.Global.I18n 1417 * @crossplatform 1418 * @since 11 1419 */ 1420 /** 1421 * Adds or subtract the specified amount of time to the given calendar field. 1422 * 1423 * @param { string } field - field values such as year, month, week_of_year, week_of_month, date, day_of_year, day_of_week 1424 * day_of_week_in_month, hour, hour_of_day, minute, second, millisecond 1425 * @param { number } amount - the amount of date or time to be added to the field. 1426 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1427 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 1428 * @syscap SystemCapability.Global.I18n 1429 * @crossplatform 1430 * @atomicservice 1431 * @since 12 1432 */ 1433 add(field: string, amount: number): void; 1434 1435 /** 1436 * Get the UTC milliseconds. 1437 * 1438 * @returns { number } the calendar time as UTC milliseconds. 1439 * @syscap SystemCapability.Global.I18n 1440 * @crossplatform 1441 * @since 11 1442 */ 1443 /** 1444 * Get the UTC milliseconds. 1445 * 1446 * @returns { number } the calendar time as UTC milliseconds. 1447 * @syscap SystemCapability.Global.I18n 1448 * @crossplatform 1449 * @atomicservice 1450 * @since 12 1451 */ 1452 getTimeInMillis(): number; 1453 1454 /** 1455 * Returns days comparison result. 1456 * 1457 * @param { Date } date - Date object to be compared. 1458 * @returns { number } value of of the comparison result. A positive value indicates that the date is later, 1459 * and a negative value indicates that the date is earlier. 1460 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1461 * @syscap SystemCapability.Global.I18n 1462 * @crossplatform 1463 * @since 11 1464 */ 1465 /** 1466 * Returns days comparison result. 1467 * 1468 * @param { Date } date - Date object to be compared. 1469 * @returns { number } value of of the comparison result. A positive value indicates that the date is later, 1470 * and a negative value indicates that the date is earlier. 1471 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 1472 * @syscap SystemCapability.Global.I18n 1473 * @crossplatform 1474 * @atomicservice 1475 * @since 12 1476 */ 1477 compareDays(date: Date): number; 1478 } 1479 1480 /** 1481 * Judge whether the locale is RTL locale. 1482 * 1483 * @param { string } locale - The locale to be used. 1484 * @returns { boolean } true representing the locale is an RTL locale 1485 * @syscap SystemCapability.Global.I18n 1486 * @since 7 1487 */ 1488 /** 1489 * Judge whether the locale is RTL locale. 1490 * 1491 * @param { string } locale - The locale to be used. 1492 * @returns { boolean } true representing the locale is an RTL locale 1493 * @syscap SystemCapability.Global.I18n 1494 * @crossplatform 1495 * @since 10 1496 */ 1497 /** 1498 * Judge whether the locale is RTL locale. 1499 * 1500 * @param { string } locale - The locale to be used. 1501 * @returns { boolean } true representing the locale is an RTL locale 1502 * @syscap SystemCapability.Global.I18n 1503 * @crossplatform 1504 * @atomicservice 1505 * @since 12 1506 */ 1507 export function isRTL(locale: string): boolean; 1508 1509 /** 1510 * Obtains a BreakIterator object for finding the location of break point in text. 1511 * 1512 * @param { string } locale - the returned BreakIterator will adapt the rule, specified by the locale, to break text. 1513 * @returns { BreakIterator } a newly constructed BreakIterator object. 1514 * @syscap SystemCapability.Global.I18n 1515 * @since 8 1516 */ 1517 /** 1518 * Obtains a BreakIterator object for finding the location of break point in text. 1519 * 1520 * @param { string } locale - the returned BreakIterator will adapt the rule, specified by the locale, to break text. 1521 * @returns { BreakIterator } a newly constructed BreakIterator object. 1522 * @syscap SystemCapability.Global.I18n 1523 * @atomicservice 1524 * @since 12 1525 */ 1526 export function getLineInstance(locale: string): BreakIterator; 1527 1528 /** 1529 * The BreakIterator class is used for finding the location of break point in text. 1530 * 1531 * @syscap SystemCapability.Global.I18n 1532 * @since 8 1533 */ 1534 /** 1535 * The BreakIterator class is used for finding the location of break point in text. 1536 * 1537 * @syscap SystemCapability.Global.I18n 1538 * @atomicservice 1539 * @since 12 1540 */ 1541 export class BreakIterator { 1542 /** 1543 * Obtains the current position of the BreakIterator instance. 1544 * 1545 * @returns { number } the current position of the BreakIterator instance. 1546 * @syscap SystemCapability.Global.I18n 1547 * @since 8 1548 */ 1549 /** 1550 * Obtains the current position of the BreakIterator instance. 1551 * 1552 * @returns { number } the current position of the BreakIterator instance. 1553 * @syscap SystemCapability.Global.I18n 1554 * @atomicservice 1555 * @since 12 1556 */ 1557 current(): number; 1558 1559 /** 1560 * Set the BreakIterator's position to the first break point, the first break point is always the beginning of the 1561 * processed text. 1562 * 1563 * @returns { number } the index of the first break point. 1564 * @syscap SystemCapability.Global.I18n 1565 * @since 8 1566 */ 1567 /** 1568 * Set the BreakIterator's position to the first break point, the first break point is always the beginning of the 1569 * processed text. 1570 * 1571 * @returns { number } the index of the first break point. 1572 * @syscap SystemCapability.Global.I18n 1573 * @atomicservice 1574 * @since 12 1575 */ 1576 first(): number; 1577 1578 /** 1579 * Set the BreakIterator's position to the last break point. the last break point is always the index beyond the 1580 * last character of the processed text. 1581 * 1582 * @returns { number } the index of the last break point. 1583 * @syscap SystemCapability.Global.I18n 1584 * @since 8 1585 */ 1586 /** 1587 * Set the BreakIterator's position to the last break point. the last break point is always the index beyond the 1588 * last character of the processed text. 1589 * 1590 * @returns { number } the index of the last break point. 1591 * @syscap SystemCapability.Global.I18n 1592 * @atomicservice 1593 * @since 12 1594 */ 1595 last(): number; 1596 1597 /** 1598 * Set the BreakIterator's position to the nth break point from the current break point. 1599 * 1600 * @param { number } [index] - indicates the number of break points to advance. If index is not given, n is treated as 1. 1601 * @returns { number } the index of the BreakIterator after moving. If there is not enough break points, returns -1. 1602 * @syscap SystemCapability.Global.I18n 1603 * @since 8 1604 */ 1605 /** 1606 * Set the BreakIterator's position to the nth break point from the current break point. 1607 * 1608 * @param { number } [index] - indicates the number of break points to advance. If index is not given, n is treated as 1. 1609 * @returns { number } the index of the BreakIterator after moving. If there is not enough break points, returns -1. 1610 * @syscap SystemCapability.Global.I18n 1611 * @atomicservice 1612 * @since 12 1613 */ 1614 next(index?: number): number; 1615 1616 /** 1617 * Set the BreakIterator's position to the break point preceding the current break point. 1618 * 1619 * @returns { number } the index of the BreakIterator after moving. If there is not enough break points, returns -1. 1620 * @syscap SystemCapability.Global.I18n 1621 * @since 8 1622 */ 1623 /** 1624 * Set the BreakIterator's position to the break point preceding the current break point. 1625 * 1626 * @returns { number } the index of the BreakIterator after moving. If there is not enough break points, returns -1. 1627 * @syscap SystemCapability.Global.I18n 1628 * @atomicservice 1629 * @since 12 1630 */ 1631 previous(): number; 1632 1633 /** 1634 * Set the text to be processed. 1635 * 1636 * @param { string } text - Indicates the text to be processed by the BreakIterator. 1637 * @syscap SystemCapability.Global.I18n 1638 * @since 8 1639 */ 1640 /** 1641 * Set the text to be processed. 1642 * 1643 * @param { string } text - Indicates the text to be processed by the BreakIterator. 1644 * @syscap SystemCapability.Global.I18n 1645 * @atomicservice 1646 * @since 12 1647 */ 1648 setLineBreakText(text: string): void; 1649 1650 /** 1651 * Set the BreakIterator's position to the first break point following the specified offset. 1652 * 1653 * @param { number } offset 1654 * @returns { number } the index of the BreakIterator after moving. If there is not enough break points, returns -1. 1655 * @syscap SystemCapability.Global.I18n 1656 * @since 8 1657 */ 1658 /** 1659 * Set the BreakIterator's position to the first break point following the specified offset. 1660 * 1661 * @param { number } offset 1662 * @returns { number } the index of the BreakIterator after moving. If there is not enough break points, returns -1. 1663 * @syscap SystemCapability.Global.I18n 1664 * @atomicservice 1665 * @since 12 1666 */ 1667 following(offset: number): number; 1668 1669 /** 1670 * Obtains the text being processed. 1671 * 1672 * @returns { string } the text that is processed by the BreakIterator. 1673 * @syscap SystemCapability.Global.I18n 1674 * @since 8 1675 */ 1676 /** 1677 * Obtains the text being processed. 1678 * 1679 * @returns { string } the text that is processed by the BreakIterator. 1680 * @syscap SystemCapability.Global.I18n 1681 * @atomicservice 1682 * @since 12 1683 */ 1684 getLineBreakText(): string; 1685 1686 /** 1687 * Returns true if the position indicated by the offset is a break point, otherwise false. The BreakIterator's 1688 * position will be set to the position indicated by the offset if it returns true, otherwise the BreakIterator 1689 * will be moved to the break point following the offset. 1690 * 1691 * @param { number } offset The offset to be checked. 1692 * @returns { boolean } true if the offset is a break point. 1693 * @syscap SystemCapability.Global.I18n 1694 * @since 8 1695 */ 1696 /** 1697 * Returns true if the position indicated by the offset is a break point, otherwise false. The BreakIterator's 1698 * position will be set to the position indicated by the offset if it returns true, otherwise the BreakIterator 1699 * will be moved to the break point following the offset. 1700 * 1701 * @param { number } offset The offset to be checked. 1702 * @returns { boolean } true if the offset is a break point. 1703 * @syscap SystemCapability.Global.I18n 1704 * @atomicservice 1705 * @since 12 1706 */ 1707 isBoundary(offset: number): boolean; 1708 } 1709 1710 /** 1711 * Get IndexUtil object. 1712 * 1713 * @param { string } [locale] - Indicates a character string containing the locale information, including 1714 * the language and optionally the script and region, for the NumberFormat object. 1715 * @returns { IndexUtil } IndexUtil object. 1716 * @syscap SystemCapability.Global.I18n 1717 * @since 8 1718 */ 1719 /** 1720 * Get IndexUtil object. 1721 * 1722 * @param { string } [locale] - Indicates a character string containing the locale information, including 1723 * the language and optionally the script and region, for the NumberFormat object. 1724 * @returns { IndexUtil } IndexUtil object. 1725 * @syscap SystemCapability.Global.I18n 1726 * @atomicservice 1727 * @since 12 1728 */ 1729 export function getInstance(locale?: string): IndexUtil; 1730 1731 /** 1732 * Sequence text can be grouped under the specified area, 1733 * and grouping index with different lengths can be specified. 1734 * 1735 * @syscap SystemCapability.Global.I18n 1736 * @since 8 1737 */ 1738 /** 1739 * Sequence text can be grouped under the specified area, 1740 * and grouping index with different lengths can be specified. 1741 * 1742 * @syscap SystemCapability.Global.I18n 1743 * @atomicservice 1744 * @since 12 1745 */ 1746 export class IndexUtil { 1747 /** 1748 * Get a list of labels for use as a UI index 1749 * 1750 * @returns { Array<string> } a list of labels 1751 * @syscap SystemCapability.Global.I18n 1752 * @since 8 1753 */ 1754 /** 1755 * Get a list of labels for use as a UI index 1756 * 1757 * @returns { Array<string> } a list of labels 1758 * @syscap SystemCapability.Global.I18n 1759 * @atomicservice 1760 * @since 12 1761 */ 1762 getIndexList(): Array<string>; 1763 1764 /** 1765 * Add the index characters from a Locale to the index. 1766 * 1767 * @param { string } locale - The locale whose index characters are to be added. 1768 * @syscap SystemCapability.Global.I18n 1769 * @since 8 1770 */ 1771 /** 1772 * Add the index characters from a Locale to the index. 1773 * 1774 * @param { string } locale - The locale whose index characters are to be added. 1775 * @syscap SystemCapability.Global.I18n 1776 * @atomicservice 1777 * @since 12 1778 */ 1779 addLocale(locale: string): void; 1780 1781 /** 1782 * Get corresponding index of the input text. 1783 * 1784 * @param { string } text - input text 1785 * @returns { string } index of the input text 1786 * @syscap SystemCapability.Global.I18n 1787 * @since 8 1788 */ 1789 /** 1790 * Get corresponding index of the input text. 1791 * 1792 * @param { string } text - input text 1793 * @returns { string } index of the input text 1794 * @syscap SystemCapability.Global.I18n 1795 * @atomicservice 1796 * @since 12 1797 */ 1798 getIndex(text: string): string; 1799 } 1800 1801 /** 1802 * Provides the API for accessing unicode character properties. For example, determine whether a character is a number. 1803 * 1804 * @syscap SystemCapability.Global.I18n 1805 * @since 8 1806 * @deprecated since 9 1807 * @useinstead Unicode 1808 */ 1809 export class Character { 1810 /** 1811 * Determines whether the specified code point is a digit character 1812 * 1813 * @param { string } char - the character to be tested 1814 * @returns { boolean } true if the character is a digit character 1815 * @syscap SystemCapability.Global.I18n 1816 * @since 8 1817 * @deprecated since 9 1818 * @useinstead Unicode.isDigit 1819 */ 1820 isDigit(char: string): boolean; 1821 1822 /** 1823 * Determines if the specified character is a space character or not. 1824 * 1825 * @param { string } char - the character to be tested 1826 * @returns { boolean } true if the character is a space character 1827 * @syscap SystemCapability.Global.I18n 1828 * @since 8 1829 * @deprecated since 9 1830 * @useinstead Unicode.isSpaceChar 1831 */ 1832 isSpaceChar(char: string): boolean; 1833 1834 /** 1835 * Determines if the specified character is a whitespace character 1836 * 1837 * @param { string } char - the character to be tested 1838 * @returns { boolean } true if the character is a whitespace character 1839 * @syscap SystemCapability.Global.I18n 1840 * @since 8 1841 * @deprecated since 9 1842 * @useinstead Unicode.isWhitespace 1843 */ 1844 isWhitespace(char: string): boolean; 1845 1846 /** 1847 * Determines if the specified character is a RTL character or not. 1848 * 1849 * @param { string } char - the character to be tested 1850 * @returns { boolean } true if the character is a RTL character 1851 * @syscap SystemCapability.Global.I18n 1852 * @since 8 1853 * @deprecated since 9 1854 * @useinstead Unicode.isRTL 1855 */ 1856 isRTL(char: string): boolean; 1857 1858 /** 1859 * Determines if the specified character is a Ideographic character or not. 1860 * 1861 * @param { string } char - the character to be tested 1862 * @returns { boolean } true if the character is a Ideographic character 1863 * @syscap SystemCapability.Global.I18n 1864 * @since 8 1865 * @deprecated since 9 1866 * @useinstead Unicode.isIdeograph 1867 */ 1868 isIdeograph(char: string): boolean; 1869 1870 /** 1871 * Determines if the specified character is a Letter or not. 1872 * 1873 * @param { string } char - the character to be tested 1874 * @returns { boolean } true if the character is a Letter 1875 * @syscap SystemCapability.Global.I18n 1876 * @since 8 1877 * @deprecated since 9 1878 * @useinstead Unicode.isLetter 1879 */ 1880 isLetter(char: string): boolean; 1881 1882 /** 1883 * Determines if the specified character is a LowerCase character or not. 1884 * 1885 * @param { string } char - the character to be tested 1886 * @returns { boolean } true if the character is a LowerCase character 1887 * @syscap SystemCapability.Global.I18n 1888 * @since 8 1889 * @deprecated since 9 1890 * @useinstead Unicode.isLowerCase 1891 */ 1892 isLowerCase(char: string): boolean; 1893 1894 /** 1895 * Determines if the specified character is a UpperCase character or not. 1896 * 1897 * @param { string } char - the character to be tested 1898 * @returns { boolean } true if the character is a UpperCase character 1899 * @syscap SystemCapability.Global.I18n 1900 * @since 8 1901 * @deprecated since 9 1902 * @useinstead Unicode.isUpperCase 1903 */ 1904 isUpperCase(char: string): boolean; 1905 1906 /** 1907 * Get the general category value of the specified character. 1908 * 1909 * @param { string } char - the character to be tested 1910 * @returns { string } the general category of the specified character. 1911 * @syscap SystemCapability.Global.I18n 1912 * @since 8 1913 * @deprecated since 9 1914 * @useinstead Unicode.getType 1915 */ 1916 getType(char: string): string; 1917 } 1918 1919 /** 1920 * Provides the API for accessing unicode character properties. For example, determine whether a character is a number. 1921 * 1922 * @syscap SystemCapability.Global.I18n 1923 * @since 9 1924 */ 1925 /** 1926 * Provides the API for accessing unicode character properties. For example, determine whether a character is a number. 1927 * 1928 * @syscap SystemCapability.Global.I18n 1929 * @crossplatform 1930 * @since 10 1931 */ 1932 /** 1933 * Provides the API for accessing unicode character properties. For example, determine whether a character is a number. 1934 * 1935 * @syscap SystemCapability.Global.I18n 1936 * @crossplatform 1937 * @atomicservice 1938 * @since 12 1939 */ 1940 export class Unicode { 1941 /** 1942 * Determines whether the specified code point is a digit character 1943 * 1944 * @param { string } char - the character to be tested 1945 * @returns { boolean } true if the character is a digit character 1946 * @syscap SystemCapability.Global.I18n 1947 * @since 9 1948 */ 1949 /** 1950 * Determines whether the specified code point is a digit character 1951 * 1952 * @param { string } char - the character to be tested 1953 * @returns { boolean } true if the character is a digit character 1954 * @syscap SystemCapability.Global.I18n 1955 * @crossplatform 1956 * @since 10 1957 */ 1958 /** 1959 * Determines whether the specified code point is a digit character 1960 * 1961 * @param { string } char - the character to be tested 1962 * @returns { boolean } true if the character is a digit character 1963 * @syscap SystemCapability.Global.I18n 1964 * @crossplatform 1965 * @atomicservice 1966 * @since 12 1967 */ 1968 static isDigit(char: string): boolean; 1969 1970 /** 1971 * Determines if the specified character is a space character or not. 1972 * 1973 * @param { string } char - the character to be tested 1974 * @returns { boolean } true if the character is a space character 1975 * @syscap SystemCapability.Global.I18n 1976 * @since 9 1977 */ 1978 /** 1979 * Determines if the specified character is a space character or not. 1980 * 1981 * @param { string } char - the character to be tested 1982 * @returns { boolean } true if the character is a space character 1983 * @syscap SystemCapability.Global.I18n 1984 * @crossplatform 1985 * @since 10 1986 */ 1987 /** 1988 * Determines if the specified character is a space character or not. 1989 * 1990 * @param { string } char - the character to be tested 1991 * @returns { boolean } true if the character is a space character 1992 * @syscap SystemCapability.Global.I18n 1993 * @crossplatform 1994 * @atomicservice 1995 * @since 12 1996 */ 1997 static isSpaceChar(char: string): boolean; 1998 1999 /** 2000 * Determines if the specified character is a whitespace character 2001 * 2002 * @param { string } char - the character to be tested 2003 * @returns { boolean } true if the character is a whitespace character 2004 * @syscap SystemCapability.Global.I18n 2005 * @since 9 2006 */ 2007 /** 2008 * Determines if the specified character is a whitespace character 2009 * 2010 * @param { string } char - the character to be tested 2011 * @returns { boolean } true if the character is a whitespace character 2012 * @syscap SystemCapability.Global.I18n 2013 * @crossplatform 2014 * @since 10 2015 */ 2016 /** 2017 * Determines if the specified character is a whitespace character 2018 * 2019 * @param { string } char - the character to be tested 2020 * @returns { boolean } true if the character is a whitespace character 2021 * @syscap SystemCapability.Global.I18n 2022 * @crossplatform 2023 * @atomicservice 2024 * @since 12 2025 */ 2026 static isWhitespace(char: string): boolean; 2027 2028 /** 2029 * Determines if the specified character is a RTL character or not. 2030 * 2031 * @param { string } char - the character to be tested 2032 * @returns { boolean } true if the character is a RTL character 2033 * @syscap SystemCapability.Global.I18n 2034 * @since 9 2035 */ 2036 /** 2037 * Determines if the specified character is a RTL character or not. 2038 * 2039 * @param { string } char - the character to be tested 2040 * @returns { boolean } true if the character is a RTL character 2041 * @syscap SystemCapability.Global.I18n 2042 * @crossplatform 2043 * @since 10 2044 */ 2045 /** 2046 * Determines if the specified character is a RTL character or not. 2047 * 2048 * @param { string } char - the character to be tested 2049 * @returns { boolean } true if the character is a RTL character 2050 * @syscap SystemCapability.Global.I18n 2051 * @crossplatform 2052 * @atomicservice 2053 * @since 12 2054 */ 2055 static isRTL(char: string): boolean; 2056 2057 /** 2058 * Determines if the specified character is a Ideographic character or not. 2059 * 2060 * @param { string } char - the character to be tested 2061 * @returns { boolean } true if the character is a Ideographic character 2062 * @syscap SystemCapability.Global.I18n 2063 * @since 9 2064 */ 2065 /** 2066 * Determines if the specified character is a Ideographic character or not. 2067 * 2068 * @param { string } char - the character to be tested 2069 * @returns { boolean } true if the character is a Ideographic character 2070 * @syscap SystemCapability.Global.I18n 2071 * @crossplatform 2072 * @since 10 2073 */ 2074 /** 2075 * Determines if the specified character is a Ideographic character or not. 2076 * 2077 * @param { string } char - the character to be tested 2078 * @returns { boolean } true if the character is a Ideographic character 2079 * @syscap SystemCapability.Global.I18n 2080 * @crossplatform 2081 * @atomicservice 2082 * @since 12 2083 */ 2084 static isIdeograph(char: string): boolean; 2085 2086 /** 2087 * Determines if the specified character is a Letter or not. 2088 * 2089 * @param { string } char - the character to be tested 2090 * @returns { boolean } true if the character is a Letter 2091 * @syscap SystemCapability.Global.I18n 2092 * @since 9 2093 */ 2094 /** 2095 * Determines if the specified character is a Letter or not. 2096 * 2097 * @param { string } char - the character to be tested 2098 * @returns { boolean } true if the character is a Letter 2099 * @syscap SystemCapability.Global.I18n 2100 * @crossplatform 2101 * @since 10 2102 */ 2103 /** 2104 * Determines if the specified character is a Letter or not. 2105 * 2106 * @param { string } char - the character to be tested 2107 * @returns { boolean } true if the character is a Letter 2108 * @syscap SystemCapability.Global.I18n 2109 * @crossplatform 2110 * @atomicservice 2111 * @since 12 2112 */ 2113 static isLetter(char: string): boolean; 2114 2115 /** 2116 * Determines if the specified character is a LowerCase character or not. 2117 * 2118 * @param { string } char - the character to be tested 2119 * @returns { boolean } true if the character is a LowerCase character 2120 * @syscap SystemCapability.Global.I18n 2121 * @since 9 2122 */ 2123 /** 2124 * Determines if the specified character is a LowerCase character or not. 2125 * 2126 * @param { string } char - the character to be tested 2127 * @returns { boolean } true if the character is a LowerCase character 2128 * @syscap SystemCapability.Global.I18n 2129 * @crossplatform 2130 * @since 10 2131 */ 2132 /** 2133 * Determines if the specified character is a LowerCase character or not. 2134 * 2135 * @param { string } char - the character to be tested 2136 * @returns { boolean } true if the character is a LowerCase character 2137 * @syscap SystemCapability.Global.I18n 2138 * @crossplatform 2139 * @atomicservice 2140 * @since 12 2141 */ 2142 static isLowerCase(char: string): boolean; 2143 2144 /** 2145 * Determines if the specified character is a UpperCase character or not. 2146 * 2147 * @param { string } char - the character to be tested 2148 * @returns { boolean } true if the character is a UpperCase character 2149 * @syscap SystemCapability.Global.I18n 2150 * @since 9 2151 */ 2152 /** 2153 * Determines if the specified character is a UpperCase character or not. 2154 * 2155 * @param { string } char - the character to be tested 2156 * @returns { boolean } true if the character is a UpperCase character 2157 * @syscap SystemCapability.Global.I18n 2158 * @crossplatform 2159 * @since 10 2160 */ 2161 /** 2162 * Determines if the specified character is a UpperCase character or not. 2163 * 2164 * @param { string } char - the character to be tested 2165 * @returns { boolean } true if the character is a UpperCase character 2166 * @syscap SystemCapability.Global.I18n 2167 * @crossplatform 2168 * @atomicservice 2169 * @since 12 2170 */ 2171 static isUpperCase(char: string): boolean; 2172 2173 /** 2174 * Get the general category value of the specified character. 2175 * 2176 * @param { string } char - the character to be tested 2177 * @returns { string } the general category of the specified character. 2178 * @syscap SystemCapability.Global.I18n 2179 * @since 9 2180 */ 2181 /** 2182 * Get the general category value of the specified character. 2183 * 2184 * @param { string } char - the character to be tested 2185 * @returns { string } the general category of the specified character. 2186 * @syscap SystemCapability.Global.I18n 2187 * @crossplatform 2188 * @since 10 2189 */ 2190 /** 2191 * Get the general category value of the specified character. 2192 * 2193 * @param { string } char - the character to be tested 2194 * @returns { string } the general category of the specified character. 2195 * @syscap SystemCapability.Global.I18n 2196 * @crossplatform 2197 * @atomicservice 2198 * @since 12 2199 */ 2200 static getType(char: string): string; 2201 } 2202 2203 /** 2204 * check out whether system is 24-hour system. 2205 * 2206 * @returns { boolean } a boolean represent whether system is 24-hour system. 2207 * @syscap SystemCapability.Global.I18n 2208 * @since 7 2209 * @deprecated since 9 2210 * @useinstead ohos.i18n/i18n.System#is24HourClock 2211 */ 2212 export function is24HourClock(): boolean; 2213 2214 /** 2215 * set 24-hour system. 2216 * 2217 * @permission ohos.permission.UPDATE_CONFIGURATION 2218 * @param { boolean } option - represent the boolean to be set. 2219 * @returns { boolean } a boolean represent whether setting 24-hour system success. 2220 * @syscap SystemCapability.Global.I18n 2221 * @since 7 2222 * @deprecated since 9 2223 * @useinstead ohos.i18n/i18n.System#set24HourClock 2224 */ 2225 export function set24HourClock(option: boolean): boolean; 2226 2227 /** 2228 * Add one language to preferred language List. 2229 * 2230 * @permission ohos.permission.UPDATE_CONFIGURATION 2231 * @param { string } language - the language to be added. 2232 * @param { number } [index] - the position of preferred language list to be inserted. 2233 * @returns { boolean } a boolean represent whether language added success. 2234 * @syscap SystemCapability.Global.I18n 2235 * @since 8 2236 * @deprecated since 9 2237 * @useinstead ohos.i18n/i18n.System#addPreferredLanguage 2238 */ 2239 export function addPreferredLanguage(language: string, index?: number): boolean; 2240 2241 /** 2242 * Remove one language from preferred language list. 2243 * 2244 * @permission ohos.permission.UPDATE_CONFIGURATION 2245 * @param { number } index - the position of removed language in preferred language list. 2246 * @returns { boolean } a boolean represent whether removed success. 2247 * @syscap SystemCapability.Global.I18n 2248 * @since 8 2249 * @deprecated since 9 2250 * @useinstead ohos.i18n/i18n.System#removePreferredLanguage 2251 */ 2252 export function removePreferredLanguage(index: number): boolean; 2253 2254 /** 2255 * Access the system preferred language list. 2256 * 2257 * @returns { Array<string> } a string Array represent the preferred language list. 2258 * @syscap SystemCapability.Global.I18n 2259 * @since 8 2260 * @deprecated since 9 2261 * @useinstead ohos.i18n/i18n.System#getPreferredLanguageList 2262 */ 2263 export function getPreferredLanguageList(): Array<string>; 2264 2265 /** 2266 * Get the first preferred language of system. 2267 * 2268 * @returns { string } a string represent the first preferred language of system. 2269 * @syscap SystemCapability.Global.I18n 2270 * @since 8 2271 * @deprecated since 9 2272 * @useinstead ohos.i18n/i18n.System#getFirstPreferredLanguage 2273 */ 2274 export function getFirstPreferredLanguage(): string; 2275 2276 /** 2277 * Get the default TimeZone object or the TimeZone object corresponds to zoneID. 2278 * 2279 * @param { string } [zoneID] - TimeZone ID used to create TimeZone Object. 2280 * @returns { TimeZone } a TimeZone object corresponds to zoneID. 2281 * @syscap SystemCapability.Global.I18n 2282 * @since 7 2283 */ 2284 /** 2285 * Get the default TimeZone object or the TimeZone object corresponds to zoneID. 2286 * 2287 * @param { string } [zoneID] - TimeZone ID used to create TimeZone Object. 2288 * @returns { TimeZone } a TimeZone object corresponds to zoneID. 2289 * @syscap SystemCapability.Global.I18n 2290 * @crossplatform 2291 * @since 10 2292 */ 2293 /** 2294 * Get the default TimeZone object or the TimeZone object corresponds to zoneID. 2295 * 2296 * @param { string } [zoneID] - TimeZone ID used to create TimeZone Object. 2297 * @returns { TimeZone } a TimeZone object corresponds to zoneID. 2298 * @syscap SystemCapability.Global.I18n 2299 * @crossplatform 2300 * @atomicservice 2301 * @since 12 2302 */ 2303 export function getTimeZone(zoneID?: string): TimeZone; 2304 2305 /** 2306 * Provides the API for accessing TimeZone name, rawOffset and offset information. 2307 * 2308 * @syscap SystemCapability.Global.I18n 2309 * @since 7 2310 */ 2311 /** 2312 * Provides the API for accessing TimeZone name, rawOffset and offset information. 2313 * 2314 * @syscap SystemCapability.Global.I18n 2315 * @crossplatform 2316 * @since 10 2317 */ 2318 /** 2319 * Provides the API for accessing TimeZone name, rawOffset and offset information. 2320 * 2321 * @syscap SystemCapability.Global.I18n 2322 * @crossplatform 2323 * @atomicservice 2324 * @since 12 2325 */ 2326 export class TimeZone { 2327 /** 2328 * Get the id of the TimeZone object. 2329 * 2330 * @returns { string } a string represents the timezone id. 2331 * @syscap SystemCapability.Global.I18n 2332 * @since 7 2333 */ 2334 /** 2335 * Get the id of the TimeZone object. 2336 * 2337 * @returns { string } a string represents the timezone id. 2338 * @syscap SystemCapability.Global.I18n 2339 * @crossplatform 2340 * @since 10 2341 */ 2342 /** 2343 * Get the id of the TimeZone object. 2344 * 2345 * @returns { string } a string represents the timezone id. 2346 * @syscap SystemCapability.Global.I18n 2347 * @crossplatform 2348 * @atomicservice 2349 * @since 12 2350 */ 2351 getID(): string; 2352 2353 /** 2354 * Get the displayName of the TimeZone Object under the locale. 2355 * 2356 * @param { string } [locale] - the locale tag use to display timezone object's name. 2357 * @param { boolean } [isDST] - wether consider daylight saving time when display timezone object's name. 2358 * @returns { string } a string represents the display name. 2359 * @syscap SystemCapability.Global.I18n 2360 * @since 7 2361 */ 2362 /** 2363 * Get the displayName of the TimeZone Object under the locale. 2364 * 2365 * @param { string } [locale] - the locale tag use to display timezone object's name. 2366 * @param { boolean } [isDST] - wether consider daylight saving time when display timezone object's name. 2367 * @returns { string } a string represents the display name. 2368 * @syscap SystemCapability.Global.I18n 2369 * @atomicservice 2370 * @since 12 2371 */ 2372 getDisplayName(locale?: string, isDST?: boolean): string; 2373 2374 /** 2375 * Get the raw offset of the TimeZone object. 2376 * 2377 * @returns { number } a number represents the raw offset. 2378 * @syscap SystemCapability.Global.I18n 2379 * @since 7 2380 */ 2381 /** 2382 * Get the raw offset of the TimeZone object. 2383 * 2384 * @returns { number } a number represents the raw offset. 2385 * @syscap SystemCapability.Global.I18n 2386 * @crossplatform 2387 * @since 10 2388 */ 2389 /** 2390 * Get the raw offset of the TimeZone object. 2391 * 2392 * @returns { number } a number represents the raw offset. 2393 * @syscap SystemCapability.Global.I18n 2394 * @crossplatform 2395 * @atomicservice 2396 * @since 12 2397 */ 2398 getRawOffset(): number; 2399 2400 /** 2401 * Get the offset of the TimeZone object. 2402 * 2403 * @param { number } [date] - Indicates a date use to compute offset. 2404 * @returns { number } a number represents the offset with date. 2405 * @syscap SystemCapability.Global.I18n 2406 * @since 7 2407 */ 2408 /** 2409 * Get the offset of the TimeZone object. 2410 * 2411 * @param { number } [date] - Indicates a date use to compute offset. 2412 * @returns { number } a number represents the offset with date. 2413 * @syscap SystemCapability.Global.I18n 2414 * @crossplatform 2415 * @since 10 2416 */ 2417 /** 2418 * Get the offset of the TimeZone object. 2419 * 2420 * @param { number } [date] - Indicates a date use to compute offset. 2421 * @returns { number } a number represents the offset with date. 2422 * @syscap SystemCapability.Global.I18n 2423 * @crossplatform 2424 * @atomicservice 2425 * @since 12 2426 */ 2427 getOffset(date?: number): number; 2428 2429 /** 2430 * Get available TimeZone ID list. 2431 * 2432 * @returns { Array<string> } a string array represents the available TimeZone ID list. 2433 * @syscap SystemCapability.Global.I18n 2434 * @since 9 2435 */ 2436 /** 2437 * Get available TimeZone ID list. 2438 * 2439 * @returns { Array<string> } a string array represents the available TimeZone ID list. 2440 * @syscap SystemCapability.Global.I18n 2441 * @crossplatform 2442 * @since 10 2443 */ 2444 /** 2445 * Get available TimeZone ID list. 2446 * 2447 * @returns { Array<string> } a string array represents the available TimeZone ID list. 2448 * @syscap SystemCapability.Global.I18n 2449 * @crossplatform 2450 * @atomicservice 2451 * @since 12 2452 */ 2453 static getAvailableIDs(): Array<string>; 2454 2455 /** 2456 * Get available Zone City ID list. 2457 * 2458 * @returns { Array<string> } a string array represents the available Zone City ID list. 2459 * @syscap SystemCapability.Global.I18n 2460 * @since 9 2461 */ 2462 /** 2463 * Get available Zone City ID list. 2464 * 2465 * @returns { Array<string> } a string array represents the available Zone City ID list. 2466 * @syscap SystemCapability.Global.I18n 2467 * @atomicservice 2468 * @since 12 2469 */ 2470 static getAvailableZoneCityIDs(): Array<string>; 2471 2472 /** 2473 * Get City display name in a certain locale. 2474 * 2475 * @param { string } cityID - Zone City ID. 2476 * @param { string } locale - locale used to display city name. 2477 * @returns { string } a string represents the display name of City in locale. 2478 * @syscap SystemCapability.Global.I18n 2479 * @since 9 2480 */ 2481 /** 2482 * Get City display name in a certain locale. 2483 * 2484 * @param { string } cityID - Zone City ID. 2485 * @param { string } locale - locale used to display city name. 2486 * @returns { string } a string represents the display name of City in locale. 2487 * @syscap SystemCapability.Global.I18n 2488 * @atomicservice 2489 * @since 12 2490 */ 2491 static getCityDisplayName(cityID: string, locale: string): string; 2492 2493 /** 2494 * Get TimeZone Object from city ID. 2495 * 2496 * @param { string } cityID - Zone City ID. 2497 * @returns { TimeZone } a TimeZone Object from city ID. 2498 * @syscap SystemCapability.Global.I18n 2499 * @since 9 2500 */ 2501 /** 2502 * Get TimeZone Object from city ID. 2503 * 2504 * @param { string } cityID - Zone City ID. 2505 * @returns { TimeZone } a TimeZone Object from city ID. 2506 * @syscap SystemCapability.Global.I18n 2507 * @atomicservice 2508 * @since 12 2509 */ 2510 static getTimezoneFromCity(cityID: string): TimeZone; 2511 2512 /** 2513 * Get the possible time zones from the specified longitude and latitude. 2514 * 2515 * @param { number } longitude value 2516 * @param { number } latitude value 2517 * @returns { Array<TimeZone> } Returns a TimeZone array from the specified longitude and latitude. 2518 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 2519 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 2520 * @syscap SystemCapability.Global.I18n 2521 * @since 10 2522 */ 2523 2524 /** 2525 * Get the possible time zones from the specified longitude and latitude. 2526 * 2527 * @param { number } longitude value 2528 * @param { number } latitude value 2529 * @returns { Array<TimeZone> } Returns a TimeZone array from the specified longitude and latitude. 2530 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 2531 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 2532 * @syscap SystemCapability.Global.I18n 2533 * @atomicservice 2534 * @since 12 2535 */ 2536 static getTimezonesByLocation(longitude: number, latitude: number): Array<TimeZone>; 2537 } 2538 2539 /** 2540 * Provides the API for transliterate text from one format to another. 2541 * 2542 * @syscap SystemCapability.Global.I18n 2543 * @since 9 2544 */ 2545 /** 2546 * Provides the API for transliterate text from one format to another. 2547 * 2548 * @syscap SystemCapability.Global.I18n 2549 * @atomicservice 2550 * @since 12 2551 */ 2552 export class Transliterator { 2553 /** 2554 * Get a string array of all available transliterator ids. 2555 * 2556 * @returns { string[] } a string array of all available transliterator ids. 2557 * @syscap SystemCapability.Global.I18n 2558 * @since 9 2559 */ 2560 /** 2561 * Get a string array of all available transliterator ids. 2562 * 2563 * @returns { string[] } a string array of all available transliterator ids. 2564 * @syscap SystemCapability.Global.I18n 2565 * @atomicservice 2566 * @since 12 2567 */ 2568 static getAvailableIDs(): string[]; 2569 2570 /** 2571 * Get a Transliterator that is specified by id name. 2572 * 2573 * @param { string } id - specified the type of Transliterator. id is formed by source and dest. Transliterator will transliterate 2574 * the input string from source format to the dest format. For example, a Simplified Chinese to Latn 2575 * Transliterator will transform the text written in Chinese to Latn characters. 2576 * @returns { Transliterator } Transliterator that is specified by id name. 2577 * @syscap SystemCapability.Global.I18n 2578 * @since 9 2579 */ 2580 /** 2581 * Get a Transliterator that is specified by id name. 2582 * 2583 * @param { string } id - specified the type of Transliterator. id is formed by source and dest. Transliterator will transliterate 2584 * the input string from source format to the dest format. For example, a Simplified Chinese to Latn 2585 * Transliterator will transform the text written in Chinese to Latn characters. 2586 * @returns { Transliterator } Transliterator that is specified by id name. 2587 * @syscap SystemCapability.Global.I18n 2588 * @atomicservice 2589 * @since 12 2590 */ 2591 static getInstance(id: string): Transliterator; 2592 2593 /** 2594 * Transform the input text. 2595 * 2596 * @param { string } text - text to be transliterated. 2597 * @returns { string } the output text that is transliterated from source format to the dest format. 2598 * @syscap SystemCapability.Global.I18n 2599 * @since 9 2600 */ 2601 /** 2602 * Transform the input text. 2603 * 2604 * @param { string } text - text to be transliterated. 2605 * @returns { string } the output text that is transliterated from source format to the dest format. 2606 * @syscap SystemCapability.Global.I18n 2607 * @atomicservice 2608 * @since 12 2609 */ 2610 transform(text: string): string; 2611 } 2612 2613 /** 2614 * Enumerates the Normalizer modes. 2615 * 2616 * @enum { number } 2617 * @syscap SystemCapability.Global.I18n 2618 * @since 10 2619 */ 2620 /** 2621 * Enumerates the Normalizer modes. 2622 * 2623 * @enum { number } 2624 * @syscap SystemCapability.Global.I18n 2625 * @atomicservice 2626 * @since 12 2627 */ 2628 export enum NormalizerMode { 2629 /** 2630 * Normalization form C, characters are decomposed and then re-composed by canonical equivalence 2631 * 2632 * @syscap SystemCapability.Global.I18n 2633 * @since 10 2634 */ 2635 /** 2636 * Normalization form C, characters are decomposed and then re-composed by canonical equivalence 2637 * 2638 * @syscap SystemCapability.Global.I18n 2639 * @atomicservice 2640 * @since 12 2641 */ 2642 NFC = 1, 2643 /** 2644 * Normalization form D, characters are decomposed by canonical equivalence 2645 * 2646 * @syscap SystemCapability.Global.I18n 2647 * @since 10 2648 */ 2649 /** 2650 * Normalization form D, characters are decomposed by canonical equivalence 2651 * 2652 * @syscap SystemCapability.Global.I18n 2653 * @atomicservice 2654 * @since 12 2655 */ 2656 NFD = 2, 2657 /** 2658 * Normalization form KC, characters are decomposed by compatibility, then re-composed by canonical equivalence 2659 * 2660 * @syscap SystemCapability.Global.I18n 2661 * @since 10 2662 */ 2663 /** 2664 * Normalization form KC, characters are decomposed by compatibility, then re-composed by canonical equivalence 2665 * 2666 * @syscap SystemCapability.Global.I18n 2667 * @atomicservice 2668 * @since 12 2669 */ 2670 NFKC = 3, 2671 /** 2672 * Normalization form KD, characters are decomposed by compatibility 2673 * 2674 * @syscap SystemCapability.Global.I18n 2675 * @since 10 2676 */ 2677 /** 2678 * Normalization form KD, characters are decomposed by compatibility 2679 * 2680 * @syscap SystemCapability.Global.I18n 2681 * @atomicservice 2682 * @since 12 2683 */ 2684 NFKD = 4 2685 } 2686 2687 /** 2688 * Provides the API for text encoding normalization. 2689 * 2690 * @syscap SystemCapability.Global.I18n 2691 * @since 10 2692 */ 2693 /** 2694 * Provides the API for text encoding normalization. 2695 * 2696 * @syscap SystemCapability.Global.I18n 2697 * @atomicservice 2698 * @since 12 2699 */ 2700 export class Normalizer { 2701 /** 2702 * Get a Normalizer that is specified by normalize mode. 2703 * 2704 * @param { NormalizerMode } mode - specified the mode of Normalizer. It must be a valid mode. 2705 * @returns { Normalizer } Transliterator that is specified by id name. 2706 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 2707 * @syscap SystemCapability.Global.I18n 2708 * @since 10 2709 */ 2710 /** 2711 * Get a Normalizer that is specified by normalize mode. 2712 * 2713 * @param { NormalizerMode } mode - specified the mode of Normalizer. It must be a valid mode. 2714 * @returns { Normalizer } Transliterator that is specified by id name. 2715 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 2716 * @syscap SystemCapability.Global.I18n 2717 * @atomicservice 2718 * @since 12 2719 */ 2720 static getInstance(mode: NormalizerMode): Normalizer; 2721 2722 /** 2723 * Get a normalized string of specified mode. 2724 * 2725 * @param { string } text - text to normalized. 2726 * @returns { string } a normalized string from source. 2727 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 2728 * @syscap SystemCapability.Global.I18n 2729 * @since 10 2730 */ 2731 /** 2732 * Get a normalized string of specified mode. 2733 * 2734 * @param { string } text - text to normalized. 2735 * @returns { string } a normalized string from source. 2736 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 2737 * @syscap SystemCapability.Global.I18n 2738 * @atomicservice 2739 * @since 12 2740 */ 2741 normalize(text: string): string; 2742 } 2743 2744 /** 2745 * Enumerates the locale suggestion type modes. 2746 * 2747 * @enum { number } 2748 * @syscap SystemCapability.Global.I18n 2749 * @systemapi Hide this for inner system use. 2750 * @since 10 2751 */ 2752 export enum SuggestionType { 2753 /** 2754 * No correlation between language and region. 2755 * 2756 * @syscap SystemCapability.Global.I18n 2757 * @systemapi Hide this for inner system use. 2758 * @since 10 2759 */ 2760 SUGGESTION_TYPE_NONE = 0, 2761 /** 2762 * The language related to the specified region 2763 * 2764 * @syscap SystemCapability.Global.I18n 2765 * @systemapi Hide this for inner system use. 2766 * @since 10 2767 */ 2768 SUGGESTION_TYPE_RELATED = 1, 2769 /** 2770 * The region is SIM card region. 2771 * 2772 * @syscap SystemCapability.Global.I18n 2773 * @systemapi Hide this for inner system use. 2774 * @since 10 2775 */ 2776 SUGGESTION_TYPE_SIM = 2, 2777 } 2778 2779 /** 2780 * Provides the options which is used to sort the locales. 2781 * 2782 * @interface SortOptions 2783 * @syscap SystemCapability.Global.I18n 2784 * @systemapi Hide this for inner system use. 2785 * @since 10 2786 */ 2787 export interface SortOptions { 2788 /** 2789 * Locale code. 2790 * 2791 * @type { ?string } 2792 * @syscap SystemCapability.Global.I18n 2793 * @systemapi Hide this for inner system use. 2794 * @since 10 2795 */ 2796 locale?: string; 2797 2798 /** 2799 * Whether to use local names for sorting 2800 * 2801 * @type { ?boolean } 2802 * @syscap SystemCapability.Global.I18n 2803 * @systemapi Hide this for inner system use. 2804 * @since 10 2805 */ 2806 isUseLocalName?: boolean; 2807 2808 /** 2809 * Whether to put the suggested item at the top 2810 * 2811 * @type { ?boolean } 2812 * @syscap SystemCapability.Global.I18n 2813 * @systemapi Hide this for inner system use. 2814 * @since 10 2815 */ 2816 isSuggestedFirst?: boolean; 2817 } 2818 2819 /** 2820 * Provide information for a language or region 2821 * 2822 * @interface LocaleItem 2823 * @syscap SystemCapability.Global.I18n 2824 * @systemapi Hide this for inner system use. 2825 * @since 10 2826 */ 2827 export interface LocaleItem { 2828 /** 2829 * language or region id. 2830 * 2831 * @type { string } 2832 * @syscap SystemCapability.Global.I18n 2833 * @systemapi Hide this for inner system use. 2834 * @since 10 2835 */ 2836 id: string; 2837 2838 /** 2839 * The suggestion type of the language or region. 2840 * 2841 * @type { SuggestionType } 2842 * @syscap SystemCapability.Global.I18n 2843 * @systemapi Hide this for inner system use. 2844 * @since 10 2845 */ 2846 suggestionType: SuggestionType; 2847 2848 /** 2849 * The display name of the language or region in specified language 2850 * 2851 * @type { string } 2852 * @syscap SystemCapability.Global.I18n 2853 * @systemapi Hide this for inner system use. 2854 * @since 10 2855 */ 2856 displayName: string; 2857 2858 /** 2859 * The display name of the language or region in local language 2860 * @type { ?string } 2861 * @syscap SystemCapability.Global.I18n 2862 * @systemapi Hide this for inner system use. 2863 * @since 10 2864 */ 2865 localName?: string; 2866 } 2867 2868 /** 2869 * Provides the informations of one time zone city. 2870 * 2871 * @interface TimeZoneCityItem 2872 * @syscap SystemCapability.Global.I18n 2873 * @systemapi Hide this for inner system use. 2874 * @since 10 2875 */ 2876 export interface TimeZoneCityItem { 2877 /** 2878 * Time zone id. 2879 * 2880 * @type { string } 2881 * @syscap SystemCapability.Global.I18n 2882 * @systemapi Hide this for inner system use. 2883 * @since 10 2884 */ 2885 zoneId: string; 2886 2887 /** 2888 * City id. 2889 * 2890 * @type { string } 2891 * @syscap SystemCapability.Global.I18n 2892 * @systemapi Hide this for inner system use. 2893 * @since 10 2894 */ 2895 cityId: string; 2896 2897 /** 2898 * The display name of the city. 2899 * 2900 * @type { string } 2901 * @syscap SystemCapability.Global.I18n 2902 * @systemapi Hide this for inner system use. 2903 * @since 10 2904 */ 2905 cityDisplayName: string; 2906 2907 /** 2908 * The time zone offset for the city. 2909 * @type { number } 2910 * @syscap SystemCapability.Global.I18n 2911 * @systemapi Hide this for inner system use. 2912 * @since 10 2913 */ 2914 offset: number; 2915 2916 /** 2917 * The display name of the time zone for the city. 2918 * 2919 * @type { string } 2920 * @syscap SystemCapability.Global.I18n 2921 * @systemapi Hide this for inner system use. 2922 * @since 10 2923 */ 2924 zoneDisplayName: string; 2925 2926 /** 2927 * The time zone raw offset for the city. 2928 * @type { ?number } 2929 * @syscap SystemCapability.Global.I18n 2930 * @systemapi Hide this for inner system use. 2931 * @since 10 2932 */ 2933 rawOffset?: number; 2934 } 2935 2936 /** 2937 * Provide some functions for settings and startup guide to select language or region. 2938 * 2939 * @syscap SystemCapability.Global.I18n 2940 * @systemapi Hide this for inner system use. 2941 * @since 10 2942 */ 2943 export class SystemLocaleManager { 2944 /** 2945 * A constructor used to create a SystemLocaleManager object. 2946 * 2947 * @syscap SystemCapability.Global.I18n 2948 * @systemapi Hide this for inner system use. 2949 * @since 10 2950 */ 2951 constructor(); 2952 2953 /** 2954 * Obtains sorted language array for setting or startup guide app. 2955 * 2956 * @param { Array<string> } languages - The languages whose name will be sorted and displayed. 2957 * @param { SortOptions } options - Sort options for locale item. 2958 * @returns { Array<LocaleItem> } Locale Informations sorted for specified options. 2959 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 2960 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 2961 * @syscap SystemCapability.Global.I18n 2962 * @systemapi Hide this for inner system use. 2963 * @since 10 2964 */ 2965 /** 2966 * Obtains sorted language array for setting or startup guide app. 2967 * 2968 * @param { Array<string> } languages - The languages whose name will be sorted and displayed. 2969 * @param { SortOptions } options - Sort options for locale item. 2970 * @returns { Array<LocaleItem> } Locale Informations sorted for specified options. 2971 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 2972 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 2973 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 2974 * @syscap SystemCapability.Global.I18n 2975 * @systemapi Hide this for inner system use. 2976 * @since 12 2977 */ 2978 getLanguageInfoArray(languages: Array<string>, options?: SortOptions): Array<LocaleItem>; 2979 2980 /** 2981 * Obtains sorted region array for setting or startup guide app. 2982 * 2983 * @param { Array<string> } regions - The regions whose name will be sorted and displayed. 2984 * @param { SortOptions } options - Sort options for locale item. 2985 * @returns { Array<LocaleItem> } Locale Informations sorted for specified options. 2986 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 2987 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 2988 * @syscap SystemCapability.Global.I18n 2989 * @systemapi Hide this for inner system use. 2990 * @since 10 2991 */ 2992 /** 2993 * Obtains sorted region array for setting or startup guide app. 2994 * 2995 * @param { Array<string> } regions - The regions whose name will be sorted and displayed. 2996 * @param { SortOptions } options - Sort options for locale item. 2997 * @returns { Array<LocaleItem> } Locale Informations sorted for specified options. 2998 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 2999 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 3000 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 3001 * @syscap SystemCapability.Global.I18n 3002 * @systemapi Hide this for inner system use. 3003 * @since 12 3004 */ 3005 getRegionInfoArray(regions: Array<string>, options?: SortOptions): Array<LocaleItem>; 3006 3007 /** 3008 * Obtains sorted time zone city info array for showing time zone list 3009 * 3010 * @returns { Array<TimeZoneCityItem> } Time zone city information sorted by city name. 3011 * @syscap SystemCapability.Global.I18n 3012 * @systemapi Hide this for inner system use. 3013 * @since 10 3014 */ 3015 /** 3016 * Obtains sorted time zone city info array for showing time zone list 3017 * 3018 * @returns { Array<TimeZoneCityItem> } Time zone city information sorted by city name. 3019 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 3020 * @syscap SystemCapability.Global.I18n 3021 * @systemapi Hide this for inner system use. 3022 * @since 12 3023 */ 3024 static getTimeZoneCityItemArray(): Array<TimeZoneCityItem>; 3025 } 3026 3027 /** 3028 * Provides the informations of one holiday. 3029 * 3030 * @interface HolidayInfoItem 3031 * @syscap SystemCapability.Global.I18n 3032 * @since 11 3033 */ 3034 /** 3035 * Provides the informations of one holiday. 3036 * 3037 * @interface HolidayInfoItem 3038 * @syscap SystemCapability.Global.I18n 3039 * @atomicservice 3040 * @since 12 3041 */ 3042 export interface HolidayInfoItem { 3043 /** 3044 * Holiday base name. 3045 * 3046 * @type { string } 3047 * @syscap SystemCapability.Global.I18n 3048 * @since 11 3049 */ 3050 /** 3051 * Holiday base name. 3052 * 3053 * @type { string } 3054 * @syscap SystemCapability.Global.I18n 3055 * @atomicservice 3056 * @since 12 3057 */ 3058 baseName: string; 3059 3060 /** 3061 * Holiday start year. 3062 * 3063 * @type { number } 3064 * @syscap SystemCapability.Global.I18n 3065 * @since 11 3066 */ 3067 /** 3068 * Holiday start year. 3069 * 3070 * @type { number } 3071 * @syscap SystemCapability.Global.I18n 3072 * @atomicservice 3073 * @since 12 3074 */ 3075 year: number; 3076 3077 /** 3078 * Holiday start month. 3079 * 3080 * @type { number } 3081 * @syscap SystemCapability.Global.I18n 3082 * @since 11 3083 */ 3084 /** 3085 * Holiday start month. 3086 * 3087 * @type { number } 3088 * @syscap SystemCapability.Global.I18n 3089 * @atomicservice 3090 * @since 12 3091 */ 3092 month: number; 3093 3094 /** 3095 * Holiday start day. 3096 * 3097 * @type { number } 3098 * @syscap SystemCapability.Global.I18n 3099 * @since 11 3100 */ 3101 /** 3102 * Holiday start day. 3103 * 3104 * @type { number } 3105 * @syscap SystemCapability.Global.I18n 3106 * @atomicservice 3107 * @since 12 3108 */ 3109 day: number; 3110 3111 /** 3112 * Holiday local name array. 3113 * 3114 * @type { ?Array<HolidayLocalName> } 3115 * @syscap SystemCapability.Global.I18n 3116 * @since 11 3117 */ 3118 /** 3119 * Holiday local name array. 3120 * 3121 * @type { ?Array<HolidayLocalName> } 3122 * @syscap SystemCapability.Global.I18n 3123 * @atomicservice 3124 * @since 12 3125 */ 3126 localNames?: Array<HolidayLocalName>; 3127 } 3128 3129 /** 3130 * Provides the informations holiday locale name. 3131 * 3132 * @interface HolidayLocalName 3133 * @syscap SystemCapability.Global.I18n 3134 * @since 11 3135 */ 3136 /** 3137 * Provides the informations holiday locale name. 3138 * 3139 * @interface HolidayLocalName 3140 * @syscap SystemCapability.Global.I18n 3141 * @atomicservice 3142 * @since 12 3143 */ 3144 export interface HolidayLocalName { 3145 /** 3146 * Holiday locale name language id. 3147 * 3148 * @type { string } 3149 * @syscap SystemCapability.Global.I18n 3150 * @since 11 3151 */ 3152 /** 3153 * Holiday locale name language id. 3154 * 3155 * @type { string } 3156 * @syscap SystemCapability.Global.I18n 3157 * @atomicservice 3158 * @since 12 3159 */ 3160 language: string; 3161 3162 /** 3163 * Holiday local name. 3164 * 3165 * @type { string } 3166 * @syscap SystemCapability.Global.I18n 3167 * @since 11 3168 */ 3169 /** 3170 * Holiday local name. 3171 * 3172 * @type { string } 3173 * @syscap SystemCapability.Global.I18n 3174 * @atomicservice 3175 * @since 12 3176 */ 3177 name: string; 3178 } 3179 3180 /** 3181 * Provide some functions to manage holidays in a country or region. Partly follows the RFC2445 standard. 3182 * 3183 * @syscap SystemCapability.Global.I18n 3184 * @since 11 3185 */ 3186 /** 3187 * Provide some functions to manage holidays in a country or region. Partly follows the RFC2445 standard. 3188 * 3189 * @syscap SystemCapability.Global.I18n 3190 * @atomicservice 3191 * @since 12 3192 */ 3193 export class HolidayManager { 3194 /** 3195 * A constructor used to create a HolidayManager object. 3196 * 3197 * @param { String } icsPath - the path of the iCalendar format file to create HolidayManager object. 3198 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 3199 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 3200 * @syscap SystemCapability.Global.I18n 3201 * @since 11 3202 */ 3203 /** 3204 * A constructor used to create a HolidayManager object. 3205 * 3206 * @param { String } icsPath - the path of the iCalendar format file to create HolidayManager object. 3207 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 3208 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 3209 * @syscap SystemCapability.Global.I18n 3210 * @atomicservice 3211 * @since 12 3212 */ 3213 constructor(icsPath: String); 3214 3215 /** 3216 * Returns true if the given date is a holiday. If the date is not given, 3217 * the date object of current time is used. 3218 * 3219 * @param { Date } [date] - Date object whose attribute is desired. 3220 * @returns { boolean } whether the date is a holiday day. 3221 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 3222 * @syscap SystemCapability.Global.I18n 3223 * @since 11 3224 */ 3225 /** 3226 * Returns true if the given date is a holiday. If the date is not given, 3227 * the date object of current time is used. 3228 * 3229 * @param { Date } [date] - Date object whose attribute is desired. 3230 * @returns { boolean } whether the date is a holiday day. 3231 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 3232 * @syscap SystemCapability.Global.I18n 3233 * @atomicservice 3234 * @since 12 3235 */ 3236 isHoliday(date?: Date): boolean; 3237 3238 /** 3239 * Obtains holiday info array for a specified year 3240 * 3241 * @param { number } [year] - specified holiday year. If the year is not given, 3242 * the current year is used. 3243 * @returns { Array<HolidayInfoItem> } holiday information array for one year. 3244 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 3245 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 3246 * @syscap SystemCapability.Global.I18n 3247 * @since 11 3248 */ 3249 /** 3250 * Obtains holiday info array for a specified year 3251 * 3252 * @param { number } [year] - specified holiday year. If the year is not given, 3253 * the current year is used. 3254 * @returns { Array<HolidayInfoItem> } holiday information array for one year. 3255 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 3256 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 3257 * @syscap SystemCapability.Global.I18n 3258 * @atomicservice 3259 * @since 12 3260 */ 3261 getHolidayInfoItemArray(year?: number): Array<HolidayInfoItem>; 3262 } 3263 3264 /** 3265 * Provides the informations of one entity. 3266 * 3267 * @interface EntityInfoItem 3268 * @syscap SystemCapability.Global.I18n 3269 * @since 11 3270 */ 3271 /** 3272 * Provides the informations of one entity. 3273 * 3274 * @interface EntityInfoItem 3275 * @syscap SystemCapability.Global.I18n 3276 * @atomicservice 3277 * @since 12 3278 */ 3279 export interface EntityInfoItem { 3280 /** 3281 * Entity begin position. 3282 * 3283 * @type { number } 3284 * @syscap SystemCapability.Global.I18n 3285 * @since 11 3286 */ 3287 /** 3288 * Entity begin position. 3289 * 3290 * @type { number } 3291 * @syscap SystemCapability.Global.I18n 3292 * @atomicservice 3293 * @since 12 3294 */ 3295 begin: number; 3296 3297 /** 3298 * Entity end position. 3299 * 3300 * @type { number } 3301 * @syscap SystemCapability.Global.I18n 3302 * @since 11 3303 */ 3304 /** 3305 * Entity end position. 3306 * 3307 * @type { number } 3308 * @syscap SystemCapability.Global.I18n 3309 * @atomicservice 3310 * @since 12 3311 */ 3312 end: number; 3313 3314 /** 3315 * Entity type. Field values such as phone_number, date 3316 * 3317 * @type { string } 3318 * @syscap SystemCapability.Global.I18n 3319 * @since 11 3320 */ 3321 /** 3322 * Entity type. Field values such as phone_number, date 3323 * 3324 * @type { string } 3325 * @syscap SystemCapability.Global.I18n 3326 * @atomicservice 3327 * @since 12 3328 */ 3329 type: string; 3330 } 3331 3332 /** 3333 * Provide some functions to find named entity in text. 3334 * 3335 * @syscap SystemCapability.Global.I18n 3336 * @since 11 3337 */ 3338 /** 3339 * Provide some functions to find named entity in text. 3340 * 3341 * @syscap SystemCapability.Global.I18n 3342 * @atomicservice 3343 * @since 12 3344 */ 3345 export class EntityRecognizer { 3346 /** 3347 * A constructor used to create a EntityRecognizer object. 3348 * 3349 * @param { string } [locale] - specified the locale. Use current app locale by default. It must be a valid locale. 3350 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 3351 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 3352 * @syscap SystemCapability.Global.I18n 3353 * @since 11 3354 */ 3355 /** 3356 * A constructor used to create a EntityRecognizer object. 3357 * 3358 * @param { string } [locale] - specified the locale. Use current app locale by default. It must be a valid locale. 3359 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 3360 * @throws { BusinessError } 890001 - Invalid parameter. Possible causes: Parameter verification failed. 3361 * @syscap SystemCapability.Global.I18n 3362 * @atomicservice 3363 * @since 12 3364 */ 3365 constructor(locale?: string); 3366 3367 /** 3368 * Obtains holiday info array for a specified text 3369 * 3370 * @param { string } text - the text to find entities. 3371 * @returns { Array<EntityInfoItem> } entity information array found. 3372 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 3373 * @syscap SystemCapability.Global.I18n 3374 * @since 11 3375 */ 3376 /** 3377 * Obtains holiday info array for a specified text 3378 * 3379 * @param { string } text - the text to find entities. 3380 * @returns { Array<EntityInfoItem> } entity information array found. 3381 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. 3382 * @syscap SystemCapability.Global.I18n 3383 * @atomicservice 3384 * @since 12 3385 */ 3386 findEntityInfo(text: string): Array<EntityInfoItem>; 3387 } 3388} 3389export default i18n; 3390