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