1# @ohos.i18n (Internationalization)
2
3This module provides system-related or enhanced i18n capabilities, such as locale management, phone number formatting, and calendar, through supplementary i18n APIs that are not defined in ECMA 402. The [intl](js-apis-intl.md) module provides basic i18n capabilities through the standard i18n APIs defined in ECMA 402. It works with the **i18n** module to provide a complete suite of i18n capabilities.
4
5>  **NOTE**
6>
7>  - The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8>
9>  - The APIs of this module conform to the [Common Locale Data Repository (CLDR)](https://cldr.unicode.org) internationalization database. The processing result may change with CLDR evolution. API version 12 corresponds to [CLDR 42](https://cldr.unicode.org/index/downloads/cldr-42). For details about data changes, visit the official website.
10>
11>  - Since API version 11, some APIs of this module are supported in ArkTS widgets.
12
13
14## Modules to Import
15
16```ts
17import { i18n } from '@kit.LocalizationKit';
18```
19
20## System<sup>9+</sup>
21
22### getDisplayCountry<sup>9+</sup>
23
24static getDisplayCountry(country: string, locale: string, sentenceCase?: boolean): string
25
26Obtains the localized display of the text for the specified country.
27
28**Atomic service API**: This API can be used in atomic services since API version 12.
29
30**System capability**: SystemCapability.Global.I18n
31
32**Parameters**
33
34| Name         | Type     | Mandatory  | Description              |
35| ------------ | ------- | ---- | ---------------- |
36| country      | string  | Yes   | Valid country code.           |
37| locale       | string  | Yes   | Valid locale ID for the specified country.    |
38| sentenceCase | boolean | No   | Whether the first letter of the text is capitalized. The default value is **true**.|
39
40**Return value**
41
42| Type    | Description           |
43| ------ | ------------- |
44| string | Localized display of the text.|
45
46**Error codes**
47
48For details about the error codes, see [ohos.i18n Error Codes](errorcode-i18n.md) and [Universal Error Codes](../errorcode-universal.md).
49
50| ID | Error Message                  |
51| ------ | ---------------------- |
52| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
53| 890001 | Invalid parameter. Possible causes: Parameter verification failed. |
54
55> **Description**
56>
57> The error message of 890001 is subject to the actual error.
58
59**Example**
60  ```ts
61  import { BusinessError } from '@kit.BasicServicesKit';
62
63  try {
64      let displayCountry: string = i18n.System.getDisplayCountry("zh-CN", "en-GB"); // displayCountry = "China"
65  } catch (error) {
66      let err: BusinessError = error as BusinessError;
67      console.error(`call System.getDisplayCountry failed, error code: ${err.code}, message: ${err.message}.`);
68  }
69  ```
70
71### getDisplayLanguage<sup>9+</sup>
72
73static getDisplayLanguage(language: string, locale: string, sentenceCase?: boolean): string
74
75Obtains the localized display of the text for the specified language. For example, if **getDisplayLanguage ("de," "zh-Hans-CN")** is called to display German in Chinese, the output is in German.
76
77**Atomic service API**: This API can be used in atomic services since API version 11.
78
79**System capability**: SystemCapability.Global.I18n
80
81**Parameters**
82
83| Name         | Type     | Mandatory  | Description              |
84| ------------ | ------- | ---- | ---------------- |
85| language     | string  | Yes   | Valid language ID.           |
86| locale       | string  | Yes   | Valid locale ID for the specified language.    |
87| sentenceCase | boolean | No   | Whether the first letter of the text is capitalized. The default value is **true**.|
88
89**Return value**
90
91| Type    | Description           |
92| ------ | ------------- |
93| string | Localized display of the text for the specified language.|
94
95**Error codes**
96
97For details about the error codes, see [ohos.i18n Error Codes](errorcode-i18n.md) and [Universal Error Codes](../errorcode-universal.md).
98
99| ID | Error Message                  |
100| ------ | ---------------------- |
101| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
102| 890001 | Invalid parameter. Possible causes: Parameter verification failed. |
103
104**Example**
105  ```ts
106  import { BusinessError } from '@kit.BasicServicesKit';
107
108  try {
109    let displayLanguage: string = i18n.System.getDisplayLanguage("zh", "en-GB"); // Display Chinese in English.
110  } catch(error) {
111    let err: BusinessError = error as BusinessError;
112    console.error(`call System.getDisplayLanguage failed, error code: ${err.code}, message: ${err.message}.`);
113  }
114  ```
115
116### getSystemLanguages<sup>9+</sup>
117
118static getSystemLanguages(): Array&lt;string&gt;
119
120Obtains the list of system languages.
121
122Since API version 11, this API is supported in ArkTS widgets.
123
124**Atomic service API**: This API can be used in atomic services since API version 12.
125
126**System capability**: SystemCapability.Global.I18n
127
128**Return value**
129
130| Type                 | Description          |
131| ------------------- | ------------ |
132| Array&lt;string&gt; | List of the IDs of system languages.|
133
134**Example**
135  ```ts
136  let systemLanguages: Array<string> = i18n.System.getSystemLanguages(); // [ "ug", "bo", "zh-Hant", "en-Latn-US", "zh-Hans" ]
137  ```
138
139### getSystemCountries<sup>9+</sup>
140
141static getSystemCountries(language: string): Array&lt;string&gt;
142
143Obtains the list of countries and regions supported for the specified language.
144
145**Atomic service API**: This API can be used in atomic services since API version 12.
146
147**System capability**: SystemCapability.Global.I18n
148
149**Parameters**
150
151| Name     | Type    | Mandatory  | Description   |
152| -------- | ------ | ---- | ----- |
153| language | string | Yes   | Valid language ID.|
154
155**Return value**
156
157| Type                 | Description          |
158| ------------------- | ------------ |
159| Array&lt;string&gt; | List of countries or regions supported for the specified language.|
160
161**Error codes**
162
163For details about the error codes, see [ohos.i18n Error Codes](errorcode-i18n.md) and [Universal Error Codes](../errorcode-universal.md).
164
165| ID | Error Message                  |
166| ------ | ---------------------- |
167| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
168| 890001 | Invalid parameter. Possible causes: Parameter verification failed. |
169
170> **Description**
171>
172> The error message of 890001 is subject to the actual error.
173
174**Example**
175  ```ts
176  import { BusinessError } from '@kit.BasicServicesKit';
177
178  try {
179    let systemCountries: Array<string> = i18n.System.getSystemCountries('zh'); // systemCountries = [ "ZW", "YT", "YE", ..., "ER", "CN", "DE" ]
180  } catch(error) {
181    let err: BusinessError = error as BusinessError;
182    console.error(`call System.getSystemCountries failed, error code: ${err.code}, message: ${err.message}.`);
183  }
184  ```
185
186### isSuggested<sup>9+</sup>
187
188static isSuggested(language: string, region?: string): boolean
189
190Checks whether the system language matches the specified region.
191
192**Atomic service API**: This API can be used in atomic services since API version 12.
193
194**System capability**: SystemCapability.Global.I18n
195
196**Parameters**
197
198| Name     | Type    | Mandatory  | Description           |
199| -------- | ------ | ---- | ------------- |
200| language | string | Yes   | Valid language ID, for example, **zh**.|
201| region   | string | No   | Valid region ID, for example, **CN**.<br>The default value is the country or region where the SIM card is used. |
202
203**Return value**
204
205| Type     | Description                                      |
206| ------- | ---------------------------------------- |
207| boolean | The value **true** indicates that the language matches the specified country or region,<br>and the value **false** indicates the opposite.|
208
209**Error codes**
210
211For details about the error codes, see [ohos.i18n Error Codes](errorcode-i18n.md) and [Universal Error Codes](../errorcode-universal.md).
212
213| ID | Error Message                  |
214| ------ | ---------------------- |
215| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
216| 890001 | Invalid parameter. Possible causes: Parameter verification failed. |
217
218
219> **Description**
220>
221> The error message of 890001 is subject to the actual error.
222
223**Example**
224  ```ts
225  import { BusinessError } from '@kit.BasicServicesKit';
226
227  try {
228    let res: boolean = i18n.System.isSuggested('zh', 'CN');  // res = true
229  } catch(error) {
230    let err: BusinessError = error as BusinessError;
231    console.error(`call System.isSuggested failed, error code: ${err.code}, message: ${err.message}.`);
232  }
233  ```
234
235### getSystemLanguage<sup>9+</sup>
236
237static getSystemLanguage(): string
238
239Obtains the system language.
240
241**Atomic service API**: This API can be used in atomic services since API version 11.
242
243**Widget capability**: Since API version 11, this feature is supported in ArkTS widgets.
244
245**System capability**: SystemCapability.Global.I18n
246
247**Return value**
248
249| Type    | Description     |
250| ------ | ------- |
251| string | System language ID.|
252
253**Example**
254  ```ts
255  let systemLanguage: string = i18n.System.getSystemLanguage();  // systemLanguage indicates the current system language.
256  ```
257
258### getSystemRegion<sup>9+</sup>
259
260static getSystemRegion(): string
261
262Obtains the system region.
263
264**Atomic service API**: This API can be used in atomic services since API version 12.
265
266**System capability**: SystemCapability.Global.I18n
267
268**Return value**
269
270| Type    | Description     |
271| ------ | ------- |
272| string | System region ID.|
273
274**Example**
275  ```ts
276  let systemRegion: string = i18n.System.getSystemRegion(); // Obtain the current system region.
277  ```
278
279### getSystemLocale<sup>9+</sup>
280
281static getSystemLocale(): string
282
283Obtains the system locale.
284
285**Atomic service API**: This API can be used in atomic services since API version 11.
286
287**System capability**: SystemCapability.Global.I18n
288
289**Return value**
290
291| Type    | Description     |
292| ------ | ------- |
293| string | System locale ID.|
294
295**Example**
296  ```ts
297  let systemLocale: string = i18n.System.getSystemLocale();  // Obtain the current system locale.
298  ```
299
300### is24HourClock<sup>9+</sup>
301
302static is24HourClock(): boolean
303
304Checks whether the 24-hour clock is used.
305
306**Widget capability**: Since API version 11, this feature is supported in ArkTS widgets.
307
308**Atomic service API**: This API can be used in atomic services since API version 12.
309
310**System capability**: SystemCapability.Global.I18n
311
312**Return value**
313
314| Type     | Description                                      |
315| ------- | ---------------------------------------- |
316| boolean | The value **true** indicates that the 24-hour clock is used, and the value **false** indicates the opposite.|
317
318**Example**
319  ```ts
320  let is24HourClock: boolean = i18n.System.is24HourClock();  // Check whether the 24-hour clock is enabled.
321  ```
322
323
324### getPreferredLanguageList<sup>9+</sup>
325
326static getPreferredLanguageList(): Array&lt;string&gt;
327
328Obtains the list of preferred languages.
329
330**Atomic service API**: This API can be used in atomic services since API version 12.
331
332**System capability**: SystemCapability.Global.I18n
333
334**Return value**
335
336| Type                 | Description       |
337| ------------------- | --------- |
338| Array&lt;string&gt; | List of preferred languages.|
339
340**Example**
341  ```ts
342  let preferredLanguageList: Array<string> = i18n.System.getPreferredLanguageList(); // Obtain the current preferred language list.
343  ```
344
345### getFirstPreferredLanguage<sup>9+</sup>
346
347static getFirstPreferredLanguage(): string
348
349Obtains the first language in the preferred language list.
350
351**Atomic service API**: This API can be used in atomic services since API version 12.
352
353**System capability**: SystemCapability.Global.I18n
354
355**Return value**
356
357| Type    | Description            |
358| ------ | -------------- |
359| string | First language in the preferred language list.|
360
361**Example**
362  ```ts
363  let firstPreferredLanguage: string = i18n.System.getFirstPreferredLanguage();  // Obtain the first language in the preferred language list.
364  ```
365
366### setAppPreferredLanguage<sup>11+</sup>
367
368static setAppPreferredLanguage(language: string): void
369
370Sets the preferred language of the application.
371
372**Atomic service API**: This API can be used in atomic services since API version 12.
373
374**System capability**: SystemCapability.Global.I18n
375
376**Parameters**
377
378| Name     | Type    | Mandatory  | Description   |
379| -------- | ------ | ---- | ----- |
380| language | string | Yes   | Valid language ID.|
381
382**Error codes**
383
384For details about the error codes, see [ohos.i18n Error Codes](errorcode-i18n.md) and [Universal Error Codes](../errorcode-universal.md).
385
386| ID | Error Message                  |
387| ------ | ---------------------- |
388| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
389| 890001 | Invalid parameter. Possible causes: Parameter verification failed. |
390
391**Example**
392  ```ts
393  import { BusinessError } from '@kit.BasicServicesKit';
394
395  try {
396    i18n.System.setAppPreferredLanguage('zh'); // Set the preferred language of the application to zh.
397  } catch(error) {
398    let err: BusinessError = error as BusinessError;
399    console.error(`call System.setAppPreferredLanguage failed, error code: ${err.code}, message: ${err.message}.`);
400  }
401  ```
402
403### getAppPreferredLanguage<sup>9+</sup>
404
405static getAppPreferredLanguage(): string
406
407Obtains the preferred language of an application.
408
409**Atomic service API**: This API can be used in atomic services since API version 12.
410
411**System capability**: SystemCapability.Global.I18n
412
413**Return value**
414
415| Type    | Description      |
416| ------ | -------- |
417| string | Preferred language of the application.|
418
419**Example**
420  ```ts
421  let appPreferredLanguage: string = i18n.System.getAppPreferredLanguage(); // Obtain the preferred language of the application.
422  ```
423
424
425### getUsingLocalDigit<sup>9+</sup>
426
427static getUsingLocalDigit(): boolean
428
429Checks whether use of local digits is enabled.
430
431**Atomic service API**: This API can be used in atomic services since API version 12.
432
433**System capability**: SystemCapability.Global.I18n
434
435**Return value**
436
437| Type     | Description                                      |
438| ------- | ---------------------------------------- |
439| boolean | The value **true** indicates that the local digit switch is enabled, and the value **false** indicates the opposite.|
440
441**Example**
442  ```ts
443  let status: boolean = i18n.System.getUsingLocalDigit();  // Check whether the local digit switch is enabled.
444  ```
445
446
447## i18n.isRTL
448
449isRTL(locale: string): boolean
450
451Checks whether a locale uses a right-to-left (RTL) language.
452
453**Atomic service API**: This API can be used in atomic services since API version 12.
454
455**System capability**: SystemCapability.Global.I18n
456
457**Parameters**
458
459| Name   | Type    | Mandatory  | Description     |
460| ------ | ------ | ---- | ------- |
461| locale | string | Yes   | Locale ID.|
462
463**Return value**
464
465| Type     | Description                                      |
466| ------- | ---------------------------------------- |
467| boolean | The value **true** indicates that the locale uses an RTL language, and the value **false** indicates the opposite.|
468
469**Example**
470  ```ts
471  i18n.isRTL("zh-CN");// Since Chinese is not written from right to left, false is returned.
472  i18n.isRTL("ar-EG");// Since Arabic is written from right to left, true is returned.
473  ```
474
475## i18n.getCalendar<sup>8+</sup>
476
477getCalendar(locale: string, type? : string): Calendar
478
479Obtains a **Calendar** object.
480
481**Atomic service API**: This API can be used in atomic services since API version 12.
482
483**System capability**: SystemCapability.Global.I18n
484
485**Parameters**
486
487| Name   | Type    | Mandatory  | Description                                      |
488| ------ | ------ | ---- | ---------------------------------------- |
489| locale | string | Yes   | Valid locale ID, for example, **zh-Hans-CN**.                |
490| type   | string | No   | Valid calendar type. The value can be **buddhist**, **chinese**, **coptic**, **ethiopic**, **hebrew**, **gregory**, **indian**, **islamic_civil**, **islamic_tbla**, **islamic_umalqura**, **japanese**, or **persian**.<br>The default value is the default calendar type of the locale. For details, see [Calendar Setting](../../internationalization/i18n-calendar.md).|
491
492**Return value**
493
494| Type                    | Description   |
495| ---------------------- | ----- |
496| [Calendar](#calendar8) | **Calendar** object.|
497
498**Example**
499  ```ts
500  i18n.getCalendar("zh-Hans", "chinese"); // Obtain the Calendar object for the Chinese lunar calendar.
501  ```
502
503## EntityRecognizer<sup>11+</sup>
504
505### constructor<sup>11+</sup>
506
507constructor(locale?: string)
508
509Creates an **entityRecognizer** object.
510
511**Atomic service API**: This API can be used in atomic services since API version 12.
512
513**System capability**: SystemCapability.Global.I18n
514
515**Parameters**
516
517| Name | Type  | Mandatory  | Description               |
518| ---- | ---- | ---- | ----------------- |
519| locale | string | No   | Valid locale ID, for example, **zh-Hans-CN**.|
520
521**Error codes**
522
523For details about the error codes, see [ohos.i18n Error Codes](errorcode-i18n.md) and [Universal Error Codes](../errorcode-universal.md).
524
525| ID | Error Message                  |
526| ------ | ---------------------- |
527| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
528| 890001 | Invalid parameter. Possible causes: Parameter verification failed. |
529
530**Example**
531  ```ts
532  let entityRecognizer: i18n.EntityRecognizer = new i18n.EntityRecognizer("zh-CN");
533  ```
534
535### findEntityInfo<sup>11+</sup>
536
537findEntityInfo(text: string): Array&lt;EntityInfoItem&gt;
538
539Recognizes entities in text.
540
541**Atomic service API**: This API can be used in atomic services since API version 12.
542
543**System capability**: SystemCapability.Global.I18n
544
545**Parameters**
546
547| Name | Type  | Mandatory  | Description               |
548| ---- | ---- | ---- | ----------------- |
549| text | string | Yes   | Text to be recognized.|
550
551**Return value**
552
553| Type  | Description               |
554| ---- | ----------------- |
555| Array&lt;[EntityInfoItem](#entityinfoitem11)&gt; | List of entities in the text.|
556
557**Error codes**
558
559For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
560
561| ID | Error Message                  |
562| ------ | ---------------------- |
563| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
564
565**Example**
566  ```ts
567  let entityRecognizer: i18n.EntityRecognizer = new i18n.EntityRecognizer("zh-CN");
568  let text1: string = " If you have any questions, call us by phone 12345678";
569  let result1: Array<i18n.EntityInfoItem> = entityRecognizer.findEntityInfo(text1); // result1[0].type = "phone_number", result1[0].begin = 8, result1[0].end = 19
570  let text2: string = "Let's have dinner on December 1, 2023."
571  let result2: Array<i18n.EntityInfoItem> = entityRecognizer.findEntityInfo(text2); // result2[0].type = "date", result2[0].begin = 2, result2[0].end = 12
572  ```
573
574## EntityInfoItem<sup>11+</sup>
575
576Defines a list of entities.
577
578**Atomic service API**: This API can be used in atomic services since API version 12.
579
580**System capability**: SystemCapability.Global.I18n
581
582| Name | Type  | Readable  | Writable  | Description               |
583| ---- | ---- | ---- | ---- | ----------------- |
584| type | string | Yes   | Yes   | Entity type. Only phone number and date are supported.|
585| begin | number | Yes   | Yes   | Start position of an entity.|
586| end | number | Yes   | Yes   | End position of an entity.|
587
588## Calendar<sup>8+</sup>
589
590### setTime<sup>8+</sup>
591
592setTime(date: Date): void
593
594Sets the date and time for a **Calendar** object.
595
596**Atomic service API**: This API can be used in atomic services since API version 12.
597
598**System capability**: SystemCapability.Global.I18n
599
600**Parameters**
601
602| Name | Type  | Mandatory  | Description               |
603| ---- | ---- | ---- | ----------------- |
604| date | Date | Yes   | Date and time.|
605
606**Example**
607  ```ts
608  let calendar: i18n.Calendar = i18n.getCalendar("en-US", "gregory");
609  let date: Date = new Date(2021, 10, 7, 8, 0, 0, 0);
610  calendar.setTime(date);
611  ```
612
613
614### setTime<sup>8+</sup>
615
616setTime(time: number): void
617
618Sets the date and time for a **Calendar** object.
619
620**Atomic service API**: This API can be used in atomic services since API version 12.
621
622**System capability**: SystemCapability.Global.I18n
623
624**Parameters**
625
626| Name | Type    | Mandatory  | Description                                      |
627| ---- | ------ | ---- | ---------------------------------------- |
628| time | number | Yes   | Number of milliseconds that have elapsed since the Unix epoch.|
629
630**Example**
631  ```ts
632  let calendar: i18n.Calendar = i18n.getCalendar("en-US", "gregory");
633  calendar.setTime(10540800000);
634  ```
635
636### set<sup>8+</sup>
637
638set(year: number, month: number, date:number, hour?: number, minute?: number, second?: number): void
639
640Sets the year, month, day, hour, minute, and second for this **Calendar** object.
641
642**Atomic service API**: This API can be used in atomic services since API version 12.
643
644**System capability**: SystemCapability.Global.I18n
645
646**Parameters**
647
648| Name   | Type    | Mandatory  | Description    |
649| ------ | ------ | ---- | ------ |
650| year   | number | Yes   | Year to set. |
651| month  | number | Yes   | Month to set. |
652| date   | number | Yes   | Day to set. |
653| hour   | number | No   | Hour to set. The default value is the system hour.|
654| minute | number | No   | Minute to set. The default value is the system minute.|
655| second | number | No   | Second to set. The default value is the system second.|
656
657**Example**
658  ```ts
659  let calendar: i18n.Calendar = i18n.getCalendar("zh-Hans");
660  calendar.set(2021, 10, 1, 8, 0, 0); // set time to 2021.11.1 08:00:00
661  ```
662
663### setTimeZone<sup>8+</sup>
664
665setTimeZone(timezone: string): void
666
667Sets the time zone of this **Calendar** object.
668
669**Atomic service API**: This API can be used in atomic services since API version 12.
670
671**System capability**: SystemCapability.Global.I18n
672
673**Parameters**
674
675| Name     | Type    | Mandatory  | Description                       |
676| -------- | ------ | ---- | ------------------------- |
677| timezone | string | Yes   | Valid time zone ID, for example, Asia/Shanghai.|
678
679**Example**
680  ```ts
681  let calendar: i18n.Calendar = i18n.getCalendar("zh-Hans");
682  calendar.setTimeZone("Asia/Shanghai");
683  ```
684
685
686### getTimeZone<sup>8+</sup>
687
688getTimeZone(): string
689
690Obtains the time zone of this **Calendar** object.
691
692**Atomic service API**: This API can be used in atomic services since API version 12.
693
694**System capability**: SystemCapability.Global.I18n
695
696**Return value**
697
698| Type    | Description        |
699| ------ | ---------- |
700| string | Time zone ID.|
701
702**Example**
703  ```ts
704  let calendar: i18n.Calendar = i18n.getCalendar("zh-Hans");
705  calendar.setTimeZone("Asia/Shanghai");
706  let timezone: string = calendar.getTimeZone(); // timezone = "Asia/Shanghai"
707  ```
708
709
710### getFirstDayOfWeek<sup>8+</sup>
711
712getFirstDayOfWeek(): number
713
714Obtains the start day of a week for a **Calendar** object.
715
716**Atomic service API**: This API can be used in atomic services since API version 12.
717
718**System capability**: SystemCapability.Global.I18n
719
720**Return value**
721
722| Type    | Description                   |
723| ------ | --------------------- |
724| number | Start day of a week. The value **1** indicates Sunday, and the value **7** indicates Saturday.|
725
726**Example**
727  ```ts
728  let calendar: i18n.Calendar = i18n.getCalendar("en-US", "gregory");
729  let firstDayOfWeek: number = calendar.getFirstDayOfWeek(); // firstDayOfWeek = 1
730  ```
731
732
733### setFirstDayOfWeek<sup>8+</sup>
734
735setFirstDayOfWeek(value: number): void
736
737Sets the start day of a week for a **Calendar** object.
738
739**Atomic service API**: This API can be used in atomic services since API version 12.
740
741**System capability**: SystemCapability.Global.I18n
742
743**Parameters**
744
745| Name  | Type    | Mandatory  | Description                   |
746| ----- | ------ | ---- | --------------------- |
747| value | number | Yes   | Start day of a week. The value **1** indicates Sunday, and the value **7** indicates Saturday.|
748
749**Example**
750  ```ts
751  let calendar: i18n.Calendar = i18n.getCalendar("zh-Hans");
752  calendar.setFirstDayOfWeek(3);
753  let firstDayOfWeek: number = calendar.getFirstDayOfWeek(); // firstDayOfWeek = 3
754  ```
755
756### getMinimalDaysInFirstWeek<sup>8+</sup>
757
758getMinimalDaysInFirstWeek(): number
759
760Obtains the minimum number of days in the first week of a year.
761
762**Atomic service API**: This API can be used in atomic services since API version 12.
763
764**System capability**: SystemCapability.Global.I18n
765
766**Return value**
767
768| Type    | Description          |
769| ------ | ------------ |
770| number | Minimum number of days in the first week of a year.|
771
772**Example**
773  ```ts
774  let calendar: i18n.Calendar = i18n.getCalendar("zh-Hans");
775  let minimalDaysInFirstWeek: number = calendar.getMinimalDaysInFirstWeek(); // minimalDaysInFirstWeek = 1
776  ```
777
778
779### setMinimalDaysInFirstWeek<sup>8+</sup>
780
781setMinimalDaysInFirstWeek(value: number): void
782
783Sets the minimum number of days in the first week of a year.
784
785**Atomic service API**: This API can be used in atomic services since API version 12.
786
787**System capability**: SystemCapability.Global.I18n
788
789**Parameters**
790
791| Name  | Type    | Mandatory  | Description          |
792| ----- | ------ | ---- | ------------ |
793| value | number | Yes   | Minimum number of days in the first week of a year.|
794
795**Example**
796  ```ts
797  let calendar: i18n.Calendar = i18n.getCalendar("zh-Hans");
798  calendar.setMinimalDaysInFirstWeek(3);
799  let minimalDaysInFirstWeek: number = calendar.getMinimalDaysInFirstWeek(); // minimalDaysInFirstWeek = 3
800  ```
801
802
803### get<sup>8+</sup>
804
805get(field: string): number
806
807Obtains the value of the associated field in a **Calendar** object.
808
809**Atomic service API**: This API can be used in atomic services since API version 12.
810
811**System capability**: SystemCapability.Global.I18n
812
813**Parameters**
814
815| Name  | Type    | Mandatory  | Description                                      |
816| ----- | ------ | ---- | ---------------------------------------- |
817| field | string | Yes   | Associated field in a **Calendar** object. The following table lists the supported field values.|
818
819
820| Field  | Description                                      |
821| ----- | ---------------------------------------- |
822| era | Era, for example, AD or BC.|
823| year | Year.|
824| month | Month.|
825| date | Date.|
826| hour | Wall-clock hour.|
827| hour_of_day | Hour of day.|
828| minute | Minute.|
829| second | Second.|
830| millisecond | Millisecond.|
831| week_of_year | Week of year. Note that the algorithm for calculating the first week of a year varies according to regions. For example, the first seven days in a year are the first week.|
832| year_woy | Year used with the week of year field. |
833| week_of_month | Week of month.|
834| day_of_week_in_month | Day of week in month.|
835| day_of_year | Day of year.|
836| day_of_week | Day of week.|
837| milliseconds_in_day | Milliseconds in day.|
838| zone_offset | Fixed time zone offset in milliseconds (excluding DST).|
839| dst_offset | DST offset in milliseconds.|
840| dow_local | Localized day of week.|
841| extended_year | Extended year, which can be a negative number.|
842| julian_day | Julian day.|
843| is_leap_month | Whether a month is a leap month.|
844
845**Return value**
846
847| Type    | Description                                      |
848| ------ | ---------------------------------------- |
849| number | Value of the specified field. For example, if the year in the internal date of this **Calendar** object is **1990**, the **get("year")** function will return **1990**.|
850
851**Example**
852  ```ts
853  let calendar: i18n.Calendar = i18n.getCalendar("zh-Hans");
854  calendar.set(2021, 10, 1, 8, 0, 0); // set time to 2021.11.1 08:00:00
855  let hourOfDay: number = calendar.get("hour_of_day"); // hourOfDay = 8
856  ```
857
858
859### getDisplayName<sup>8+</sup>
860
861getDisplayName(locale: string): string
862
863Obtains the displayed name of the **Calendar** object for the specified locale.
864
865**Atomic service API**: This API can be used in atomic services since API version 12.
866
867**System capability**: SystemCapability.Global.I18n
868
869**Parameters**
870
871| Name   | Type    | Mandatory  | Description                                      |
872| ------ | ------ | ---- | ---------------------------------------- |
873| locale | string | Yes   | Locale ID.|
874
875**Return value**
876
877| Type    | Description                 |
878| ------ | ------------------- |
879| string | Displayed name of the **Calendar** object for the specified locale. For example, **buddhist** is displayed as **Buddhist Calendar** if the locale is **en-US**.|
880
881**Example**
882  ```ts
883  let calendar: i18n.Calendar = i18n.getCalendar("en-US", "buddhist");
884  let calendarName: string = calendar.getDisplayName("zh"); // calendarName = "Buddhist Calendar"
885  ```
886
887
888### isWeekend<sup>8+</sup>
889
890isWeekend(date?: Date): boolean
891
892Checks whether a given date is a weekend in the calendar.
893
894**Atomic service API**: This API can be used in atomic services since API version 12.
895
896**System capability**: SystemCapability.Global.I18n
897
898**Parameters**
899
900| Name | Type  | Mandatory  | Description                                      |
901| ---- | ---- | ---- | ---------------------------------------- |
902| date | Date | No   | Specified date.<br>The default value is the system date. If this parameter is left empty, the system checks whether the current date is a weekend.|
903
904**Return value**
905
906| Type     | Description                                 |
907| ------- | ----------------------------------- |
908| boolean | The value **true** indicates that the specified date is a weekend, and the value **false** indicates the opposite.|
909
910**Example**
911  ```ts
912  let calendar: i18n.Calendar = i18n.getCalendar("zh-Hans");
913  calendar.set(2021, 11, 11, 8, 0, 0); // set time to 2021.12.11 08:00:00
914  calendar.isWeekend(); // true
915  let date: Date = new Date(2011, 11, 6, 9, 0, 0);
916  calendar.isWeekend(date); // false
917  ```
918
919
920### add<sup>11+</sup>
921
922add(field: string, amount: number): void
923
924Adds or subtracts some fields in a **Calendar** object.
925
926**Atomic service API**: This API can be used in atomic services since API version 12.
927
928**System capability**: SystemCapability.Global.I18n
929
930**Parameters**
931
932| Name | Type  | Mandatory  | Description                                      |
933| ---- | ---- | ---- | ---------------------------------------- |
934| field | string | Yes   | Specified field in the **Calendar** object. The value can be any of the following: **year**, **month**, **week_of_year**, **week_of_month**, **date**, **day_of_year**, **day_of_week**, **day_of_week_in_month**, **hour**, **hour_of_day**, **minute**, **second**, **millisecond**.<br>For details about the values, see [get](#get8).|
935| amount | number | Yes   | Addition or subtraction amount.|
936
937**Error codes**
938
939For details about the error codes, see [ohos.i18n Error Codes](errorcode-i18n.md) and [Universal Error Codes](../errorcode-universal.md).
940
941| ID | Error Message                  |
942| ------ | ---------------------- |
943| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
944| 890001 | Invalid parameter. Possible causes: Parameter verification failed. |
945
946**Example**
947  ```ts
948  import { BusinessError } from '@kit.BasicServicesKit';
949
950  try {
951    let calendar: i18n.Calendar = i18n.getCalendar("zh-Hans");
952    calendar.set(2021, 11, 11, 8, 0, 0); // set time to 2021.12.11 08:00:00
953    calendar.add("year", 8); // 2021 + 8
954    let year: number = calendar.get("year"); // year = 2029
955  } catch(error) {
956    let err: BusinessError = error as BusinessError;
957    console.error(`call Calendar.add failed, error code: ${err.code}, message: ${err.message}.`);
958  }
959  ```
960
961
962### getTimeInMillis<sup>11+</sup>
963
964getTimeInMillis(): number
965
966Obtains number of milliseconds that have elapsed since the Unix epoch in the current **Calendar** object.
967
968**Atomic service API**: This API can be used in atomic services since API version 12.
969
970**System capability**: SystemCapability.Global.I18n
971
972**Return value**
973
974| Type     | Description                                 |
975| ------- | ----------------------------------- |
976| number | Number of milliseconds that have elapsed since the Unix epoch.|
977
978**Example**
979  ```ts
980  let calendar: i18n.Calendar = i18n.getCalendar("zh-Hans");
981  calendar.setTime(5000);
982  let millisecond: number = calendar.getTimeInMillis(); // millisecond = 5000
983  ```
984
985
986### compareDays<sup>11+</sup>
987
988compareDays(date: Date): number
989
990Compares the **Calendar** object and the specified date for the difference in the number of days.
991
992**Atomic service API**: This API can be used in atomic services since API version 12.
993
994**System capability**: SystemCapability.Global.I18n
995
996**Parameters**
997
998| Name | Type  | Mandatory  | Description                                      |
999| ---- | ---- | ---- | ---------------------------------------- |
1000| date | Date | Yes   | Specified date.|
1001
1002**Return value**
1003
1004| Type     | Description                                 |
1005| ------- | ----------------------------------- |
1006| number | Difference in the number of days between the calendar date and the specified date. A positive number indicates that the calendar date is earlier, and a negative number indicates the opposite.<br>The value is accurate to milliseconds. If the value is less than one day, it is considered as one day.|
1007
1008**Error codes**
1009
1010For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1011
1012| ID | Error Message                  |
1013| ------ | ---------------------- |
1014| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
1015
1016**Example**
1017  ```ts
1018  import { BusinessError } from '@kit.BasicServicesKit';
1019
1020  try {
1021    let calendar: i18n.Calendar = i18n.getCalendar("zh-Hans");
1022    calendar.setTime(5000);
1023    let date: Date = new Date(6000);
1024    let diff: number = calendar.compareDays(date); // diff = 1
1025  } catch(error) {
1026    let err: BusinessError = error as BusinessError;
1027    console.error(`call Calendar.compareDays failed, error code: ${err.code}, message: ${err.message}.`);
1028  }
1029  ```
1030
1031## PhoneNumberFormat<sup>8+</sup>
1032
1033
1034### constructor<sup>8+</sup>
1035
1036constructor(country: string, options?: PhoneNumberFormatOptions)
1037
1038Creates a **PhoneNumberFormat** object.
1039
1040**Atomic service API**: This API can be used in atomic services since API version 12.
1041
1042**System capability**: SystemCapability.Global.I18n
1043
1044**Parameters**
1045
1046| Name    | Type                                      | Mandatory  | Description              |
1047| ------- | ---------------------------------------- | ---- | ---------------- |
1048| country | string                                   | Yes   | Country or region to which the phone number to be formatted belongs.|
1049| options | [PhoneNumberFormatOptions](#phonenumberformatoptions8) | No   | Options for initializing the **PhoneNumberFormat** object. The default value is **NATIONAL**. |
1050
1051**Example**
1052  ```ts
1053  let option: i18n.PhoneNumberFormatOptions = {type: "E164"};
1054  let phoneNumberFormat: i18n.PhoneNumberFormat = new i18n.PhoneNumberFormat("CN", option);
1055  ```
1056
1057### isValidNumber<sup>8+</sup>
1058
1059isValidNumber(number: string): boolean
1060
1061Checks whether the format of the specified phone number is valid.
1062
1063**Atomic service API**: This API can be used in atomic services since API version 12.
1064
1065**System capability**: SystemCapability.Global.I18n
1066
1067**Parameters**
1068
1069| Name   | Type    | Mandatory  | Description       |
1070| ------ | ------ | ---- | --------- |
1071| number | string | Yes   | Phone number to be checked.|
1072
1073**Return value**
1074
1075| Type     | Description                                   |
1076| ------- | ------------------------------------- |
1077| boolean | The value **true** indicates that the phone number format is valid, and the value **false** indicates the opposite.|
1078
1079**Example**
1080  ```ts
1081  let phonenumberfmt: i18n.PhoneNumberFormat = new i18n.PhoneNumberFormat("CN");
1082  let isValidNumber: boolean = phonenumberfmt.isValidNumber("158****2312"); // isValidNumber = true
1083  ```
1084
1085
1086### format<sup>8+</sup>
1087
1088format(number: string): string
1089
1090Formats a phone number.
1091
1092> **Description**
1093> Formatting dialed phone numbers is supported since API version 12.
1094
1095**Atomic service API**: This API can be used in atomic services since API version 12.
1096
1097**System capability**: SystemCapability.Global.I18n
1098
1099**Parameters**
1100
1101| Name   | Type    | Mandatory  | Description        |
1102| ------ | ------ | ---- | ---------- |
1103| number | string | Yes   | Phone number to be formatted.|
1104
1105**Return value**
1106
1107| Type    | Description        |
1108| ------ | ---------- |
1109| string | Formatted phone number.|
1110
1111**Example**
1112  ```ts
1113  let phonenumberfmt: i18n.PhoneNumberFormat = new i18n.PhoneNumberFormat("CN");
1114  let formattedPhoneNumber: string = phonenumberfmt.format("158****2312"); // formattedPhoneNumber = "158 **** 2312"
1115
1116  // Format the dialed phone number.
1117  let option: i18n.PhoneNumberFormatOptions = {type: "TYPING"};
1118  let phoneNumberFmt: i18n.PhoneNumberFormat = new i18n.PhoneNumberFormat("CN", option);
1119  let phoneNumber : string = "130493";
1120  let formatResult : string = "";
1121  for (let i = 0; i < phoneNumber.length; i++) {
1122    formatResult += phoneNumber.charAt(i);
1123    formatResult = phoneNumberFmt.format(formatResult);
1124  }
1125  console.log(formatResult); // formatResult: 130 493
1126  ```
1127
1128
1129### getLocationName<sup>9+</sup>
1130
1131getLocationName(number: string, locale: string): string
1132
1133Obtains the home location of a phone number.
1134
1135**Atomic service API**: This API can be used in atomic services since API version 12.
1136
1137**System capability**: SystemCapability.Global.I18n
1138
1139**Parameters**
1140
1141| Name   | Type    | Mandatory  | Description  |
1142| ------ | ------ | ---- | ---- |
1143| number | string | Yes   | Phone number. To obtain the home location of a number in other countries/regions, you need to prefix the number with **00** and the country code.|
1144| locale | string | Yes   | Valid locale ID.|
1145
1146**Return value**
1147
1148| Type    | Description      |
1149| ------ | -------- |
1150| string | Home location of the phone number.|
1151
1152**Example**
1153  ```ts
1154  let phonenumberfmt: i18n.PhoneNumberFormat = new i18n.PhoneNumberFormat("CN");
1155  let locationName: string = phonenumberfmt.getLocationName("158****2345", "zh-CN"); // locationName = "Zhanjiang, Guangdong Province"
1156  let locName: string = phonenumberfmt.getLocationName("0039312****789", "zh-CN"); // locName = "Italy"
1157  ```
1158
1159
1160## PhoneNumberFormatOptions<sup>8+</sup>
1161
1162Options for initializing the **PhoneNumberFormat** object.
1163
1164**Atomic service API**: This API can be used in atomic services since API version 12.
1165
1166**System capability**: SystemCapability.Global.I18n
1167
1168| Name  | Type    | Readable  | Writable  | Description                                      |
1169| ---- | ------ | ---- | ---- | ---------------------------------------- |
1170| type | string | Yes   | Yes   | Type of the phone number. The value can be **E164**, **INTERNATIONAL**, **NATIONAL**, **RFC3966**, or **TYPING**.<br>- In API version 8, **type** is mandatory.<br>- In API version 9 or later, **type** is optional.<br>- **TYPING** is supported since API version 12.|
1171
1172
1173## UnitInfo<sup>8+</sup>
1174
1175Defines the measurement unit information.
1176
1177**Atomic service API**: This API can be used in atomic services since API version 12.
1178
1179**System capability**: SystemCapability.Global.I18n
1180
1181| Name           | Type    | Readable  | Writable  | Description                                      |
1182| ------------- | ------ | ---- | ---- | ---------------------------------------- |
1183| unit          | string | Yes   | Yes   | Name of the measurement unit, for example, **meter**, **inch**, or **cup**.|
1184| measureSystem | string | Yes   | Yes   | Measurement system. The value can be **SI**, **US**, or **UK**.|
1185
1186
1187## getInstance<sup>8+</sup>
1188
1189getInstance(locale?:string): IndexUtil
1190
1191Creates an **IndexUtil** object.
1192
1193**Atomic service API**: This API can be used in atomic services since API version 12.
1194
1195**System capability**: SystemCapability.Global.I18n
1196
1197**Parameters**
1198
1199| Name   | Type    | Mandatory  | Description                          |
1200| ------ | ------ | ---- | ---------------------------- |
1201| locale | string | No   | A string containing locale information, including the language, optional script, and region.<br>The default value is the system locale.|
1202
1203**Return value**
1204
1205| Type                      | Description                   |
1206| ------------------------ | --------------------- |
1207| [IndexUtil](#indexutil8) | **IndexUtil** object mapping to the **locale** object.|
1208
1209**Example**
1210  ```ts
1211  let indexUtil: i18n.IndexUtil = i18n.getInstance("zh-CN");
1212  ```
1213
1214
1215## IndexUtil<sup>8+</sup>
1216
1217**Atomic service API**: This API can be used in atomic services since API version 12.
1218
1219### getIndexList<sup>8+</sup>
1220
1221getIndexList(): Array&lt;string&gt;
1222
1223Obtains the index list of the current locale.
1224
1225**Atomic service API**: This API can be used in atomic services since API version 12.
1226
1227**System capability**: SystemCapability.Global.I18n
1228
1229**Return value**
1230
1231| Type                 | Description                |
1232| ------------------- | ------------------ |
1233| Array&lt;string&gt; | Index list of the current locale.|
1234
1235**Example**
1236  ```ts
1237  let indexUtil: i18n.IndexUtil = i18n.getInstance("zh-CN");
1238  // indexList = [ "...", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N",
1239  //              "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "..." ]
1240  let indexList: Array<string> = indexUtil.getIndexList();
1241  ```
1242
1243
1244### addLocale<sup>8+</sup>
1245
1246addLocale(locale: string): void
1247
1248Adds the index list of a new locale to the index list of the current locale to form a composite list.
1249
1250**Atomic service API**: This API can be used in atomic services since API version 12.
1251
1252**System capability**: SystemCapability.Global.I18n
1253
1254**Parameters**
1255
1256| Name   | Type    | Mandatory  | Description                          |
1257| ------ | ------ | ---- | ---------------------------- |
1258| locale | string | Yes   | A string containing locale information, including the language, optional script, and region.|
1259
1260**Example**
1261  ```ts
1262  let indexUtil: i18n.IndexUtil = i18n.getInstance("zh-CN");
1263  indexUtil.addLocale("en-US");
1264  ```
1265
1266### getIndex<sup>8+</sup>
1267
1268getIndex(text: string): string
1269
1270Obtains the index of a **text** object.
1271
1272**Atomic service API**: This API can be used in atomic services since API version 12.
1273
1274**System capability**: SystemCapability.Global.I18n
1275
1276**Parameters**
1277
1278| Name | Type    | Mandatory  | Description          |
1279| ---- | ------ | ---- | ------------ |
1280| text | string | Yes   | **text** object whose index is to be obtained.|
1281
1282**Return value**
1283
1284| Type    | Description         |
1285| ------ | ----------- |
1286| string | Index of the **text** object.|
1287
1288**Example**
1289  ```ts
1290  let indexUtil: i18n.IndexUtil = i18n.getInstance("zh-CN");
1291  let index: string = indexUtil.getIndex("hi");  // index = "H"
1292  ```
1293
1294
1295## i18n.getLineInstance<sup>8+</sup>
1296
1297getLineInstance(locale: string): BreakIterator
1298
1299Obtains a [BreakIterator](#breakiterator8) object for text segmentation.
1300
1301**Atomic service API**: This API can be used in atomic services since API version 12.
1302
1303**System capability**: SystemCapability.Global.I18n
1304
1305**Parameters**
1306
1307| Name   | Type    | Mandatory  | Description                                      |
1308| ------ | ------ | ---- | ---------------------------------------- |
1309| locale | string | Yes   | A string containing locale information, including the language, optional script, and region.<br>The [BreakIterator](#breakiterator8) object segments text according to the rules of the specified locale.|
1310
1311**Return value**
1312
1313| Type                              | Description         |
1314| -------------------------------- | ----------- |
1315| [BreakIterator](#breakiterator8) | Break iterator used for text segmentation.|
1316
1317**Example**
1318  ```ts
1319  let iterator: i18n.BreakIterator = i18n.getLineInstance("en");
1320  ```
1321
1322
1323## BreakIterator<sup>8+</sup>
1324
1325
1326### setLineBreakText<sup>8+</sup>
1327
1328setLineBreakText(text: string): void
1329
1330Sets the text to be processed by the **BreakIterator** object.
1331
1332**Atomic service API**: This API can be used in atomic services since API version 12.
1333
1334**System capability**: SystemCapability.Global.I18n
1335
1336**Parameters**
1337
1338| Name | Type    | Mandatory  | Description                     |
1339| ---- | ------ | ---- | ----------------------- |
1340| text | string | Yes   | Text to be processed by the **BreakIterator** object.|
1341
1342**Example**
1343  ```ts
1344  let iterator: i18n.BreakIterator = i18n.getLineInstance("en");
1345  iterator.setLineBreakText("Apple is my favorite fruit ."); // Set a short sentence as the text to be processed by the BreakIterator object.
1346  ```
1347
1348
1349### getLineBreakText<sup>8+</sup>
1350
1351getLineBreakText(): string
1352
1353Obtains the text being processed by the **BreakIterator** object.
1354
1355**Atomic service API**: This API can be used in atomic services since API version 12.
1356
1357**System capability**: SystemCapability.Global.I18n
1358
1359**Return value**
1360
1361| Type    | Description                    |
1362| ------ | ---------------------- |
1363| string | Text being processed by the **BreakIterator** object.|
1364
1365**Example**
1366  ```ts
1367  let iterator: i18n.BreakIterator = i18n.getLineInstance("en");
1368  iterator.setLineBreakText("Apple is my favorite fruit.");
1369  let breakText: string = iterator.getLineBreakText(); // breakText = "Apple is my favorite fruit."
1370  ```
1371
1372
1373### current<sup>8+</sup>
1374
1375current(): number
1376
1377Obtains the position of a **BreakIterator** object in the processed text.
1378
1379**Atomic service API**: This API can be used in atomic services since API version 12.
1380
1381**System capability**: SystemCapability.Global.I18n
1382
1383**Return value**
1384
1385| Type    | Description                         |
1386| ------ | --------------------------- |
1387| number | Position of the **BreakIterator** object in the text being processed.|
1388
1389**Example**
1390  ```ts
1391  let iterator: i18n.BreakIterator = i18n.getLineInstance("en");
1392  iterator.setLineBreakText("Apple is my favorite fruit.");
1393  let currentPos: number = iterator.current(); // currentPos = 0
1394  ```
1395
1396
1397### first<sup>8+</sup>
1398
1399first(): number
1400
1401Moves a **BreakIterator** object to the first break point, which is always at the beginning of the processed text.
1402
1403**Atomic service API**: This API can be used in atomic services since API version 12.
1404
1405**System capability**: SystemCapability.Global.I18n
1406
1407**Return value**
1408
1409| Type    | Description               |
1410| ------ | ----------------- |
1411| number | Offset to the first break point of the processed text.|
1412
1413**Example**
1414  ```ts
1415  let iterator: i18n.BreakIterator = i18n.getLineInstance("en");
1416  iterator.setLineBreakText("Apple is my favorite fruit.");
1417  let firstPos: number = iterator.first(); // firstPos = 0
1418  ```
1419
1420
1421### last<sup>8+</sup>
1422
1423last(): number
1424
1425Moves a **BreakIterator** object to the last break point, which is always the next position after the end of the processed text.
1426
1427**Atomic service API**: This API can be used in atomic services since API version 12.
1428
1429**System capability**: SystemCapability.Global.I18n
1430
1431**Return value**
1432
1433| Type    | Description                |
1434| ------ | ------------------ |
1435| number | Offset to the last break point of the processed text.|
1436
1437**Example**
1438  ```ts
1439  let iterator: i18n.BreakIterator = i18n.getLineInstance("en");
1440  iterator.setLineBreakText("Apple is my favorite fruit.");
1441  let lastPos: number = iterator.last(); // lastPos = 27
1442  ```
1443
1444
1445### next<sup>8+</sup>
1446
1447next(index?: number): number
1448
1449Moves the **BreakIterator** object backward by the corresponding number of break points.
1450
1451**Atomic service API**: This API can be used in atomic services since API version 12.
1452
1453**System capability**: SystemCapability.Global.I18n
1454
1455**Parameters**
1456
1457| Name  | Type    | Mandatory  | Description                                      |
1458| ----- | ------ | ---- | ---------------------------------------- |
1459| index | number | No   | Number of break points to be moved by the **BreakIterator** object.<br>A positive value indicates that the break point is moved backward by the specified number of break points, and a negative value indicates the opposite.<br>The default value is **1**.|
1460
1461**Return value**
1462
1463| Type    | Description                                      |
1464| ------ | ---------------------------------------- |
1465| number | Position of the **BreakIterator** object in the text after it is moved by the specified number of break points.<br>The value **-1** is returned if the position of the **BreakIterator** object is outside of the processed text after movement.|
1466
1467**Example**
1468  ```ts
1469  let iterator: i18n.BreakIterator = i18n.getLineInstance("en");
1470  iterator.setLineBreakText("Apple is my favorite fruit.");
1471  let pos: number = iterator.first(); // pos = 0
1472  pos = iterator.next(); // pos = 6
1473  pos = iterator.next(10); // pos = -1
1474  ```
1475
1476
1477### previous<sup>8+</sup>
1478
1479previous(): number
1480
1481Moves the **BreakIterator** object forward by one break point.
1482
1483**Atomic service API**: This API can be used in atomic services since API version 12.
1484
1485**System capability**: SystemCapability.Global.I18n
1486
1487**Return value**
1488
1489| Type    | Description                                      |
1490| ------ | ---------------------------------------- |
1491| number | Position of the **BreakIterator** object in the text after it is moved to the previous break point.<br>The value **-1** is returned if the position of the **BreakIterator** object is outside of the processed text after movement.|
1492
1493**Example**
1494  ```ts
1495  let iterator: i18n.BreakIterator = i18n.getLineInstance("en");
1496  iterator.setLineBreakText("Apple is my favorite fruit.");
1497  let pos: number = iterator.first(); // pos = 0
1498  pos = iterator.next(3); // pos = 12
1499  pos = iterator.previous(); // pos = 9
1500  ```
1501
1502
1503### following<sup>8+</sup>
1504
1505following(offset: number): number
1506
1507Moves a **BreakIterator** object to the break point following the specified position.
1508
1509**Atomic service API**: This API can be used in atomic services since API version 12.
1510
1511**System capability**: SystemCapability.Global.I18n
1512
1513**Parameters**
1514
1515| Name   | Type    | Mandatory  | Description                                      |
1516| ------ | ------ | ---- | ---------------------------------------- |
1517| offset | number | Yes   | Offset to the break point following the specified position.|
1518
1519**Return value**
1520
1521| Type    | Description                                      |
1522| ------ | ---------------------------------------- |
1523| number | Position of the **BreakIterator** object after movement. The value **-1** is returned if the position of the **BreakIterator** object is outside of the processed text after movement.|
1524
1525**Example**
1526  ```ts
1527  let iterator: i18n.BreakIterator = i18n.getLineInstance("en");
1528  iterator.setLineBreakText("Apple is my favorite fruit.");
1529  let pos: number = iterator.following(0); // pos = 6
1530  pos = iterator.following(100); // pos = -1
1531  pos = iterator.current(); // pos = 27
1532  ```
1533
1534
1535### isBoundary<sup>8+</sup>
1536
1537isBoundary(offset: number): boolean
1538
1539Checks whether the specified position is a break point.
1540
1541**Atomic service API**: This API can be used in atomic services since API version 12.
1542
1543**System capability**: SystemCapability.Global.I18n
1544
1545**Parameters**
1546
1547| Name   | Type    | Mandatory  | Description         |
1548| ------ | ------ | ---- | ----------- |
1549| offset | number | Yes   | Specified position.|
1550
1551**Return value**
1552
1553| Type     | Description                             |
1554| ------- | ------------------------------- |
1555| boolean | Offset to the specified position of the text. The value **true** is returned if the position specified by **offset** is a break point, and the value **false** is returned otherwise.<br>If **true** is returned, the **BreakIterator** object is moved to the position specified by **offset**. Otherwise, **following** is called.|
1556
1557**Example**
1558  ```ts
1559  let iterator: i18n.BreakIterator = i18n.getLineInstance("en");
1560  iterator.setLineBreakText("Apple is my favorite fruit.");
1561  let isBoundary: boolean = iterator.isBoundary(0); // isBoundary = true;
1562  isBoundary = iterator.isBoundary(5); // isBoundary = false;
1563  ```
1564
1565
1566## i18n.getTimeZone
1567
1568getTimeZone(zoneID?: string): TimeZone
1569
1570Obtains the **TimeZone** object corresponding to the specified time zone ID.
1571
1572**Atomic service API**: This API can be used in atomic services since API version 12.
1573
1574**System capability**: SystemCapability.Global.I18n
1575
1576**Parameters**
1577
1578| Name   | Type    | Mandatory  | Description   |
1579| ------ | ------ | ---- | ----- |
1580| zoneID | string | No   | Time zone ID. The default value is the system time zone.|
1581
1582**Return value**
1583
1584| Type      | Description          |
1585| -------- | ------------ |
1586| [TimeZone](#timezone) | **TimeZone** object corresponding to the time zone ID.|
1587
1588**Example**
1589  ```ts
1590  let timezone: i18n.TimeZone = i18n.getTimeZone();
1591  ```
1592
1593## TimeZone
1594
1595### getID
1596
1597getID(): string
1598
1599Obtains the ID of the specified **TimeZone** object.
1600
1601**Atomic service API**: This API can be used in atomic services since API version 12.
1602
1603**System capability**: SystemCapability.Global.I18n
1604
1605**Return value**
1606
1607| Type    | Description          |
1608| ------ | ------------ |
1609| string | Time zone ID corresponding to the **TimeZone** object.|
1610
1611**Example**
1612  ```ts
1613  let timezone: i18n.TimeZone = i18n.getTimeZone();
1614  let timezoneID: string = timezone.getID(); // timezoneID = "Asia/Shanghai"
1615  ```
1616
1617
1618### getDisplayName
1619
1620getDisplayName(locale?: string, isDST?: boolean): string
1621
1622Obtains the localized representation of a **TimeZone** object.
1623
1624**Atomic service API**: This API can be used in atomic services since API version 12.
1625
1626**System capability**: SystemCapability.Global.I18n
1627
1628**Parameters**
1629
1630| Name   | Type     | Mandatory  | Description                  |
1631| ------ | ------- | ---- | -------------------- |
1632| locale | string  | No   | A string containing locale information, including the language, optional script, and region. The default value is the system locale.               |
1633| isDST  | boolean | No   | Whether DST is considered in the localized representation of the **TimeZone** object. The default value is **false**.|
1634
1635**Return value**
1636
1637| Type    | Description           |
1638| ------ | ------------- |
1639| string | Localized display of the **TimeZone** object in the specified locale.|
1640
1641**Example**
1642  ```ts
1643  let timezone: i18n.TimeZone = i18n.getTimeZone();
1644  let timezoneName: string = timezone.getDisplayName("zh-CN", false); // timezoneName = "China Standard Time"
1645  ```
1646
1647
1648### getRawOffset
1649
1650getRawOffset(): number
1651
1652Obtains the offset between the time zone represented by a **TimeZone** object and the UTC time zone.
1653
1654**Atomic service API**: This API can be used in atomic services since API version 12.
1655
1656**System capability**: SystemCapability.Global.I18n
1657
1658**Return value**
1659
1660| Type    | Description                 |
1661| ------ | ------------------- |
1662| number | Offset between the time zone represented by a **TimeZone** object and the UTC time zone, in milliseconds.|
1663
1664**Example**
1665  ```ts
1666  let timezone: i18n.TimeZone = i18n.getTimeZone();
1667  let offset: number = timezone.getRawOffset(); // offset = 28800000
1668  ```
1669
1670
1671### getOffset
1672
1673getOffset(date?: number): number
1674
1675Obtains the offset between the time zone represented by a **TimeZone** object and the UTC time zone at a certain time.
1676
1677**Atomic service API**: This API can be used in atomic services since API version 12.
1678
1679**System capability**: SystemCapability.Global.I18n
1680
1681**Parameters**
1682
1683| Name   | Type    | Mandatory  | Description    |
1684| ------ | ------ | ---- | ------ |
1685| date | number | No   | Time for calculating the offset, in milliseconds. The default value is the system time.|
1686
1687**Return value**
1688
1689| Type    | Description                     |
1690| ------ | ----------------------- |
1691| number | Offset between the time zone represented by the **TimeZone** object and the UTC time zone at a certain time.|
1692
1693**Example**
1694  ```ts
1695  let timezone: i18n.TimeZone = i18n.getTimeZone();
1696  let offset: number = timezone.getOffset(1234567890); // offset = 28800000
1697  ```
1698
1699
1700### getAvailableIDs<sup>9+</sup>
1701
1702static getAvailableIDs(): Array&lt;string&gt;
1703
1704Obtains the list of time zone IDs supported by the system.
1705
1706**Atomic service API**: This API can be used in atomic services since API version 12.
1707
1708**System capability**: SystemCapability.Global.I18n
1709
1710**Return value**
1711
1712| Type                 | Description         |
1713| ------------------- | ----------- |
1714| Array&lt;string&gt; | List of time zone IDs supported by the system.|
1715
1716**Example**
1717  ```ts
1718  // ids = ["America/Adak", "America/Anchorage", "America/Bogota", "America/Denver", "America/Los_Angeles", "America/Montevideo", "America/Santiago", "America/Sao_Paulo", "Asia/Ashgabat", "Asia/Hovd", "Asia/Jerusalem", "Asia/Magadan", "Asia/Omsk", "Asia/Shanghai", "Asia/Tokyo", "Asia/Yerevan", "Atlantic/Cape_Verde", "Australia/Lord_Howe", "Europe/Dublin", "Europe/London", "Europe/Moscow", "Pacific/Auckland", "Pacific/Easter", "Pacific/Pago-Pago"]
1719  let ids: Array<string> = i18n.TimeZone.getAvailableIDs();
1720  ```
1721
1722
1723### getAvailableZoneCityIDs<sup>9+</sup>
1724
1725static getAvailableZoneCityIDs(): Array&lt;string&gt;
1726
1727Obtains the list of time zone city IDs supported by the system.
1728
1729**Atomic service API**: This API can be used in atomic services since API version 12.
1730
1731**System capability**: SystemCapability.Global.I18n
1732
1733**Return value**
1734
1735| Type                 | Description           |
1736| ------------------- | ------------- |
1737| Array&lt;string&gt; | List of time zone city IDs supported by the system.|
1738
1739**Example**
1740  ```ts
1741  // cityIDs = ["Auckland", "Magadan", "Lord Howe Island", "Tokyo", "Shanghai", "Hovd", "Omsk", "Ashgabat", "Yerevan", "Moscow", "Tel Aviv", "Dublin", "London", "Praia", "Montevideo", "Brasília", "Santiago", "Bogotá", "Easter Island", "Salt Lake City", "Los Angeles", "Anchorage", "Adak", "Pago Pago"]
1742  let cityIDs: Array<string> = i18n.TimeZone.getAvailableZoneCityIDs();
1743  ```
1744
1745### getCityDisplayName<sup>9+</sup>
1746
1747static getCityDisplayName(cityID: string, locale: string): string
1748
1749Obtains the localized representation of a time zone city in the specified locale.
1750
1751**Atomic service API**: This API can be used in atomic services since API version 12.
1752
1753**System capability**: SystemCapability.Global.I18n
1754
1755**Parameters**
1756
1757| Name   | Type    | Mandatory  | Description    |
1758| ------ | ------ | ---- | ------ |
1759| cityID | string | Yes   | Time zone city ID.|
1760| locale | string | Yes   | A string containing locale information, including the language, optional script, and region. |
1761
1762**Return value**
1763
1764| Type    | Description                |
1765| ------ | ------------------ |
1766| string | Localized display of the time zone city in the specified locale.|
1767
1768**Example**
1769  ```ts
1770  let displayName: string = i18n.TimeZone.getCityDisplayName("Shanghai", "zh-CN"); // displayName = "Shanghai (China)"
1771  ```
1772
1773
1774### getTimezoneFromCity<sup>9+</sup>
1775
1776static getTimezoneFromCity(cityID: string): TimeZone
1777
1778Obtains the **TimeZone** object corresponding to the specified time zone city ID.
1779
1780**Atomic service API**: This API can be used in atomic services since API version 12.
1781
1782**System capability**: SystemCapability.Global.I18n
1783
1784**Parameters**
1785
1786| Name   | Type    | Mandatory  | Description    |
1787| ------ | ------ | ---- | ------ |
1788| cityID | string | Yes   | Time zone city ID.|
1789
1790**Return value**
1791
1792| Type      | Description         |
1793| -------- | ----------- |
1794| TimeZone | **TimeZone** object corresponding to the specified time zone city ID.|
1795
1796**Example**
1797  ```ts
1798  let timezone: i18n.TimeZone = i18n.TimeZone.getTimezoneFromCity("Shanghai");
1799  ```
1800
1801### getTimezonesByLocation<sup>10+</sup>
1802
1803static getTimezonesByLocation(longitude: number, latitude: number): Array&lt;TimeZone&gt;
1804
1805Creates an array of **TimeZone** objects corresponding to the specified longitude and latitude.
1806
1807**Atomic service API**: This API can be used in atomic services since API version 12.
1808
1809**System capability**: SystemCapability.Global.I18n
1810
1811**Parameters**
1812
1813| Name    | Type    | Mandatory  | Description    |
1814| --------- | ------ | ---- | ------ |
1815| longitude | number | Yes   | Longitude. The value range is [-180, 179.9). A positive value is used for east longitude and a negative value is used for west longitude.|
1816| latitude  | number | Yes   | Latitude. The value range is [-90, 89.9). A positive value is used for north latitude and a negative value is used for south latitude.|
1817
1818**Return value**
1819
1820| Type      | Description         |
1821| -------- | ----------- |
1822| Array&lt;[TimeZone](#timezone)&gt; | **TimeZone** object array.|
1823
1824**Error codes**
1825
1826For details about the error codes, see [ohos.i18n Error Codes](errorcode-i18n.md) and [Universal Error Codes](../errorcode-universal.md).
1827
1828| ID | Error Message                  |
1829| ------ | ---------------------- |
1830| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
1831| 890001 | Invalid parameter. Possible causes: Parameter verification failed. |
1832
1833
1834> **Description**
1835>
1836> The error message of 890001 is subject to the actual error.
1837
1838**Example**
1839  ```ts
1840  let timezoneArray: Array<i18n.TimeZone> = i18n.TimeZone.getTimezonesByLocation(-118.1, 34.0);
1841  for (let i = 0; i < timezoneArray.length; i++) {
1842      let tzId: string = timezoneArray[i].getID();
1843  }
1844  ```
1845
1846
1847## Transliterator<sup>9+</sup>
1848
1849
1850### getAvailableIDs<sup>9+</sup>
1851
1852static getAvailableIDs(): string[]
1853
1854Obtains a list of IDs supported by the **Transliterator** object.
1855
1856**Atomic service API**: This API can be used in atomic services since API version 12.
1857
1858**System capability**: SystemCapability.Global.I18n
1859
1860**Return value**
1861
1862| Type      | Description        |
1863| -------- | ---------- |
1864| string[] | List of IDs supported by the **Transliterator** object.|
1865
1866**Example**
1867  ```ts
1868  // A total of 742 IDs are supported. One ID is comprised of two parts separated by a hyphen (-) in the format of source-destination. For example, in **ids = ["Han-Latin","Latin-ASCII", "Amharic-Latin/BGN","Accents-Any", ...]**, **Han-Latin** indicates conversion from Chinese to Latin, and **Amharic-Latin** indicates conversion from Amharic to Latin.
1869  // For more information, see ISO-15924.
1870  let ids: string[] = i18n.Transliterator.getAvailableIDs();
1871  ```
1872
1873
1874### getInstance<sup>9+</sup>
1875
1876static getInstance(id: string): Transliterator
1877
1878Creates a **Transliterator** object.
1879
1880**Atomic service API**: This API can be used in atomic services since API version 12.
1881
1882**System capability**: SystemCapability.Global.I18n
1883
1884**Parameters**
1885
1886| Name | Type    | Mandatory  | Description      |
1887| ---- | ------ | ---- | -------- |
1888| id   | string | Yes   | ID supported by the **Transliterator** object.|
1889
1890**Return value**
1891
1892| Type                                | Description   |
1893| ---------------------------------- | ----- |
1894| [Transliterator](#transliterator9) | **Transliterator** object.|
1895
1896**Example**
1897  ```ts
1898  let transliterator: i18n.Transliterator = i18n.Transliterator.getInstance("Any-Latn");
1899  ```
1900
1901
1902### transform<sup>9+</sup>
1903
1904transform(text: string): string
1905
1906Converts the input string from the source format to the target format.
1907
1908**Atomic service API**: This API can be used in atomic services since API version 12.
1909
1910**System capability**: SystemCapability.Global.I18n
1911
1912**Parameters**
1913
1914| Name | Type    | Mandatory  | Description    |
1915| ---- | ------ | ---- | ------ |
1916| text | string | Yes   | Input string.|
1917
1918**Return value**
1919
1920| Type    | Description      |
1921| ------ | -------- |
1922| string | Target string.|
1923
1924**Example**
1925  ```ts
1926  let transliterator: i18n.Transliterator = i18n.Transliterator.getInstance("Any-Latn");
1927  let res: string = transliterator.transform("China"); // res = "zhōng guó"
1928  ```
1929
1930
1931## Unicode<sup>9+</sup>
1932
1933**Atomic service API**: This API can be used in atomic services since API version 12.
1934
1935### isDigit<sup>9+</sup>
1936
1937static isDigit(char: string): boolean
1938
1939Checks whether the input string is composed of digits.
1940
1941**Atomic service API**: This API can be used in atomic services since API version 12.
1942
1943**System capability**: SystemCapability.Global.I18n
1944
1945**Parameters**
1946
1947| Name | Type    | Mandatory  | Description   |
1948| ---- | ------ | ---- | ----- |
1949| char | string | Yes   | Input string.|
1950
1951**Return value**
1952
1953| Type     | Description                                  |
1954| ------- | ------------------------------------ |
1955| boolean | The value **true** indicates that the input character is a digit, and the value **false** indicates the opposite.|
1956
1957**Example**
1958  ```ts
1959  let isdigit: boolean = i18n.Unicode.isDigit("1");  // isdigit = true
1960  ```
1961
1962
1963### isSpaceChar<sup>9+</sup>
1964
1965static isSpaceChar(char: string): boolean
1966
1967Checks whether the input character is a space.
1968
1969**Atomic service API**: This API can be used in atomic services since API version 12.
1970
1971**System capability**: SystemCapability.Global.I18n
1972
1973**Parameters**
1974
1975| Name | Type    | Mandatory  | Description   |
1976| ---- | ------ | ---- | ----- |
1977| char | string | Yes   | Input string.|
1978
1979**Return value**
1980
1981| Type     | Description                                    |
1982| ------- | -------------------------------------- |
1983| boolean | The value **true** indicates that the input character is a space, and the value **false** indicates the opposite.|
1984
1985**Example**
1986  ```ts
1987  let isspacechar: boolean = i18n.Unicode.isSpaceChar("a");  // isspacechar = false
1988  ```
1989
1990
1991### isWhitespace<sup>9+</sup>
1992
1993static isWhitespace(char: string): boolean
1994
1995Checks whether the input character is a white space.
1996
1997**Atomic service API**: This API can be used in atomic services since API version 12.
1998
1999**System capability**: SystemCapability.Global.I18n
2000
2001**Parameters**
2002
2003| Name | Type    | Mandatory  | Description   |
2004| ---- | ------ | ---- | ----- |
2005| char | string | Yes   | String obtained.|
2006
2007**Return value**
2008
2009| Type     | Description                                    |
2010| ------- | -------------------------------------- |
2011| boolean | The value **true** indicates that the input character is a white space, and the value **false** indicates the opposite.|
2012
2013**Example**
2014  ```ts
2015  let iswhitespace: boolean = i18n.Unicode.isWhitespace("a");  // iswhitespace = false
2016  ```
2017
2018
2019### isRTL<sup>9+</sup>
2020
2021static isRTL(char: string): boolean
2022
2023Checks whether the input character is of the right to left (RTL) language.
2024
2025**Atomic service API**: This API can be used in atomic services since API version 12.
2026
2027**System capability**: SystemCapability.Global.I18n
2028
2029**Parameters**
2030
2031| Name | Type    | Mandatory  | Description   |
2032| ---- | ------ | ---- | ----- |
2033| char | string | Yes   | Input character.|
2034
2035**Return value**
2036
2037| Type     | Description                                      |
2038| ------- | ---------------------------------------- |
2039| boolean | The value **true** indicates that the input character is of the RTL language, and the value **false** indicates the opposite.|
2040
2041**Example**
2042  ```ts
2043  let isrtl: boolean = i18n.Unicode.isRTL("a");  // isrtl = false
2044  ```
2045
2046
2047### isIdeograph<sup>9+</sup>
2048
2049static isIdeograph(char: string): boolean
2050
2051Checks whether the input character is an ideographic character.
2052
2053**Atomic service API**: This API can be used in atomic services since API version 12.
2054
2055**System capability**: SystemCapability.Global.I18n
2056
2057**Parameters**
2058
2059| Name | Type    | Mandatory  | Description   |
2060| ---- | ------ | ---- | ----- |
2061| char | string | Yes   | Input character.|
2062
2063**Return value**
2064
2065| Type     | Description                                      |
2066| ------- | ---------------------------------------- |
2067| boolean | The value **true** indicates that the input character is an ideographic character, and the value **false** indicates the opposite.|
2068
2069**Example**
2070  ```ts
2071  let isideograph: boolean = i18n.Unicode.isIdeograph("a");  // isideograph = false
2072  ```
2073
2074
2075### isLetter<sup>9+</sup>
2076
2077static isLetter(char: string): boolean
2078
2079Checks whether the input character is a letter.
2080
2081**Atomic service API**: This API can be used in atomic services since API version 12.
2082
2083**System capability**: SystemCapability.Global.I18n
2084
2085**Parameters**
2086
2087| Name | Type    | Mandatory  | Description   |
2088| ---- | ------ | ---- | ----- |
2089| char | string | Yes   | Input character.|
2090
2091**Return value**
2092
2093| Type     | Description                                  |
2094| ------- | ------------------------------------ |
2095| boolean | The value **true** indicates that the input character is a letter, and the value **false** indicates the opposite.|
2096
2097**Example**
2098  ```ts
2099  let isletter: boolean = i18n.Unicode.isLetter("a");  // isletter = true
2100  ```
2101
2102
2103### isLowerCase<sup>9+</sup>
2104
2105static isLowerCase(char: string): boolean
2106
2107Checks whether the input character is a lowercase letter.
2108
2109**Atomic service API**: This API can be used in atomic services since API version 12.
2110
2111**System capability**: SystemCapability.Global.I18n
2112
2113**Parameters**
2114
2115| Name | Type    | Mandatory  | Description   |
2116| ---- | ------ | ---- | ----- |
2117| char | string | Yes   | Input character.|
2118
2119**Return value**
2120
2121| Type     | Description                                      |
2122| ------- | ---------------------------------------- |
2123| boolean | The value **true** indicates that the input character is a lowercase letter, and the value **false** indicates the opposite.|
2124
2125**Example**
2126  ```ts
2127  let islowercase: boolean = i18n.Unicode.isLowerCase("a");  // islowercase = true
2128  ```
2129
2130
2131### isUpperCase<sup>9+</sup>
2132
2133static isUpperCase(char: string): boolean
2134
2135Checks whether the input character is an uppercase letter.
2136
2137**Atomic service API**: This API can be used in atomic services since API version 12.
2138
2139**System capability**: SystemCapability.Global.I18n
2140
2141**Parameters**
2142
2143| Name | Type    | Mandatory  | Description   |
2144| ---- | ------ | ---- | ----- |
2145| char | string | Yes   | Input character.|
2146
2147**Return value**
2148
2149| Type     | Description                                      |
2150| ------- | ---------------------------------------- |
2151| boolean | The value **true** indicates that the input character is an uppercase letter, and the value **false** indicates the opposite.|
2152
2153**Example**
2154  ```ts
2155  let isuppercase: boolean = i18n.Unicode.isUpperCase("a");  // isuppercase = false
2156  ```
2157
2158
2159### getType<sup>9+</sup>
2160
2161static getType(char: string): string
2162
2163Obtains the type of the input string.
2164
2165**Atomic service API**: This API can be used in atomic services since API version 12.
2166
2167**System capability**: SystemCapability.Global.I18n
2168
2169**Parameters**
2170
2171| Name | Type    | Mandatory  | Description   |
2172| ---- | ------ | ---- | ----- |
2173| char | string | Yes   | Input character.|
2174
2175**Return value**
2176
2177| Type    | Description         |
2178| ------ | ----------- |
2179| string | Type of the input character.|
2180
2181The following table lists only the common types. For more details, see the Unicode Standard.
2182
2183| Name| Value| Description|
2184| ---- | -------- | ---------- |
2185| U_UNASSIGNED | U_UNASSIGNED | Non-category for unassigned and non-character code points.|
2186| U_GENERAL_OTHER_TYPES | U_GENERAL_OTHER_TYPES | Same as **U_UNASSIGNED**.|
2187| U_UPPERCASE_LETTER | U_UPPERCASE_LETTER | Uppercase letter.|
2188| U_LOWERCASE_LETTER | U_LOWERCASE_LETTER | Lowercase letter. |
2189| U_TITLECASE_LETTER | U_TITLECASE_LETTER | Title case letter.|
2190| U_MODIFIER_LETTER | U_MODIFIER_LETTER | Modifier letter.|
2191| U_OTHER_LETTER | U_OTHER_LETTER | Letters other than the uppercase letter, lowercase letter, title case letter, and modifier letter.|
2192| U_NON_SPACING_MARK | U_NON_SPACING_MARK | Non-spacing mark, such as the accent symbol **'** and the variable symbol **#**.|
2193| U_ENCLOSING_MARK | U_ENCLOSING_MARK | Enclosing mark, for example, a circle or a box.|
2194| U_COMBINING_SPACING_MARK | U_COMBINING_SPACING_MARK | Spacing mark, for example, the vowel symbol **[]**.|
2195| U_DECIMAL_DIGIT_NUMBER | U_DECIMAL_DIGIT_NUMBER | Decimal number.|
2196| U_LETTER_NUMBER | U_LETTER_NUMBER | Letter and number (including Roman numeral).|
2197| U_OTHER_NUMBER | U_OTHER_NUMBER | Other numbers, which are used as encryption symbols, marker symbols, or non-Arabic numerals, such as **@**, **#**, **(1)**, and **①**.|
2198| U_SPACE_SEPARATOR | U_SPACE_SEPARATOR | Space separator, for example, a space character, uninterrupted space character, or space character with a fixed width.|
2199| U_LINE_SEPARATOR | U_LINE_SEPARATOR | Line separator.|
2200| U_PARAGRAPH_SEPARATOR | U_PARAGRAPH_SEPARATOR | Paragraph separator.|
2201| U_CONTROL_CHAR | U_CONTROL_CHAR | Control character.|
2202| U_FORMAT_CHAR | U_FORMAT_CHAR | Format character.|
2203| U_PRIVATE_USE_CHAR | U_PRIVATE_USE_CHAR | Privately used character, for example, a company logo.|
2204| U_SURROGATE | U_SURROGATE | Surrogate, which is used to represent supplementary characters in UTF-16.|
2205| U_DASH_PUNCTUATION | U_DASH_PUNCTUATION | Dash punctuation.|
2206| U_START_PUNCTUATION | U_START_PUNCTUATION | Start punctuation, for example, the left parenthesis.|
2207| U_END_PUNCTUATION | U_END_PUNCTUATION | End punctuation, for example, the right parenthesis.|
2208| U_INITIAL_PUNCTUATION | U_INITIAL_PUNCTUATION | Initial punctuation, for example, the left double quotation mark or left single quotation mark.|
2209| U_FINAL_PUNCTUATION | U_FINAL_PUNCTUATION | Final punctuation, for example, the right double quotation mark or right single quotation mark.|
2210| U_CONNECTOR_PUNCTUATION | U_CONNECTOR_PUNCTUATION | Connector punctuation.|
2211| U_OTHER_PUNCTUATION | U_OTHER_PUNCTUATION | Other punctuations.|
2212| U_MATH_SYMBOL | U_MATH_SYMBOL | Mathematical symbol.|
2213| U_CURRENCY_SYMBOL | U_CURRENCY_SYMBOL | Currency symbol.|
2214| U_MODIFIER_SYMBOL | U_MODIFIER_SYMBOL | Modifier symbol.|
2215| U_OTHER_SYMBOL | U_OTHER_SYMBOL | Other symbols.|
2216
2217**Example**
2218  ```ts
2219  let type: string = i18n.Unicode.getType("a"); // type = "U_LOWERCASE_LETTER"
2220  ```
2221
2222## I18NUtil<sup>9+</sup>
2223
2224
2225### unitConvert<sup>9+</sup>
2226
2227static unitConvert(fromUnit: UnitInfo, toUnit: UnitInfo, value: number, locale: string, style?: string): string
2228
2229Converts one measurement unit into another and formats the unit based on the specified locale and style.
2230
2231**Atomic service API**: This API can be used in atomic services since API version 12.
2232
2233**System capability**: SystemCapability.Global.I18n
2234
2235**Parameters**
2236
2237| Name     | Type                    | Mandatory  | Description                                      |
2238| -------- | ---------------------- | ---- | ---------------------------------------- |
2239| fromUnit | [UnitInfo](#unitinfo8) | Yes   | Measurement unit to be converted.                                |
2240| toUnit   | [UnitInfo](#unitinfo8) | Yes   | Measurement unit to be converted to.                                |
2241| value    | number                 | Yes   | Value of the measurement unit to be converted.                            |
2242| locale   | string                 | Yes   | A string containing locale information, including the language, optional script, and region, for example, **zh-Hans-CN**.               |
2243| style    | string                 | No   | Style used for formatting. The value can be **long**, **short**, or **narrow**. The default value is **short**.<br>For details about the meaning or display effect of different values, see [Number and Unit of Measurement Formatting](../../internationalization/i18n-numbers-weights-measures.md).|
2244
2245**Return value**
2246
2247| Type    | Description                     |
2248| ------ | ----------------------- |
2249| string | String obtained after formatting based on the measurement unit specified by **toUnit**.|
2250
2251**Example**
2252  ```ts
2253  let fromUnit: i18n.UnitInfo = {unit: "cup", measureSystem: "US"};
2254  let toUnit: i18n.UnitInfo = {unit: "liter", measureSystem: "SI"};
2255  let res: string = i18n.I18NUtil.unitConvert(fromUnit, toUnit, 1000, "en-US", "long"); // res = 236.588 liters
2256  ```
2257
2258### getDateOrder<sup>9+</sup>
2259
2260static getDateOrder(locale: string): string
2261
2262Obtains the sequence of the year, month, and day in the specified locale.
2263
2264**Atomic service API**: This API can be used in atomic services since API version 12.
2265
2266**System capability**: SystemCapability.Global.I18n
2267
2268**Parameters**
2269
2270| Name   | Type    | Mandatory  | Description                       |
2271| ------ | ------ | ---- | ------------------------- |
2272| locale | string | Yes   | A string containing locale information, including the language, optional script, and region, for example, **zh-Hans-CN**.|
2273
2274**Return value**
2275
2276| Type    | Description                 |
2277| ------ | ------------------- |
2278| string | Sequence of the year, month, and day in the locale.|
2279
2280**Example**
2281  ```ts
2282  let order: string = i18n.I18NUtil.getDateOrder("zh-CN");  // order = "y-L-d"
2283  ```
2284
2285
2286### getTimePeriodName<sup>11+</sup>
2287
2288static getTimePeriodName(hour:number, locale?: string): string
2289
2290Obtains the localized expression for the specified time of the specified locale.
2291
2292**Atomic service API**: This API can be used in atomic services since API version 12.
2293
2294**System capability**: SystemCapability.Global.I18n
2295
2296**Parameters**
2297
2298| Name   | Type    | Mandatory  | Description                       |
2299| ------ | ------ | ---- | ------------------------- |
2300| hour | number | Yes   | Specified time, for example, **16**.|
2301| locale | string | No   | A string containing locale information, including the language, optional script, and region, for example, **zh-Hans-CN**.<br>The default value is the current locale.|
2302
2303**Return value**
2304
2305| Type    | Description                 |
2306| ------ | ------------------- |
2307| string | Localized expression for the specified time of the specified locale.|
2308
2309**Error codes**
2310
2311For details about the error codes, see [ohos.i18n Error Codes](errorcode-i18n.md) and [Universal Error Codes](../errorcode-universal.md).
2312
2313| ID | Error Message                  |
2314| ------ | ---------------------- |
2315| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
2316| 890001 | Invalid parameter. Possible causes: Parameter verification failed. |
2317
2318**Example**
2319  ```ts
2320  import { BusinessError } from '@kit.BasicServicesKit';
2321
2322  try {
2323    let name: string = i18n.I18NUtil.getTimePeriodName(2, "zh-CN");  // name = "a.m."
2324  } catch(error) {
2325    let err: BusinessError = error as BusinessError;
2326    console.error(`call I18NUtil.getTimePeriodName failed, error code: ${err.code}, message: ${err.message}.`);
2327  }
2328  ```
2329
2330### getBestMatchLocale<sup>12+</sup>
2331
2332static getBestMatchLocale(locale: string, localeList: string[]): string
2333
2334Obtains the locale that best matches a region from the specified locale list.
2335
2336**Atomic service API**: This API can be used in atomic services since API version 12.
2337
2338**System capability**: SystemCapability.Global.I18n
2339
2340**Parameters**
2341
2342| Name   | Type    | Mandatory  | Description                       |
2343| ------ | ------ | ---- | ------------------------- |
2344| locale | string | Yes   | Locale ID, for example, **zh-Hans-CN**.|
2345| localeList | string[] | Yes  | Locale ID list.|
2346
2347**Return value**
2348
2349| Type    | Description                 |
2350| ------ | ------------------- |
2351| string | ID of the locale that best matches a region. If no matching locale is found, an empty string is returned.|
2352
2353**Error codes**
2354
2355For details about the error codes, see [ohos.i18n Error Codes](errorcode-i18n.md) and [Universal Error Codes](../errorcode-universal.md).
2356
2357| ID | Error Message                  |
2358| ------ | ---------------------- |
2359| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
2360| 890001 | Invalid parameter. Possible causes: Parameter verification failed. |
2361
2362**Example**
2363
2364  ```ts
2365  import { BusinessError } from '@kit.BasicServicesKit';
2366
2367  try {
2368    let matchedLocaleId: string = i18n.I18NUtil.getBestMatchLocale("zh-Hans-CN", ["en-Latn-US", "en-GB", "zh-Hant-CN", "zh-Hans-MO"]);  // matchedLocaleId = "zh-Hans-MO"
2369  } catch(error) {
2370    let err: BusinessError = error as BusinessError;
2371    console.error(`call I18NUtil.getBestMatchLocale failed, error code: ${err.code}, message: ${err.message}.`);
2372  }
2373  ```
2374
2375### getThreeLetterLanguage<sup>12+</sup>
2376
2377static getThreeLetterLanguage(locale: string): string
2378
2379Converts a language code from two letters to three letters.<br>For example, the two-letter language code of Chinese is **zh**, and the corresponding three-letter language code is **zho**. For details, see [ISO 639](https://www.iso.org/iso-639-language-code).
2380
2381**Atomic service API**: This API can be used in atomic services since API version 12.
2382
2383**System capability**: SystemCapability.Global.I18n
2384
2385**Parameters**
2386
2387| Name| Type  | Mandatory| Description                    |
2388| ------ | ------ | ---- | ------------------------ |
2389| locale | string | Yes  | Two-letter code of the language to be converted, for example, **zh**.|
2390
2391**Error codes**
2392
2393For details about the error codes, see [ohos.i18n Error Codes](errorcode-i18n.md) and [Universal Error Codes](../errorcode-universal.md).
2394
2395| ID| Error Message                                                    |
2396| -------- | ------------------------------------------------------------ |
2397| 401      | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
2398| 890001   | Invalid parameter. Possible causes: Parameter verification failed. |
2399
2400**Example**
2401
2402  ```ts
2403  import { BusinessError } from '@kit.BasicServicesKit';
2404
2405  try {
2406    let language : string = i18n.I18NUtil.getThreeLetterLanguage('zh')  // zho
2407  } catch(error) {
2408    console.error(`call I18NUtil.getThreeLetterLanguage failed, error code: ${error.code}, message: ${error.message}.`);
2409  }
2410  ```
2411
2412### getThreeLetterRegion<sup>12+</sup>
2413
2414static getThreeLetterRegion(locale: string): string
2415
2416Converts a country/region code from two letters to three letters.<br>For example, the two-letter country/region code of China is **CN**, and the three-letter country/region code is **CHN**. For details, see [ISO 3166](https://www.iso.org/iso-3166-country-codes.html).
2417
2418**Atomic service API**: This API can be used in atomic services since API version 12.
2419
2420**System capability**: SystemCapability.Global.I18n
2421
2422**Parameters**
2423
2424| Name| Type  | Mandatory| Description                    |
2425| ------ | ------ | ---- | ------------------------ |
2426| locale | string | Yes  | Two-letter country/region code to be converted, for example, **CN**.|
2427
2428**Error codes**
2429
2430For details about the error codes, see [ohos.i18n Error Codes](errorcode-i18n.md) and [Universal Error Codes](../errorcode-universal.md).
2431
2432| ID| Error Message                                                    |
2433| -------- | ------------------------------------------------------------ |
2434| 401      | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
2435| 890001   | Invalid parameter. Possible causes: Parameter verification failed. |
2436
2437**Example**
2438
2439  ```ts
2440  import { BusinessError } from '@kit.BasicServicesKit';
2441
2442  try {
2443    let region : string = i18n.I18NUtil.getThreeLetterRegion('CN')  // CHN
2444  } catch(error) {
2445    console.error(`call I18NUtil.getThreeLetterRegion failed, error code: ${error.code}, message: ${error.message}.`);
2446  }
2447  ```
2448
2449## Normalizer<sup>10+</sup>
2450
2451
2452### getInstance<sup>10+</sup>
2453
2454static getInstance(mode: NormalizerMode): Normalizer
2455
2456Obtains a **Normalizer** object for text normalization.
2457
2458**Atomic service API**: This API can be used in atomic services since API version 12.
2459
2460**System capability**: SystemCapability.Global.I18n
2461
2462**Parameters**
2463
2464| Name   | Type    | Mandatory  | Description                       |
2465| ------ | ------ | ---- | ------------------------- |
2466| mode | [NormalizerMode](#normalizermode10) | Yes   | Text normalization mode.|
2467
2468**Return value**
2469
2470| Type    | Description                 |
2471| ------ | ------------------- |
2472| [Normalizer](#normalizer10) | **Normalizer** object for text normalization.|
2473
2474**Error codes**
2475
2476For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
2477
2478| ID | Error Message                  |
2479| ------ | ---------------------- |
2480| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
2481
2482**Example**
2483  ```ts
2484  let normalizer: i18n.Normalizer = i18n.Normalizer.getInstance(i18n.NormalizerMode.NFC);
2485  ```
2486
2487
2488### normalize<sup>10+</sup>
2489
2490normalize(text: string): string
2491
2492Normalizes text strings.
2493
2494**Atomic service API**: This API can be used in atomic services since API version 12.
2495
2496**System capability**: SystemCapability.Global.I18n
2497
2498**Parameters**
2499
2500| Name   | Type    | Mandatory  | Description                       |
2501| ------ | ------ | ---- | ------------------------- |
2502| text | string | Yes   | Text strings to be normalized.|
2503
2504**Return value**
2505
2506| Type    | Description                 |
2507| ------ | ------------------- |
2508| string | Normalized text strings.|
2509
2510**Error codes**
2511
2512For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
2513
2514| ID | Error Message                  |
2515| ------ | ---------------------- |
2516| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
2517
2518**Example**
2519  ```ts
2520  let normalizer: i18n.Normalizer = i18n.Normalizer.getInstance(i18n.NormalizerMode.NFC);
2521  let normalizedText: string = normalizer.normalize('\u1E9B\u0323'); // normalizedText = ẛ̣
2522  ```
2523
2524## NormalizerMode<sup>10+</sup>
2525
2526Enumerates text normalization modes.
2527
2528**Atomic service API**: This API can be used in atomic services since API version 12.
2529
2530**System capability**: SystemCapability.Global.I18n
2531
2532| Name| Value| Description|
2533| -------- | -------- | -------- |
2534| NFC | 1 | NFC.|
2535| NFD | 2 | NFD.|
2536| NFKC | 3 | NFKC.|
2537| NFKD | 4 | NFKD.|
2538
2539
2540## HolidayManager<sup>11+</sup>
2541
2542
2543### constructor<sup>11+</sup>
2544
2545constructor(icsPath: String)
2546
2547Creates a **HolidayManager** object.
2548
2549**Atomic service API**: This API can be used in atomic services since API version 12.
2550
2551**System capability**: SystemCapability.Global.I18n
2552
2553**Parameters**
2554
2555|   Name |      Type     | Mandatory|     Description     |
2556| --------- | ------------- | ---- | ------------- |
2557| icsPath   | String | Yes  | Path of the **.ics** file with the read permission granted for applications. |
2558
2559**Error codes**
2560
2561For details about the error codes, see [ohos.i18n Error Codes](errorcode-i18n.md) and [Universal Error Codes](../errorcode-universal.md).
2562
2563| ID | Error Message                  |
2564| ------ | ---------------------- |
2565| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
2566| 890001 | Invalid parameter. Possible causes: Parameter verification failed. |
2567
2568**Example**
2569  ```ts
2570  let holidayManager= new i18n.HolidayManager("/system/lib/US.ics");
2571  ```
2572
2573### isHoliday<sup>11+</sup>
2574
2575isHoliday(date?: Date): boolean
2576
2577Determines whether the specified date is a holiday.
2578
2579**Atomic service API**: This API can be used in atomic services since API version 12.
2580
2581**System capability**: SystemCapability.Global.I18n
2582
2583**Parameters**
2584
2585|   Name |      Type     | Mandatory|     Description     |
2586| --------- | ---------------| ---- | ------------- |
2587| date      | Date           | No  | **Date** object.<br>If no date is specified, the current date is used by default.|
2588
2589**Return value**
2590
2591|       Type       |         Description         |
2592| ----------------- | ----------------------|
2593| boolean           | The value **true** indicates that the specified date is a holiday, and the value **false** indicates the opposite.|
2594
2595**Error codes**
2596
2597For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
2598
2599| ID | Error Message                  |
2600| ------ | ---------------------- |
2601| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
2602
2603**Example**
2604  ```ts
2605  import { BusinessError } from '@kit.BasicServicesKit';
2606
2607  try {
2608    let holidayManager= new i18n.HolidayManager("/system/lib/US.ics");
2609    let isHoliday = holidayManager.isHoliday();
2610    console.log(isHoliday.toString());
2611    let isHoliday2 = holidayManager.isHoliday(new Date(2023,5,25));
2612    console.log(isHoliday2.toString());
2613  } catch(error) {
2614    let err: BusinessError = error as BusinessError;
2615    console.error(`call holidayManager.isHoliday failed, error code: ${err.code}, message: ${err.message}.`);
2616  }
2617  ```
2618
2619
2620### getHolidayInfoItemArray<sup>11+</sup>
2621
2622getHolidayInfoItemArray(year?: number): Array&lt;[HolidayInfoItem](#holidayinfoitem11)&gt;
2623
2624Obtains the holiday information list of the specified year.
2625
2626**Atomic service API**: This API can be used in atomic services since API version 12.
2627
2628**System capability**: SystemCapability.Global.I18n
2629
2630**Parameters**
2631
2632|   Name |      Type     | Mandatory|     Description     |
2633| --------- | -------------  | ---- | ------------- |
2634| year      | number         | No  | Specified year, for example, 2023.<br>If no year is specified, the current year is used by default.|
2635
2636**Return value**
2637
2638|       Type       |         Description         |
2639| ----------------- | -------------------- |
2640| Array&lt;[HolidayInfoItem](#holidayinfoitem11)&gt; | Holiday information list.|
2641
2642**Error codes**
2643
2644For details about the error codes, see [ohos.i18n Error Codes](errorcode-i18n.md) and [Universal Error Codes](../errorcode-universal.md).
2645
2646| ID | Error Message                  |
2647| ------ | ---------------------- |
2648| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
2649| 890001 | Invalid parameter. Possible causes: Parameter verification failed. |
2650
2651**Example**
2652  ```ts
2653  import { BusinessError } from '@kit.BasicServicesKit';
2654
2655  try {
2656    let holidayManager= new i18n.HolidayManager("/system/lib/US.ics");
2657    let holidayInfoItemArray = holidayManager.getHolidayInfoItemArray(2023);
2658    for (let i =0; i < holidayInfoItemArray.length; i++) {
2659        console.log(JSON.stringify(holidayInfoItemArray[i]));
2660    }
2661  } catch(error) {
2662    let err: BusinessError = error as BusinessError;
2663    console.error(`call holidayManager.getHolidayInfoItemArray failed, error code: ${err.code}, message: ${err.message}.`);
2664  }
2665  ```
2666
2667## HolidayInfoItem<sup>11+</sup>
2668
2669Represents the holiday information.
2670
2671**Atomic service API**: This API can be used in atomic services since API version 12.
2672
2673**System capability**: SystemCapability.Global.I18n
2674
2675| Name           | Type            |  Mandatory  |  Description                                  |
2676| --------------- | --------------- | ------  | --------------------------------------- |
2677| baseName        | string          |   Yes   | Holiday name.             |
2678| year            | number          |   Yes   | Year of the holiday.                  |
2679| month           | number          |   Yes   | Month of the holiday.         |
2680| day             | number          |   Yes   | Day of the holiday.                        |
2681| localNames      | Array&lt;[HolidayLocalName](#holidaylocalname11)&gt;          |   No   | Local names of the holiday.         |
2682
2683## HolidayLocalName<sup>11+</sup>
2684
2685Defines the local names of a holiday.
2686
2687**Atomic service API**: This API can be used in atomic services since API version 12.
2688
2689**System capability**: SystemCapability.Global.I18n
2690
2691| Name           | Type            |  Mandatory  |  Description                                  |
2692| --------------- | -----------------| ------  | --------------------------------------- |
2693| language        | string           |   Yes   | Local language of a holiday, for example, **ar**, **en**, or **tr**.         |
2694| name            | string           |   Yes   | Local name of a holiday. For example, the Turkish name of Sacrifice Feast is Kurban Bayrami.     |
2695
2696
2697## i18n.getDisplayCountry<sup>(deprecated)</sup>
2698
2699getDisplayCountry(country: string, locale: string, sentenceCase?: boolean): string
2700
2701Obtains the localized script for the specified country.
2702
2703This API is deprecated since API version 9. You are advised to use [System.getDisplayCountry](#getdisplaycountry9).
2704
2705**System capability**: SystemCapability.Global.I18n
2706
2707**Parameters**
2708
2709| Name         | Type     | Mandatory  | Description              |
2710| ------------ | ------- | ---- | ---------------- |
2711| country      | string  | Yes   | Specified country.           |
2712| locale       | string  | Yes   | Locale ID.    |
2713| sentenceCase | boolean | No   | Whether to use sentence case for the localized script. The default value is **true**.|
2714
2715**Return value**
2716
2717| Type    | Description           |
2718| ------ | ------------- |
2719| string | Localized script for the specified country.|
2720
2721**Example**
2722  ```ts
2723  let countryName: string = i18n.getDisplayCountry("zh-CN", "en-GB", true); // countryName = China
2724  countryName = i18n.getDisplayCountry("zh-CN", "en-GB"); // countryName = China
2725  ```
2726
2727## i18n.getDisplayCountry<sup>(deprecated)</sup>
2728
2729getDisplayCountry(country: string, locale: string, sentenceCase?: boolean): string
2730
2731Obtains the localized script for the specified country.
2732
2733This API is deprecated since API version 9. You are advised to use [System.getDisplayCountry](#getdisplaycountry9).
2734
2735**System capability**: SystemCapability.Global.I18n
2736
2737**Parameters**
2738
2739| Name         | Type     | Mandatory  | Description              |
2740| ------------ | ------- | ---- | ---------------- |
2741| country      | string  | Yes   | Specified country.           |
2742| locale       | string  | Yes   | Locale ID.    |
2743| sentenceCase | boolean | No   | Whether to use sentence case for the localized script. The default value is **true**.|
2744
2745**Return value**
2746
2747| Type    | Description           |
2748| ------ | ------------- |
2749| string | Localized script for the specified country.|
2750
2751**Example**
2752  ```ts
2753  let countryName: string = i18n.getDisplayCountry("zh-CN", "en-GB", true); // countryName = China
2754  countryName = i18n.getDisplayCountry("zh-CN", "en-GB"); // countryName = China
2755  ```
2756
2757
2758## i18n.getDisplayLanguage<sup>(deprecated)</sup>
2759
2760getDisplayLanguage(language: string, locale: string, sentenceCase?: boolean): string
2761
2762Obtains the localized script for the specified language.
2763
2764This API is deprecated since API version 9. You are advised to use [System.getDisplayLanguage](#getdisplaylanguage9).
2765
2766**System capability**: SystemCapability.Global.I18n
2767
2768**Parameters**
2769
2770| Name         | Type     | Mandatory  | Description              |
2771| ------------ | ------- | ---- | ---------------- |
2772| language     | string  | Yes   | Specified language.           |
2773| locale       | string  | Yes   | Locale ID.    |
2774| sentenceCase | boolean | No   | Whether to use sentence case for the localized script. The default value is **true**.|
2775
2776**Return value**
2777
2778| Type    | Description           |
2779| ------ | ------------- |
2780| string | Localized script for the specified language.|
2781
2782**Example**
2783  ```ts
2784  let languageName: string = i18n.getDisplayLanguage("zh", "en-GB", true); // languageName = "Chinese"
2785  languageName = i18n.getDisplayLanguage("zh", "en-GB"); // languageName = "Chinese"
2786  ```
2787
2788
2789## i18n.getSystemLanguage<sup>(deprecated)</sup>
2790
2791getSystemLanguage(): string
2792
2793Obtains the system language.
2794
2795This API is deprecated since API version 9. You are advised to use [System.getSystemLanguage](#getsystemlanguage9).
2796
2797**System capability**: SystemCapability.Global.I18n
2798
2799**Return value**
2800
2801| Type    | Description     |
2802| ------ | ------- |
2803| string | System language ID.|
2804
2805**Example**
2806  ```ts
2807  let systemLanguage: string = i18n.getSystemLanguage(); // Obtain the current system language.
2808  ```
2809
2810
2811## i18n.getSystemRegion<sup>(deprecated)</sup>
2812
2813getSystemRegion(): string
2814
2815Obtains the system region.
2816
2817This API is deprecated since API version 9. You are advised to use [System.getSystemRegion](#getsystemregion9).
2818
2819**System capability**: SystemCapability.Global.I18n
2820
2821**Return value**
2822
2823| Type    | Description     |
2824| ------ | ------- |
2825| string | System region ID.|
2826
2827**Example**
2828  ```ts
2829  let region: string = i18n.getSystemRegion(); // Obtain the current system region.
2830  ```
2831
2832
2833## i18n.getSystemLocale<sup>(deprecated)</sup>
2834
2835getSystemLocale(): string
2836
2837Obtains the system locale.
2838
2839This API is deprecated since API version 9. You are advised to use [System.getSystemLocale](#getsystemlocale9).
2840
2841**System capability**: SystemCapability.Global.I18n
2842
2843**Return value**
2844
2845| Type    | Description     |
2846| ------ | ------- |
2847| string | System locale ID.|
2848
2849**Example**
2850  ```ts
2851  let locale: string = i18n.getSystemLocale (); // Obtain the system locale.
2852  ```
2853
2854
2855## i18n.is24HourClock<sup>(deprecated)</sup>
2856
2857is24HourClock(): boolean
2858
2859Checks whether the 24-hour clock is used.
2860
2861This API is deprecated since API version 9. You are advised to use [System.is24HourClock](#is24hourclock9).
2862
2863**System capability**: SystemCapability.Global.I18n
2864
2865**Return value**
2866
2867| Type     | Description                                      |
2868| ------- | ---------------------------------------- |
2869| boolean | The value **true** indicates that the 24-hour clock is used, and the value **false** indicates the opposite.|
2870
2871**Example**
2872  ```ts
2873  let is24HourClock: boolean = i18n.is24HourClock();
2874  ```
2875
2876
2877## i18n.set24HourClock<sup>(deprecated)</sup>
2878
2879set24HourClock(option: boolean): boolean
2880
2881Sets the 24-hour clock.
2882
2883This API is deprecated since API version 9. The substitute API is available only for system applications.
2884
2885**Permission required**: ohos.permission.UPDATE_CONFIGURATION
2886
2887**System capability**: SystemCapability.Global.I18n
2888
2889**Parameters**
2890
2891| Name   | Type     | Mandatory  | Description                                      |
2892| ------ | ------- | ---- | ---------------------------------------- |
2893| option | boolean | Yes   | Whether to enable the 24-hour clock. The value **true** means to enable the 24-hour clock, and the value **false** means the opposite.|
2894
2895**Return value**
2896
2897| Type     | Description                           |
2898| ------- | ----------------------------- |
2899| boolean | The value **true** indicates that the 24-hour clock is enabled, and the value **false** indicates the opposite.|
2900
2901**Example**
2902  ```ts
2903  // Set the system time to the 24-hour clock.
2904  let success: boolean = i18n.set24HourClock(true);
2905  ```
2906
2907
2908## i18n.addPreferredLanguage<sup>(deprecated)</sup>
2909
2910addPreferredLanguage(language: string, index?: number): boolean
2911
2912Adds a preferred language to the specified position on the preferred language list.
2913
2914This API is supported since API version 8 and is deprecated since API version 9. The substitute API is available only for system applications.
2915
2916**Permission required**: ohos.permission.UPDATE_CONFIGURATION
2917
2918**System capability**: SystemCapability.Global.I18n
2919
2920**Parameters**
2921
2922| Name     | Type    | Mandatory  | Description        |
2923| -------- | ------ | ---- | ---------- |
2924| language | string | Yes   | Preferred language to add. |
2925| index    | number | No   | Position to which the preferred language is added. The default value is the length of the preferred language list.|
2926
2927**Return value**
2928
2929| Type     | Description                           |
2930| ------- | ----------------------------- |
2931| boolean | The value **true** indicates that the preferred language is successfully added, and the value **false** indicates the opposite.|
2932
2933**Example**
2934  ```ts
2935  // Add zh-CN to the preferred language list.
2936  let language: string = 'zh-CN';
2937  let index: number = 0;
2938  let success: boolean = i18n.addPreferredLanguage(language, index);
2939  ```
2940
2941
2942## i18n.removePreferredLanguage<sup>(deprecated)</sup>
2943
2944removePreferredLanguage(index: number): boolean
2945
2946Deletes a preferred language from the specified position on the preferred language list.
2947
2948This API is supported since API version 8 and is deprecated since API version 9. The substitute API is available only for system applications.
2949
2950**Permission required**: ohos.permission.UPDATE_CONFIGURATION
2951
2952**System capability**: SystemCapability.Global.I18n
2953
2954**Parameters**
2955
2956| Name  | Type    | Mandatory  | Description                   |
2957| ----- | ------ | ---- | --------------------- |
2958| index | number | Yes   | Position of the preferred language to delete.|
2959
2960**Return value**
2961
2962| Type     | Description                           |
2963| ------- | ----------------------------- |
2964| boolean | The value **true** indicates that the preferred language is deleted, and the value **false** indicates the opposite.|
2965
2966**Example**
2967  ```ts
2968  // Delete the first preferred language from the preferred language list.
2969  let index: number = 0;
2970  let success: boolean = i18n.removePreferredLanguage(index);
2971  ```
2972
2973
2974## i18n.getPreferredLanguageList<sup>(deprecated)</sup>
2975
2976getPreferredLanguageList(): Array&lt;string&gt;
2977
2978Obtains the list of preferred languages.
2979
2980This API is supported since API version 8 and is deprecated since API version 9. You are advised to use [System.getPreferredLanguageList](#getpreferredlanguagelist9).
2981
2982**System capability**: SystemCapability.Global.I18n
2983
2984**Return value**
2985
2986| Type                 | Description       |
2987| ------------------- | --------- |
2988| Array&lt;string&gt; | List of preferred languages.|
2989
2990**Example**
2991  ```ts
2992  let preferredLanguageList: Array<string> = i18n.getPreferredLanguageList(); // Obtain the preferred language list.
2993  ```
2994
2995
2996## i18n.getFirstPreferredLanguage<sup>(deprecated)</sup>
2997
2998getFirstPreferredLanguage(): string
2999
3000Obtains the first language in the preferred language list.
3001
3002This API is supported since API version 8 and is deprecated since API version 9. You are advised to use [System.getFirstPreferredLanguage](#getfirstpreferredlanguage9).
3003
3004**System capability**: SystemCapability.Global.I18n
3005
3006**Return value**
3007
3008| Type    | Description            |
3009| ------ | -------------- |
3010| string | First language in the preferred language list.|
3011
3012**Example**
3013  ```ts
3014  let firstPreferredLanguage: string = i18n.getFirstPreferredLanguage();
3015  ```
3016
3017
3018## Util<sup>(deprecated)</sup>
3019
3020
3021### unitConvert<sup>(deprecated)</sup>
3022
3023unitConvert(fromUnit: UnitInfo, toUnit: UnitInfo, value: number, locale: string, style?: string): string
3024
3025Converts one measurement unit into another and formats the unit based on the specified locale and style.
3026
3027This API is supported since API version 8 and is deprecated since API version 9. You are advised to use [unitConvert](#unitconvert9).
3028
3029**System capability**: SystemCapability.Global.I18n
3030
3031**Parameters**
3032
3033| Name     | Type                    | Mandatory  | Description                                      |
3034| -------- | ---------------------- | ---- | ---------------------------------------- |
3035| fromUnit | [UnitInfo](#unitinfo8) | Yes   | Measurement unit to be converted.                                |
3036| toUnit   | [UnitInfo](#unitinfo8) | Yes   | Measurement unit to be converted to.                                |
3037| value    | number                 | Yes   | Value of the measurement unit to be converted.                            |
3038| locale   | string                 | Yes   | Locale used for formatting, for example, **zh-Hans-CN**.               |
3039| style    | string                 | No   | Style used for formatting. The value can be **long**, **short**, or **narrow**. The default value is **short**.|
3040
3041**Return value**
3042
3043| Type    | Description                     |
3044| ------ | ----------------------- |
3045| string | String obtained after formatting based on the measurement unit specified by **toUnit**.|
3046
3047
3048## Character<sup>(deprecated)</sup>
3049
3050
3051### isDigit<sup>(deprecated)</sup>
3052
3053isDigit(char: string): boolean
3054
3055Checks whether the input string is composed of digits.
3056
3057This API is supported since API version 8 and is deprecated since API version 9. You are advised to use [isDigit](#isdigit9).
3058
3059**System capability**: SystemCapability.Global.I18n
3060
3061**Parameters**
3062
3063| Name | Type    | Mandatory  | Description   |
3064| ---- | ------ | ---- | ----- |
3065| char | string | Yes   | Input character.|
3066
3067**Return value**
3068
3069| Type     | Description                                  |
3070| ------- | ------------------------------------ |
3071| boolean | The value **true** indicates that the input character is a digit, and the value **false** indicates the opposite.|
3072
3073
3074### isSpaceChar<sup>(deprecated)</sup>
3075
3076isSpaceChar(char: string): boolean
3077
3078Checks whether the input character is a space.
3079
3080This API is supported since API version 8 and is deprecated since API version 9. You are advised to use [isSpaceChar](#isspacechar9).
3081
3082**System capability**: SystemCapability.Global.I18n
3083
3084**Parameters**
3085
3086| Name | Type    | Mandatory  | Description   |
3087| ---- | ------ | ---- | ----- |
3088| char | string | Yes   | Input character.|
3089
3090**Return value**
3091
3092| Type     | Description                                    |
3093| ------- | -------------------------------------- |
3094| boolean | The value **true** indicates that the input character is a space, and the value **false** indicates the opposite.|
3095
3096
3097### isWhitespace<sup>(deprecated)</sup>
3098
3099isWhitespace(char: string): boolean
3100
3101Checks whether the input character is a white space.
3102
3103This API is supported since API version 8 and is deprecated since API version 9. You are advised to use [isWhitespace](#iswhitespace9).
3104
3105**System capability**: SystemCapability.Global.I18n
3106
3107**Parameters**
3108
3109| Name | Type    | Mandatory  | Description   |
3110| ---- | ------ | ---- | ----- |
3111| char | string | Yes   | Input character.|
3112
3113**Return value**
3114
3115| Type     | Description                                    |
3116| ------- | -------------------------------------- |
3117| boolean | The value **true** indicates that the input character is a white space, and the value **false** indicates the opposite.|
3118
3119
3120### isRTL<sup>(deprecated)</sup>
3121
3122isRTL(char: string): boolean
3123
3124Checks whether the input character is of the right to left (RTL) language.
3125
3126This API is supported since API version 8 and is deprecated since API version 9. You are advised to use [isRTL](#isrtl9).
3127
3128**System capability**: SystemCapability.Global.I18n
3129
3130**Parameters**
3131
3132| Name | Type    | Mandatory  | Description   |
3133| ---- | ------ | ---- | ----- |
3134| char | string | Yes   | Input character.|
3135
3136**Return value**
3137
3138| Type     | Description                                      |
3139| ------- | ---------------------------------------- |
3140| boolean | The value **true** indicates that the input character is of the RTL language, and the value **false** indicates the opposite.|
3141
3142
3143### isIdeograph<sup>(deprecated)</sup>
3144
3145isIdeograph(char: string): boolean
3146
3147Checks whether the input character is an ideographic character.
3148
3149This API is supported since API version 8 and is deprecated since API version 9. You are advised to use [isIdeograph](#isideograph9).
3150
3151**System capability**: SystemCapability.Global.I18n
3152
3153**Parameters**
3154
3155| Name | Type    | Mandatory  | Description   |
3156| ---- | ------ | ---- | ----- |
3157| char | string | Yes   | Input character.|
3158
3159**Return value**
3160
3161| Type     | Description                                      |
3162| ------- | ---------------------------------------- |
3163| boolean | The value **true** indicates that the input character is an ideographic character, and the value **false** indicates the opposite.|
3164
3165
3166### isLetter<sup>(deprecated)</sup>
3167
3168isLetter(char: string): boolean
3169
3170Checks whether the input character is a letter.
3171
3172This API is supported since API version 8 and is deprecated since API version 9. You are advised to use [isLetter](#isletter9).
3173
3174**System capability**: SystemCapability.Global.I18n
3175
3176**Parameters**
3177
3178| Name | Type    | Mandatory  | Description   |
3179| ---- | ------ | ---- | ----- |
3180| char | string | Yes   | Input character.|
3181
3182**Return value**
3183
3184| Type     | Description                                  |
3185| ------- | ------------------------------------ |
3186| boolean | The value **true** indicates that the input character is a letter, and the value **false** indicates the opposite.|
3187
3188
3189### isLowerCase<sup>(deprecated)</sup>
3190
3191isLowerCase(char: string): boolean
3192
3193Checks whether the input character is a lowercase letter.
3194
3195This API is supported since API version 8 and is deprecated since API version 9. You are advised to use [isLowerCase](#islowercase9).
3196
3197**System capability**: SystemCapability.Global.I18n
3198
3199**Parameters**
3200
3201| Name | Type    | Mandatory  | Description   |
3202| ---- | ------ | ---- | ----- |
3203| char | string | Yes   | Input character.|
3204
3205**Return value**
3206
3207| Type     | Description                                      |
3208| ------- | ---------------------------------------- |
3209| boolean | The value **true** indicates that the input character is a lowercase letter, and the value **false** indicates the opposite.|
3210
3211
3212### isUpperCase<sup>(deprecated)</sup>
3213
3214isUpperCase(char: string): boolean
3215
3216Checks whether the input character is an uppercase letter.
3217
3218This API is supported since API version 8 and is deprecated since API version 9. You are advised to use [isUpperCase](#isuppercase9).
3219
3220**System capability**: SystemCapability.Global.I18n
3221
3222**Parameters**
3223
3224| Name | Type    | Mandatory  | Description   |
3225| ---- | ------ | ---- | ----- |
3226| char | string | Yes   | Input character.|
3227
3228**Return value**
3229
3230| Type     | Description                                      |
3231| ------- | ---------------------------------------- |
3232| boolean | The value **true** indicates that the input character is an uppercase letter, and the value **false** indicates the opposite.|
3233
3234
3235### getType<sup>(deprecated)</sup>
3236
3237getType(char: string): string
3238
3239Obtains the type of the input string.
3240
3241This API is supported since API version 8 and is deprecated since API version 9. You are advised to use [getType](#gettype9).
3242
3243**System capability**: SystemCapability.Global.I18n
3244
3245**Parameters**
3246
3247| Name | Type    | Mandatory  | Description   |
3248| ---- | ------ | ---- | ----- |
3249| char | string | Yes   | Input character.|
3250
3251**Return value**
3252
3253| Type    | Description         |
3254| ------ | ----------- |
3255| string | Type of the input character.|
3256