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