js-apis-i18n.md 95.8 KB
Newer Older
S
shawn_he 已提交
1
# @ohos.i18n (Internationalization)
Z
zengyawen 已提交
2

S
shawn_he 已提交
3 4
 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.
The [Intl](js-apis-intl.md) module provides basic I18N capabilities through the standard I18N APIs defined in ECMA 402. It works with the I18N module to provide a complete suite of I18N capabilities.
S
shawn_he 已提交
5

S
shawn_he 已提交
6
>  **NOTE**
S
shawn_he 已提交
7 8
>  - 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.
>
S
shawn_he 已提交
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).
S
shawn_he 已提交
10

S
shawn_he 已提交
11 12

## Modules to Import
Z
zengyawen 已提交
13

S
shawn_he 已提交
14
```ts
S
shawn_he 已提交
15
import I18n from '@ohos.i18n';
Z
zengyawen 已提交
16 17 18
```


S
shawn_he 已提交
19
## System<sup>9+</sup>
Z
zengyawen 已提交
20

S
shawn_he 已提交
21
### getDisplayCountry<sup>9+</sup>
Z
zengyawen 已提交
22

S
shawn_he 已提交
23 24 25
static getDisplayCountry(country: string, locale: string, sentenceCase?: boolean): string

Obtains the localized script for the specified country.
Z
zengyawen 已提交
26

S
shawn_he 已提交
27 28
**System capability**: SystemCapability.Global.I18n

S
shawn_he 已提交
29
**Parameters**
S
shawn_he 已提交
30

S
shawn_he 已提交
31 32
| Name         | Type     | Mandatory  | Description              |
| ------------ | ------- | ---- | ---------------- |
S
shawn_he 已提交
33
| country      | string  | Yes   | Specified country.           |
S
shawn_he 已提交
34
| locale       | string  | Yes   | Locale ID.    |
S
shawn_he 已提交
35
| sentenceCase | boolean | No   | Whether to use sentence case for the localized script. The default value is **true**.|
S
shawn_he 已提交
36

S
shawn_he 已提交
37
**Return value**
S
shawn_he 已提交
38

S
shawn_he 已提交
39 40
| Type    | Description           |
| ------ | ------------- |
S
shawn_he 已提交
41 42 43 44
| string | Localized script for the specified country.|

**Error codes**

S
shawn_he 已提交
45
For details about the error codes, see [I18N Error Codes](../errorcodes/errorcode-i18n.md).
S
shawn_he 已提交
46

S
shawn_he 已提交
47 48
| ID | Error Message                  |
| ------ | ---------------------- |
S
shawn_he 已提交
49
| 890001 | param value not valid |
S
shawn_he 已提交
50

S
shawn_he 已提交
51
**Example**
S
shawn_he 已提交
52 53 54
  ```ts
  import { BusinessError } from '@ohos.base';

S
shawn_he 已提交
55
  try {
S
shawn_he 已提交
56 57 58 59
      let displayCountry: string = I18n.System.getDisplayCountry("zh-CN", "en-GB"); // displayCountry = "China"
  } catch (error) {
      let err: BusinessError = error as BusinessError;
      console.error(`call System.getDisplayCountry failed, error code: ${err.code}, message: ${err.message}.`);
S
shawn_he 已提交
60
  }
S
shawn_he 已提交
61 62
  ```

S
shawn_he 已提交
63
### getDisplayLanguage<sup>9+</sup>
S
shawn_he 已提交
64

S
shawn_he 已提交
65
static getDisplayLanguage(language: string, locale: string, sentenceCase?: boolean): string
Z
zengyawen 已提交
66

S
shawn_he 已提交
67
Obtains the localized script for the specified language.
Z
zengyawen 已提交
68

S
shawn_he 已提交
69 70
**System capability**: SystemCapability.Global.I18n

S
shawn_he 已提交
71
**Parameters**
S
shawn_he 已提交
72

S
shawn_he 已提交
73 74
| Name         | Type     | Mandatory  | Description              |
| ------------ | ------- | ---- | ---------------- |
S
shawn_he 已提交
75
| language     | string  | Yes   | Specified language.           |
S
shawn_he 已提交
76
| locale       | string  | Yes   | Locale ID.    |
S
shawn_he 已提交
77
| sentenceCase | boolean | No   | Whether to use sentence case for the localized script. The default value is **true**.|
S
shawn_he 已提交
78

S
shawn_he 已提交
79
**Return value**
S
shawn_he 已提交
80

S
shawn_he 已提交
81 82
| Type    | Description           |
| ------ | ------------- |
S
shawn_he 已提交
83 84 85 86
| string | Localized script for the specified language.|

**Error codes**

S
shawn_he 已提交
87
For details about the error codes, see [I18N Error Codes](../errorcodes/errorcode-i18n.md).
S
shawn_he 已提交
88

S
shawn_he 已提交
89 90
| ID | Error Message                  |
| ------ | ---------------------- |
S
shawn_he 已提交
91
| 890001 | param value not valid |
S
shawn_he 已提交
92

S
shawn_he 已提交
93
**Example**
S
shawn_he 已提交
94 95 96
  ```ts
  import { BusinessError } from '@ohos.base';
  
S
shawn_he 已提交
97
  try {
S
shawn_he 已提交
98
    let displayLanguage: string = I18n.System.getDisplayLanguage("zh", "en-GB"); // displayLanguage = Chinese
S
shawn_he 已提交
99
  } catch(error) {
S
shawn_he 已提交
100
    let err: BusinessError = error as BusinessError;
S
shawn_he 已提交
101
    console.error(`call System.getDisplayLanguage failed, error code: ${err.code}, message: ${err.message}.`);
S
shawn_he 已提交
102
  }
S
shawn_he 已提交
103 104
  ```

S
shawn_he 已提交
105
### getSystemLanguages<sup>9+</sup>
S
shawn_he 已提交
106

S
shawn_he 已提交
107
static getSystemLanguages(): Array&lt;string&gt;
Z
zengyawen 已提交
108

S
shawn_he 已提交
109
Obtains the list of system languages. For details about languages, see [Instantiating the Locale Object](../../internationalization/intl-guidelines.md#how-to-develop).
Z
zengyawen 已提交
110

S
shawn_he 已提交
111
**System capability**: SystemCapability.Global.I18n
Z
zengyawen 已提交
112

S
shawn_he 已提交
113
**Return value**
S
shawn_he 已提交
114

S
shawn_he 已提交
115 116 117
| Type                 | Description          |
| ------------------- | ------------ |
| Array&lt;string&gt; | List of the IDs of system languages.|
Z
zengyawen 已提交
118

S
shawn_he 已提交
119
**Error codes**
S
shawn_he 已提交
120

S
shawn_he 已提交
121
For details about the error codes, see [I18N Error Codes](../errorcodes/errorcode-i18n.md).
S
shawn_he 已提交
122

S
shawn_he 已提交
123 124
| ID | Error Message                  |
| ------ | ---------------------- |
S
shawn_he 已提交
125
| 890001 | param value not valid |
Z
zengyawen 已提交
126

S
shawn_he 已提交
127
**Example**
S
shawn_he 已提交
128 129 130
  ```ts
  import { BusinessError } from '@ohos.base';
  
S
shawn_he 已提交
131
  try {
S
shawn_he 已提交
132
    let systemLanguages: Array<string> = I18n.System.getSystemLanguages(); // [ "en-Latn-US", "zh-Hans" ]
S
shawn_he 已提交
133
  } catch(error) {
S
shawn_he 已提交
134
    let err: BusinessError = error as BusinessError;
S
shawn_he 已提交
135
    console.error(`call System.getSystemLanguages failed, error code: ${err.code}, message: ${err.message}.`);
S
shawn_he 已提交
136
  }
S
shawn_he 已提交
137
  ```
Z
zengyawen 已提交
138

S
shawn_he 已提交
139
### getSystemCountries<sup>9+</sup>
Z
zengyawen 已提交
140

S
shawn_he 已提交
141
static getSystemCountries(language: string): Array&lt;string&gt;
Z
zengyawen 已提交
142

S
shawn_he 已提交
143
Obtains the list of countries and regions supported for the specified language. For details about countries or regions, see [Instantiating the Locale Object](../../internationalization/intl-guidelines.md#how-to-develop).
Z
zengyawen 已提交
144

S
shawn_he 已提交
145 146
**System capability**: SystemCapability.Global.I18n

S
shawn_he 已提交
147 148
**Parameters**

S
shawn_he 已提交
149 150 151
| Name     | Type    | Mandatory  | Description   |
| -------- | ------ | ---- | ----- |
| language | string | Yes   | Language ID.|
S
shawn_he 已提交
152

S
shawn_he 已提交
153
**Return value**
S
shawn_he 已提交
154

S
shawn_he 已提交
155 156 157
| Type                 | Description          |
| ------------------- | ------------ |
| Array&lt;string&gt; | List of the IDs of the countries and regions supported for the specified language.|
S
shawn_he 已提交
158

S
shawn_he 已提交
159
**Error codes**
Z
zengyawen 已提交
160

S
shawn_he 已提交
161
For details about the error codes, see [I18N Error Codes](../errorcodes/errorcode-i18n.md).
Z
zengyawen 已提交
162

S
shawn_he 已提交
163 164
| ID | Error Message                  |
| ------ | ---------------------- |
S
shawn_he 已提交
165
| 890001 | param value not valid |
S
shawn_he 已提交
166

S
shawn_he 已提交
167
**Example**
S
shawn_he 已提交
168 169 170
  ```ts
  import { BusinessError } from '@ohos.base';
  
S
shawn_he 已提交
171
  try {
S
shawn_he 已提交
172
    let systemCountries: Array<string> = I18n.System.getSystemCountries('zh'); // systemCountries = [ "ZW", "YT", "YE", ..., "ER", "CN", "DE" ], 240 countries or regions in total
S
shawn_he 已提交
173
  } catch(error) {
S
shawn_he 已提交
174
    let err: BusinessError = error as BusinessError;
S
shawn_he 已提交
175
    console.error(`call System.getSystemCountries failed, error code: ${err.code}, message: ${err.message}.`);
S
shawn_he 已提交
176 177
  }
  ```
S
shawn_he 已提交
178

S
shawn_he 已提交
179
### isSuggested<sup>9+</sup>
S
shawn_he 已提交
180

S
shawn_he 已提交
181
static isSuggested(language: string, region?: string): boolean
S
shawn_he 已提交
182

S
shawn_he 已提交
183
Checks whether the system language matches the specified region.
S
shawn_he 已提交
184

S
shawn_he 已提交
185 186
**System capability**: SystemCapability.Global.I18n

S
shawn_he 已提交
187
**Parameters**
S
shawn_he 已提交
188

S
shawn_he 已提交
189 190 191
| Name     | Type    | Mandatory  | Description           |
| -------- | ------ | ---- | ------------- |
| language | string | Yes   | Valid language ID, for example, **zh**.|
S
shawn_he 已提交
192
| region   | string | No   | Valid region ID, for example, **CN**. The default value is the country or region where the SIM card is used. |
S
shawn_he 已提交
193

S
shawn_he 已提交
194
**Return value**
S
shawn_he 已提交
195

S
shawn_he 已提交
196 197
| Type     | Description                                      |
| ------- | ---------------------------------------- |
S
shawn_he 已提交
198
| boolean | The value **true** indicates that the system language matches the specified region, and the value **false** indicates the opposite.|
S
shawn_he 已提交
199 200 201

**Error codes**

S
shawn_he 已提交
202
For details about the error codes, see [I18N Error Codes](../errorcodes/errorcode-i18n.md).
S
shawn_he 已提交
203

S
shawn_he 已提交
204 205
| ID | Error Message                  |
| ------ | ---------------------- |
S
shawn_he 已提交
206
| 890001 | param value not valid |
S
shawn_he 已提交
207

S
shawn_he 已提交
208
**Example**
S
shawn_he 已提交
209 210 211
  ```ts
  import { BusinessError } from '@ohos.base';
  
S
shawn_he 已提交
212
  try {
S
shawn_he 已提交
213
    let res: boolean = I18n.System.isSuggested('zh', 'CN');  // res = true
S
shawn_he 已提交
214
  } catch(error) {
S
shawn_he 已提交
215
    let err: BusinessError = error as BusinessError;
S
shawn_he 已提交
216
    console.error(`call System.isSuggested failed, error code: ${err.code}, message: ${err.message}.`);
S
shawn_he 已提交
217
  }
S
shawn_he 已提交
218 219
  ```

S
shawn_he 已提交
220
### getSystemLanguage<sup>9+</sup>
S
shawn_he 已提交
221

S
shawn_he 已提交
222
static getSystemLanguage(): string
S
shawn_he 已提交
223

S
shawn_he 已提交
224
Obtains the system language. For details about languages, see [Instantiating the Locale Object](../../internationalization/intl-guidelines.md#how-to-develop).
S
shawn_he 已提交
225 226 227

**System capability**: SystemCapability.Global.I18n

S
shawn_he 已提交
228
**Return value**
S
shawn_he 已提交
229

S
shawn_he 已提交
230 231 232 233 234 235
| Type    | Description     |
| ------ | ------- |
| string | System language ID.|

**Error codes**

S
shawn_he 已提交
236
For details about the error codes, see [I18N Error Codes](../errorcodes/errorcode-i18n.md).
S
shawn_he 已提交
237

S
shawn_he 已提交
238 239
| ID | Error Message                  |
| ------ | ---------------------- |
S
shawn_he 已提交
240
| 890001 | param value not valid |
S
shawn_he 已提交
241

S
shawn_he 已提交
242
**Example**
S
shawn_he 已提交
243 244 245
  ```ts
  import { BusinessError } from '@ohos.base';
  
S
shawn_he 已提交
246
  try {
S
shawn_he 已提交
247
    let systemLanguage: string = I18n.System.getSystemLanguage();  // systemLanguage indicates the current system language.
S
shawn_he 已提交
248
  } catch(error) {
S
shawn_he 已提交
249
    let err: BusinessError = error as BusinessError;
S
shawn_he 已提交
250
    console.error(`call System.getSystemLanguage failed, error code: ${err.code}, message: ${err.message}.`);
S
shawn_he 已提交
251
  }
S
shawn_he 已提交
252 253
  ```

S
shawn_he 已提交
254
### setSystemLanguage<sup>9+</sup>
S
shawn_he 已提交
255

S
shawn_he 已提交
256
static setSystemLanguage(language: string): void
S
shawn_he 已提交
257

S
shawn_he 已提交
258
Sets the system language. Currently, this API does not support real-time updating of the system language.
S
shawn_he 已提交
259

S
shawn_he 已提交
260
**System API**: This is a system API.
S
shawn_he 已提交
261

S
shawn_he 已提交
262
**Permission required**: ohos.permission.UPDATE_CONFIGURATION
S
shawn_he 已提交
263

S
shawn_he 已提交
264
**System capability**: SystemCapability.Global.I18n
S
shawn_he 已提交
265

S
shawn_he 已提交
266
**Parameters**
S
shawn_he 已提交
267

S
shawn_he 已提交
268 269 270
| Name     | Type    | Mandatory  | Description   |
| -------- | ------ | ---- | ----- |
| language | string | Yes   | Language ID.|
S
shawn_he 已提交
271

S
shawn_he 已提交
272
**Error codes**
S
shawn_he 已提交
273

S
shawn_he 已提交
274
For details about the error codes, see [I18N Error Codes](../errorcodes/errorcode-i18n.md).
S
shawn_he 已提交
275

S
shawn_he 已提交
276 277
| ID | Error Message                  |
| ------ | ---------------------- |
S
shawn_he 已提交
278
| 890001 | param value not valid |
S
shawn_he 已提交
279

S
shawn_he 已提交
280
**Example**
S
shawn_he 已提交
281 282 283
  ```ts
  import { BusinessError } from '@ohos.base';
  
S
shawn_he 已提交
284
  try {
S
shawn_he 已提交
285
    I18n.System.setSystemLanguage('zh'); // Set the current system language to zh.
S
shawn_he 已提交
286
  } catch(error) {
S
shawn_he 已提交
287
    let err: BusinessError = error as BusinessError;
S
shawn_he 已提交
288
    console.error(`call System.setSystemLanguage failed, error code: ${err.code}, message: ${err.message}.`);
S
shawn_he 已提交
289
  }
S
shawn_he 已提交
290 291
  ```

S
shawn_he 已提交
292
### getSystemRegion<sup>9+</sup>
S
shawn_he 已提交
293

S
shawn_he 已提交
294
static getSystemRegion(): string
Z
zengyawen 已提交
295

S
shawn_he 已提交
296
Obtains the system region. For details about system regions, see [Instantiating the Locale Object](../../internationalization/intl-guidelines.md#how-to-develop).
S
shawn_he 已提交
297 298 299

**System capability**: SystemCapability.Global.I18n

S
shawn_he 已提交
300
**Return value**
S
shawn_he 已提交
301

S
shawn_he 已提交
302 303 304
| Type    | Description     |
| ------ | ------- |
| string | System region ID.|
Z
zengyawen 已提交
305

S
shawn_he 已提交
306 307
**Error codes**

S
shawn_he 已提交
308
For details about the error codes, see [I18N Error Codes](../errorcodes/errorcode-i18n.md).
S
shawn_he 已提交
309

S
shawn_he 已提交
310 311
| ID | Error Message                  |
| ------ | ---------------------- |
S
shawn_he 已提交
312
| 890001 | param value not valid |
S
shawn_he 已提交
313

S
shawn_he 已提交
314
**Example**
S
shawn_he 已提交
315 316 317
  ```ts
  import { BusinessError } from '@ohos.base';
  
S
shawn_he 已提交
318
  try {
S
shawn_he 已提交
319
    let systemRegion: string = I18n.System.getSystemRegion(); // Obtain the current system region.
S
shawn_he 已提交
320
  } catch(error) {
S
shawn_he 已提交
321
    let err: BusinessError = error as BusinessError;
S
shawn_he 已提交
322
    console.error(`call System.getSystemRegion failed, error code: ${err.code}, message: ${err.message}.`);
S
shawn_he 已提交
323
  }
S
shawn_he 已提交
324
  ```
Z
zengyawen 已提交
325

S
shawn_he 已提交
326
### setSystemRegion<sup>9+</sup>
Z
zengyawen 已提交
327

S
shawn_he 已提交
328
static setSystemRegion(region: string): void
S
shawn_he 已提交
329 330 331

Sets the system region.

S
shawn_he 已提交
332
**System API**: This is a system API.
S
shawn_he 已提交
333

S
shawn_he 已提交
334
**Permission required**: ohos.permission.UPDATE_CONFIGURATION
S
shawn_he 已提交
335

S
shawn_he 已提交
336 337
**System capability**: SystemCapability.Global.I18n

S
shawn_he 已提交
338
**Parameters**
S
shawn_he 已提交
339

S
shawn_he 已提交
340 341
| Name   | Type    | Mandatory  | Description   |
| ------ | ------ | ---- | ----- |
S
shawn_he 已提交
342
| region | string | Yes   | System region ID.|
S
shawn_he 已提交
343

S
shawn_he 已提交
344
**Error codes**
S
shawn_he 已提交
345

S
shawn_he 已提交
346
For details about the error codes, see [I18N Error Codes](../errorcodes/errorcode-i18n.md).
S
shawn_he 已提交
347

S
shawn_he 已提交
348 349
| ID | Error Message                  |
| ------ | ---------------------- |
S
shawn_he 已提交
350
| 890001 | param value not valid |
S
shawn_he 已提交
351

S
shawn_he 已提交
352
**Example**
S
shawn_he 已提交
353 354 355
  ```ts
  import { BusinessError } from '@ohos.base';
  
S
shawn_he 已提交
356
  try {
S
shawn_he 已提交
357
    I18n.System.setSystemRegion('CN'); // Set the current system region to CN.
S
shawn_he 已提交
358
  } catch(error) {
S
shawn_he 已提交
359
    let err: BusinessError = error as BusinessError;
S
shawn_he 已提交
360
    console.error(`call System.setSystemRegion failed, error code: ${err.code}, message: ${err.message}.`);
S
shawn_he 已提交
361
  }
S
shawn_he 已提交
362 363
  ```

S
shawn_he 已提交
364
### getSystemLocale<sup>9+</sup>
S
shawn_he 已提交
365

S
shawn_he 已提交
366
static getSystemLocale(): string
Z
zengyawen 已提交
367

S
shawn_he 已提交
368
Obtains the system locale. For details about system locales, see [Instantiating the Locale Object](../../internationalization/intl-guidelines.md#how-to-develop).
Z
zengyawen 已提交
369

S
shawn_he 已提交
370
**System capability**: SystemCapability.Global.I18n
Z
zengyawen 已提交
371

S
shawn_he 已提交
372
**Return value**
S
shawn_he 已提交
373

S
shawn_he 已提交
374 375 376
| Type    | Description     |
| ------ | ------- |
| string | System locale ID.|
Z
zengyawen 已提交
377

S
shawn_he 已提交
378 379
**Error codes**

S
shawn_he 已提交
380
For details about the error codes, see [I18N Error Codes](../errorcodes/errorcode-i18n.md).
S
shawn_he 已提交
381

S
shawn_he 已提交
382 383
| ID | Error Message                  |
| ------ | ---------------------- |
S
shawn_he 已提交
384
| 890001 | param value not valid |
S
shawn_he 已提交
385

S
shawn_he 已提交
386
**Example**
S
shawn_he 已提交
387 388 389
  ```ts
  import { BusinessError } from '@ohos.base';
  
S
shawn_he 已提交
390
  try {
S
shawn_he 已提交
391
    let systemLocale: string = I18n.System.getSystemLocale();  // Obtain the current system locale.
S
shawn_he 已提交
392
  } catch(error) {
S
shawn_he 已提交
393
    let err: BusinessError = error as BusinessError;
S
shawn_he 已提交
394
    console.error(`call System.getSystemLocale failed, error code: ${err.code}, message: ${err.message}.`);
S
shawn_he 已提交
395
  }
S
shawn_he 已提交
396
  ```
Z
zengyawen 已提交
397

S
shawn_he 已提交
398
### setSystemLocale<sup>9+</sup>
Z
zengyawen 已提交
399

S
shawn_he 已提交
400
static setSystemLocale(locale: string): void
S
shawn_he 已提交
401 402 403

Sets the system locale.

S
shawn_he 已提交
404
**System API**: This is a system API.
S
shawn_he 已提交
405

S
shawn_he 已提交
406
**Permission required**: ohos.permission.UPDATE_CONFIGURATION
S
shawn_he 已提交
407

S
shawn_he 已提交
408 409
**System capability**: SystemCapability.Global.I18n

S
shawn_he 已提交
410
**Parameters**
S
shawn_he 已提交
411

S
shawn_he 已提交
412 413 414
| Name   | Type    | Mandatory  | Description             |
| ------ | ------ | ---- | --------------- |
| locale | string | Yes   | System locale ID, for example, **zh-CN**.|
S
shawn_he 已提交
415

S
shawn_he 已提交
416
**Error codes**
S
shawn_he 已提交
417

S
shawn_he 已提交
418
For details about the error codes, see [I18N Error Codes](../errorcodes/errorcode-i18n.md).
S
shawn_he 已提交
419

S
shawn_he 已提交
420 421
| ID | Error Message                  |
| ------ | ---------------------- |
S
shawn_he 已提交
422
| 890001 | param value not valid |
S
shawn_he 已提交
423

S
shawn_he 已提交
424
**Example**
S
shawn_he 已提交
425 426 427
  ```ts
  import { BusinessError } from '@ohos.base';
  
S
shawn_he 已提交
428
  try {
S
shawn_he 已提交
429
    I18n.System.setSystemLocale('zh-CN'); // Set the current system locale to zh-CN.
S
shawn_he 已提交
430
  } catch(error) {
S
shawn_he 已提交
431
    let err: BusinessError = error as BusinessError;
S
shawn_he 已提交
432
    console.error(`call System.setSystemLocale failed, error code: ${err.code}, message: ${err.message}.`);
S
shawn_he 已提交
433
  }
S
shawn_he 已提交
434 435
  ```

S
shawn_he 已提交
436
### is24HourClock<sup>9+</sup>
S
shawn_he 已提交
437

S
shawn_he 已提交
438
static is24HourClock(): boolean
S
shawn_he 已提交
439

S
shawn_he 已提交
440
Checks whether the 24-hour clock is used.
S
shawn_he 已提交
441 442 443

**System capability**: SystemCapability.Global.I18n

S
shawn_he 已提交
444
**Return value**
S
shawn_he 已提交
445

S
shawn_he 已提交
446 447
| Type     | Description                                      |
| ------- | ---------------------------------------- |
S
shawn_he 已提交
448
| boolean | The value **true** indicates that the 24-hour clock is used, and the value **false** indicates the opposite.|
S
shawn_he 已提交
449 450 451

**Error codes**

S
shawn_he 已提交
452
For details about the error codes, see [I18N Error Codes](../errorcodes/errorcode-i18n.md).
S
shawn_he 已提交
453

S
shawn_he 已提交
454 455
| ID | Error Message                  |
| ------ | ---------------------- |
S
shawn_he 已提交
456
| 890001 | param value not valid |
S
shawn_he 已提交
457

S
shawn_he 已提交
458
**Example**
S
shawn_he 已提交
459 460 461
  ```ts
  import { BusinessError } from '@ohos.base';
  
S
shawn_he 已提交
462
  try {
S
shawn_he 已提交
463
    let is24HourClock: boolean = I18n.System.is24HourClock();  // Check whether the 24-hour clock is enabled.
S
shawn_he 已提交
464
  } catch(error) {
S
shawn_he 已提交
465
    let err: BusinessError = error as BusinessError;
S
shawn_he 已提交
466
    console.error(`call System.is24HourClock failed, error code: ${err.code}, message: ${err.message}.`);
S
shawn_he 已提交
467
  }
S
shawn_he 已提交
468 469
  ```

S
shawn_he 已提交
470
### set24HourClock<sup>9+</sup>
S
shawn_he 已提交
471

S
shawn_he 已提交
472
static set24HourClock(option: boolean): void
Z
zengyawen 已提交
473

S
shawn_he 已提交
474
Sets the system time to the 24-hour clock.
Z
zengyawen 已提交
475

S
shawn_he 已提交
476
**System API**: This is a system API.
S
shawn_he 已提交
477 478

**Permission required**: ohos.permission.UPDATE_CONFIGURATION
Z
zengyawen 已提交
479

S
shawn_he 已提交
480
**System capability**: SystemCapability.Global.I18n
Z
zengyawen 已提交
481

S
shawn_he 已提交
482
**Parameters**
S
shawn_he 已提交
483

S
shawn_he 已提交
484 485 486
| Name   | Type     | Mandatory  | Description                                      |
| ------ | ------- | ---- | ---------------------------------------- |
| 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.|
S
shawn_he 已提交
487

S
shawn_he 已提交
488
**Error codes**
S
shawn_he 已提交
489

S
shawn_he 已提交
490
For details about the error codes, see [I18N Error Codes](../errorcodes/errorcode-i18n.md).
S
shawn_he 已提交
491

S
shawn_he 已提交
492 493
| ID | Error Message                  |
| ------ | ---------------------- |
S
shawn_he 已提交
494
| 890001 | param value not valid |
S
shawn_he 已提交
495

S
shawn_he 已提交
496
**Example**
S
shawn_he 已提交
497 498 499
  ```ts
  import { BusinessError } from '@ohos.base';
  
S
shawn_he 已提交
500 501
  // Set the system time to the 24-hour clock.
  try {
S
shawn_he 已提交
502
    I18n.System.set24HourClock(true);
S
shawn_he 已提交
503
  } catch(error) {
S
shawn_he 已提交
504
    let err: BusinessError = error as BusinessError;
S
shawn_he 已提交
505
    console.error(`call System.set24HourClock failed, error code: ${err.code}, message: ${err.message}.`);
S
shawn_he 已提交
506
  }
S
shawn_he 已提交
507 508
  ```

S
shawn_he 已提交
509
### addPreferredLanguage<sup>9+</sup>
S
shawn_he 已提交
510

S
shawn_he 已提交
511
static addPreferredLanguage(language: string, index?: number): void
S
shawn_he 已提交
512

S
shawn_he 已提交
513
Adds a preferred language to the specified position on the preferred language list.
S
shawn_he 已提交
514

S
shawn_he 已提交
515
**System API**: This is a system API.
S
shawn_he 已提交
516

S
shawn_he 已提交
517
**Permission required**: ohos.permission.UPDATE_CONFIGURATION
S
shawn_he 已提交
518 519 520

**System capability**: SystemCapability.Global.I18n

S
shawn_he 已提交
521
**Parameters**
S
shawn_he 已提交
522

S
shawn_he 已提交
523 524 525
| Name     | Type    | Mandatory  | Description        |
| -------- | ------ | ---- | ---------- |
| language | string | Yes   | Preferred language to add. |
S
shawn_he 已提交
526
| index    | number | No   | Position to which the preferred language is added. The default value is the length of the preferred language list.|
S
shawn_he 已提交
527 528 529

**Error codes**

S
shawn_he 已提交
530
For details about the error codes, see [I18N Error Codes](../errorcodes/errorcode-i18n.md).
S
shawn_he 已提交
531

S
shawn_he 已提交
532 533
| ID | Error Message                  |
| ------ | ---------------------- |
S
shawn_he 已提交
534
| 890001 | param value not valid |
S
shawn_he 已提交
535

S
shawn_he 已提交
536
**Example**
S
shawn_he 已提交
537 538 539
  ```ts
  import { BusinessError } from '@ohos.base';
  
S
shawn_he 已提交
540
  // Add zh-CN to the preferred language list.
S
shawn_he 已提交
541 542
  let language = 'zh-CN';
  let index = 0;
S
shawn_he 已提交
543
  try {
S
shawn_he 已提交
544
    I18n.System.addPreferredLanguage(language, index); // Add zh-CN to the first place in the preferred language list.
S
shawn_he 已提交
545
  } catch(error) {
S
shawn_he 已提交
546
    let err: BusinessError = error as BusinessError;
S
shawn_he 已提交
547
    console.error(`call System.addPreferredLanguage failed, error code: ${err.code}, message: ${err.message}.`);
S
shawn_he 已提交
548
  }
S
shawn_he 已提交
549 550
  ```

S
shawn_he 已提交
551
### removePreferredLanguage<sup>9+</sup>
S
shawn_he 已提交
552

S
shawn_he 已提交
553
static removePreferredLanguage(index: number): void
S
shawn_he 已提交
554

S
shawn_he 已提交
555
Deletes a preferred language from the specified position on the preferred language list.
S
shawn_he 已提交
556

S
shawn_he 已提交
557
**System API**: This is a system API.
S
shawn_he 已提交
558 559

**Permission required**: ohos.permission.UPDATE_CONFIGURATION
S
shawn_he 已提交
560 561 562

**System capability**: SystemCapability.Global.I18n

S
shawn_he 已提交
563
**Parameters**
S
shawn_he 已提交
564

S
shawn_he 已提交
565 566 567 568 569 570
| Name  | Type    | Mandatory  | Description                   |
| ----- | ------ | ---- | --------------------- |
| index | number | Yes   | Position of the preferred language to delete.|

**Error codes**

S
shawn_he 已提交
571
For details about the error codes, see [I18N Error Codes](../errorcodes/errorcode-i18n.md).
S
shawn_he 已提交
572

S
shawn_he 已提交
573 574
| ID | Error Message                  |
| ------ | ---------------------- |
S
shawn_he 已提交
575
| 890001 | param value not valid |
S
shawn_he 已提交
576

S
shawn_he 已提交
577
**Example**
S
shawn_he 已提交
578 579 580
  ```ts
  import { BusinessError } from '@ohos.base';
  
S
shawn_he 已提交
581
  // Delete the first preferred language from the preferred language list.
S
shawn_he 已提交
582
  let index: number = 0;
S
shawn_he 已提交
583
  try {
S
shawn_he 已提交
584
    I18n.System.removePreferredLanguage(index);
S
shawn_he 已提交
585
  } catch(error) {
S
shawn_he 已提交
586
    let err: BusinessError = error as BusinessError;
S
shawn_he 已提交
587
    console.error(`call System.removePreferredLanguage failed, error code: ${err.code}, message: ${err.message}.`);
S
shawn_he 已提交
588
  }
S
shawn_he 已提交
589 590
  ```

S
shawn_he 已提交
591
### getPreferredLanguageList<sup>9+</sup>
S
shawn_he 已提交
592

S
shawn_he 已提交
593
static getPreferredLanguageList(): Array&lt;string&gt;
S
shawn_he 已提交
594

S
shawn_he 已提交
595
Obtains the list of preferred languages.
S
shawn_he 已提交
596 597 598

**System capability**: SystemCapability.Global.I18n

S
shawn_he 已提交
599
**Return value**
S
shawn_he 已提交
600

S
shawn_he 已提交
601 602
| Type                 | Description       |
| ------------------- | --------- |
S
shawn_he 已提交
603
| Array&lt;string&gt; | List of preferred languages.|
S
shawn_he 已提交
604 605 606

**Error codes**

S
shawn_he 已提交
607
For details about the error codes, see [I18N Error Codes](../errorcodes/errorcode-i18n.md).
S
shawn_he 已提交
608

S
shawn_he 已提交
609 610
| ID | Error Message                  |
| ------ | ---------------------- |
S
shawn_he 已提交
611
| 890001 | param value not valid |
S
shawn_he 已提交
612

S
shawn_he 已提交
613
**Example**
S
shawn_he 已提交
614 615 616
  ```ts
  import { BusinessError } from '@ohos.base';
  
S
shawn_he 已提交
617
  try {
S
shawn_he 已提交
618
    let preferredLanguageList: Array<string> = I18n.System.getPreferredLanguageList(); // Obtain the current preferred language list.
S
shawn_he 已提交
619
  } catch(error) {
S
shawn_he 已提交
620
    let err: BusinessError = error as BusinessError;
S
shawn_he 已提交
621
    console.error(`call System.getPreferredLanguageList failed, error code: ${err.code}, message: ${err.message}.`);
S
shawn_he 已提交
622
  }
S
shawn_he 已提交
623 624
  ```

S
shawn_he 已提交
625
### getFirstPreferredLanguage<sup>9+</sup>
S
shawn_he 已提交
626

S
shawn_he 已提交
627
static getFirstPreferredLanguage(): string
S
shawn_he 已提交
628

S
shawn_he 已提交
629
Obtains the first language in the preferred language list.
S
shawn_he 已提交
630 631 632

**System capability**: SystemCapability.Global.I18n

S
shawn_he 已提交
633
**Return value**
S
shawn_he 已提交
634

S
shawn_he 已提交
635 636 637
| Type    | Description            |
| ------ | -------------- |
| string | First language in the preferred language list.|
S
shawn_he 已提交
638

S
shawn_he 已提交
639 640
**Error codes**

S
shawn_he 已提交
641
For details about the error codes, see [I18N Error Codes](../errorcodes/errorcode-i18n.md).
S
shawn_he 已提交
642

S
shawn_he 已提交
643 644
| ID | Error Message                  |
| ------ | ---------------------- |
S
shawn_he 已提交
645
| 890001 | param value not valid |
S
shawn_he 已提交
646 647

**Example**
S
shawn_he 已提交
648 649 650
  ```ts
  import { BusinessError } from '@ohos.base';
  
S
shawn_he 已提交
651
  try {
S
shawn_he 已提交
652
    let firstPreferredLanguage: string = I18n.System.getFirstPreferredLanguage();  // Obtain the first language in the preferred language list.
S
shawn_he 已提交
653
  } catch(error) {
S
shawn_he 已提交
654
    let err: BusinessError = error as BusinessError;
S
shawn_he 已提交
655
    console.error(`call System.getFirstPreferredLanguage failed, error code: ${err.code}, message: ${err.message}.`);
S
shawn_he 已提交
656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674
  }
  ```

### getAppPreferredLanguage<sup>9+</sup>

static getAppPreferredLanguage(): string

Obtains the preferred language of an application.

**System capability**: SystemCapability.Global.I18n

**Return value**

| Type    | Description      |
| ------ | -------- |
| string | Preferred language of the application.|

**Error codes**

S
shawn_he 已提交
675
For details about the error codes, see [I18N Error Codes](../errorcodes/errorcode-i18n.md).
S
shawn_he 已提交
676

S
shawn_he 已提交
677 678
| ID | Error Message                  |
| ------ | ---------------------- |
S
shawn_he 已提交
679
| 890001 | param value not valid |
S
shawn_he 已提交
680 681

**Example**
S
shawn_he 已提交
682 683 684
  ```ts
  import { BusinessError } from '@ohos.base';
  
S
shawn_he 已提交
685
  try {
S
shawn_he 已提交
686
    let appPreferredLanguage: string = I18n.System.getAppPreferredLanguage(); // Obtain the preferred language of an application.
S
shawn_he 已提交
687
  } catch(error) {
S
shawn_he 已提交
688
    let err: BusinessError = error as BusinessError;
S
shawn_he 已提交
689
    console.error(`call System.getAppPreferredLanguage failed, error code: ${err.code}, message: ${err.message}.`);
S
shawn_he 已提交
690 691 692 693 694 695 696
  }
  ```

### setUsingLocalDigit<sup>9+</sup>

static setUsingLocalDigit(flag: boolean): void

S
shawn_he 已提交
697
Specifies whether to enable use of local digits.
S
shawn_he 已提交
698

S
shawn_he 已提交
699
**System API**: This is a system API.
S
shawn_he 已提交
700 701 702 703 704 705 706 707 708

**Permission required**: ohos.permission.UPDATE_CONFIGURATION

**System capability**: SystemCapability.Global.I18n

**Parameters**

| Name | Type     | Mandatory  | Description                             |
| ---- | ------- | ---- | ------------------------------- |
S
shawn_he 已提交
709
| 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.|
S
shawn_he 已提交
710 711 712

**Error codes**

S
shawn_he 已提交
713
For details about the error codes, see [I18N Error Codes](../errorcodes/errorcode-i18n.md).
S
shawn_he 已提交
714

S
shawn_he 已提交
715 716
| ID | Error Message                  |
| ------ | ---------------------- |
S
shawn_he 已提交
717
| 890001 | param value not valid |
S
shawn_he 已提交
718 719 720

**Example**
  ```ts
S
shawn_he 已提交
721 722
  import { BusinessError } from '@ohos.base';
  
S
shawn_he 已提交
723
  try {
S
shawn_he 已提交
724
    I18n.System.setUsingLocalDigit(true); // Enable the local digit switch.
S
shawn_he 已提交
725
  } catch(error) {
S
shawn_he 已提交
726
    let err: BusinessError = error as BusinessError;
S
shawn_he 已提交
727
    console.error(`call System.setUsingLocalDigit failed, error code: ${err.code}, message: ${err.message}.`);
S
shawn_he 已提交
728 729 730 731 732 733 734
  }
  ```

### getUsingLocalDigit<sup>9+</sup>

static getUsingLocalDigit(): boolean

S
shawn_he 已提交
735
Checks whether use of local digits is enabled.
S
shawn_he 已提交
736 737 738 739 740 741 742

**System capability**: SystemCapability.Global.I18n

**Return value**

| Type     | Description                                      |
| ------- | ---------------------------------------- |
S
shawn_he 已提交
743
| boolean | The value **true** indicates that the local digit switch is turned on, and the value **false** indicates the opposite.|
S
shawn_he 已提交
744 745 746

**Error codes**

S
shawn_he 已提交
747
For details about the error codes, see [I18N Error Codes](../errorcodes/errorcode-i18n.md).
S
shawn_he 已提交
748

S
shawn_he 已提交
749 750
| ID | Error Message                  |
| ------ | ---------------------- |
S
shawn_he 已提交
751
| 890001 | param value not valid |
S
shawn_he 已提交
752 753 754

**Example**
  ```ts
S
shawn_he 已提交
755 756
  import { BusinessError } from '@ohos.base';
  
S
shawn_he 已提交
757
  try {
S
shawn_he 已提交
758
    let status: boolean = I18n.System.getUsingLocalDigit();  // Check whether the local digit switch is enabled.
S
shawn_he 已提交
759
  } catch(error) {
S
shawn_he 已提交
760
    let err: BusinessError = error as BusinessError;
S
shawn_he 已提交
761
    console.error(`call System.getUsingLocalDigit failed, error code: ${err.code}, message: ${err.message}.`);
S
shawn_he 已提交
762 763 764 765
  }
  ```


S
shawn_he 已提交
766
## I18n.isRTL<sup>7+</sup>
S
shawn_he 已提交
767 768 769

isRTL(locale: string): boolean

S
shawn_he 已提交
770
Checks whether a locale uses an RTL language.
S
shawn_he 已提交
771 772 773 774 775

**System capability**: SystemCapability.Global.I18n

**Parameters**

S
shawn_he 已提交
776 777 778
| Name   | Type    | Mandatory  | Description     |
| ------ | ------ | ---- | ------- |
| locale | string | Yes   | Locale ID.|
S
shawn_he 已提交
779 780 781 782 783

**Return value**

| Type     | Description                                      |
| ------- | ---------------------------------------- |
S
shawn_he 已提交
784
| boolean | The value **true** indicates that the localized script is displayed from right to left, and the value **false** indicates the opposite.|
S
shawn_he 已提交
785 786

**Example**
S
shawn_he 已提交
787
  ```ts
S
shawn_he 已提交
788 789 790 791 792
  i18n.isRTL("zh-CN");// Since Chinese is not written from right to left, false is returned.
  i18n.isRTL("ar-EG");// Since Arabic is written from right to left, true is returned.
  ```


S
shawn_he 已提交
793
## I18n.getCalendar<sup>8+</sup>
S
shawn_he 已提交
794 795 796 797 798 799 800 801 802 803 804 805

getCalendar(locale: string, type? : string): Calendar

Obtains a **Calendar** object.

**System capability**: SystemCapability.Global.I18n

**Parameters**

| Name   | Type    | Mandatory  | Description                                      |
| ------ | ------ | ---- | ---------------------------------------- |
| locale | string | Yes   | Valid locale value, for example, **zh-Hans-CN**.                |
S
shawn_he 已提交
806
| 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.|
S
shawn_he 已提交
807 808 809 810 811 812 813 814

**Return value**

| Type                    | Description   |
| ---------------------- | ----- |
| [Calendar](#calendar8) | **Calendar** object.|

**Example**
S
shawn_he 已提交
815
  ```ts
S
shawn_he 已提交
816
  I18n.getCalendar("zh-Hans", "chinese"); // Obtain the Calendar object for the Chinese lunar calendar.
S
shawn_he 已提交
817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837
  ```


## Calendar<sup>8+</sup>


### setTime<sup>8+</sup>

setTime(date: Date): void

Sets the date for this **Calendar** object.

**System capability**: SystemCapability.Global.I18n

**Parameters**

| Name | Type  | Mandatory  | Description               |
| ---- | ---- | ---- | ----------------- |
| date | Date | Yes   | Date to be set for the **Calendar** object.|

**Example**
S
shawn_he 已提交
838 839 840
  ```ts
  let calendar: I18n.Calendar = I18n.getCalendar("en-US", "gregory");
  let date: Date = new Date(2021, 10, 7, 8, 0, 0, 0);
S
shawn_he 已提交
841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859
  calendar.setTime(date);
  ```


### setTime<sup>8+</sup>

setTime(time: number): void

Sets 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).

**System capability**: SystemCapability.Global.I18n

**Parameters**

| Name | Type    | Mandatory  | Description                                      |
| ---- | ------ | ---- | ---------------------------------------- |
| time | number | Yes   | Number of milliseconds that have elapsed since the Unix epoch.|

**Example**
S
shawn_he 已提交
860 861
  ```ts
  let calendar: I18n.Calendar = I18n.getCalendar("en-US", "gregory");
S
shawn_he 已提交
862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880
  calendar.setTime(10540800000);
  ```


### set<sup>8+</sup>

set(year: number, month: number, date:number, hour?: number, minute?: number, second?: number): void

Sets the year, month, day, hour, minute, and second for this **Calendar** object.

**System capability**: SystemCapability.Global.I18n

**Parameters**

| Name   | Type    | Mandatory  | Description    |
| ------ | ------ | ---- | ------ |
| year   | number | Yes   | Year to set. |
| month  | number | Yes   | Month to set. |
| date   | number | Yes   | Day to set. |
S
shawn_he 已提交
881 882 883
| hour   | number | No   | Hour to set. The default value is the system hour.|
| minute | number | No   | Minute to set. The default value is the system minute.|
| second | number | No   | Second to set. The default value is the system second.|
S
shawn_he 已提交
884 885

**Example**
S
shawn_he 已提交
886 887
  ```ts
  let calendar: I18n.Calendar = I18n.getCalendar("zh-Hans");
S
shawn_he 已提交
888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906
  calendar.set(2021, 10, 1, 8, 0, 0); // set time to 2021.10.1 08:00:00
  ```


### setTimeZone<sup>8+</sup>

setTimeZone(timezone: string): void

Sets the time zone of this **Calendar** object.

**System capability**: SystemCapability.Global.I18n

**Parameters**

| Name     | Type    | Mandatory  | Description                       |
| -------- | ------ | ---- | ------------------------- |
| timezone | string | Yes   | Time zone, for example, **Asia/Shanghai**.|

**Example**
S
shawn_he 已提交
907 908
  ```ts
  let calendar: I18n.Calendar = I18n.getCalendar("zh-Hans");
S
shawn_he 已提交
909 910 911 912 913 914 915 916 917 918 919 920
  calendar.setTimeZone("Asia/Shanghai");
  ```


### getTimeZone<sup>8+</sup>

getTimeZone(): string

Obtains the time zone of this **Calendar** object.

**System capability**: SystemCapability.Global.I18n

S
shawn_he 已提交
921
**Return value**
S
shawn_he 已提交
922

S
shawn_he 已提交
923 924 925
| Type    | Description        |
| ------ | ---------- |
| string | Time zone of the **Calendar** object.|
S
shawn_he 已提交
926

S
shawn_he 已提交
927
**Example**
S
shawn_he 已提交
928 929
  ```ts
  let calendar: I18n.Calendar = I18n.getCalendar("zh-Hans");
S
shawn_he 已提交
930
  calendar.setTimeZone("Asia/Shanghai");
S
shawn_he 已提交
931
  let timezone: string = calendar.getTimeZone(); // timezone = "Asia/Shanghai"
S
shawn_he 已提交
932 933 934 935 936 937 938 939 940 941 942
  ```


### getFirstDayOfWeek<sup>8+</sup>

getFirstDayOfWeek(): number

Obtains the start day of a week for this **Calendar** object.

**System capability**: SystemCapability.Global.I18n

S
shawn_he 已提交
943
**Return value**
S
shawn_he 已提交
944

S
shawn_he 已提交
945 946 947
| Type    | Description                   |
| ------ | --------------------- |
| number | Start day of a week. The value **1** indicates Sunday, and the value **7** indicates Saturday.|
S
shawn_he 已提交
948

S
shawn_he 已提交
949
**Example**
S
shawn_he 已提交
950 951 952
  ```ts
  let calendar: I18n.Calendar = I18n.getCalendar("en-US", "gregory");
  let firstDayOfWeek: number = calendar.getFirstDayOfWeek(); // firstDayOfWeek = 1
S
shawn_he 已提交
953 954 955 956 957 958 959 960 961 962 963
  ```


### setFirstDayOfWeek<sup>8+</sup>

setFirstDayOfWeek(value: number): void

Sets the start day of a week for this **Calendar** object.

**System capability**: SystemCapability.Global.I18n

S
shawn_he 已提交
964
**Parameters**
S
shawn_he 已提交
965

S
shawn_he 已提交
966 967
| Name  | Type    | Mandatory  | Description                   |
| ----- | ------ | ---- | --------------------- |
S
shawn_he 已提交
968
| value | number | Yes   | Start day of a week. The value **1** indicates Sunday, and the value **7** indicates Saturday.|
Z
zengyawen 已提交
969

S
shawn_he 已提交
970
**Example**
S
shawn_he 已提交
971 972
  ```ts
  let calendar: I18n.Calendar = I18n.getCalendar("zh-Hans");
S
shawn_he 已提交
973
  calendar.setFirstDayOfWeek(3);
S
shawn_he 已提交
974
  let firstDayOfWeek: number = calendar.getFirstDayOfWeek(); // firstDayOfWeek = 3
S
shawn_he 已提交
975
  ```
Z
zengyawen 已提交
976 977


S
shawn_he 已提交
978
### getMinimalDaysInFirstWeek<sup>8+</sup>
Z
zengyawen 已提交
979

S
shawn_he 已提交
980 981 982 983 984 985
getMinimalDaysInFirstWeek(): number

Obtains the minimum number of days in the first week of a year.

**System capability**: SystemCapability.Global.I18n

S
shawn_he 已提交
986
**Return value**
S
shawn_he 已提交
987

S
shawn_he 已提交
988 989 990
| Type    | Description          |
| ------ | ------------ |
| number | Minimum number of days in the first week of a year.|
S
shawn_he 已提交
991

S
shawn_he 已提交
992
**Example**
S
shawn_he 已提交
993 994 995
  ```ts
  let calendar: I18n.Calendar = I18n.getCalendar("zh-Hans");
  let minimalDaysInFirstWeek: number = calendar.getMinimalDaysInFirstWeek(); // minimalDaysInFirstWeek = 1
S
shawn_he 已提交
996
  ```
Z
zengyawen 已提交
997 998


S
shawn_he 已提交
999
### setMinimalDaysInFirstWeek<sup>8+</sup>
Z
zengyawen 已提交
1000

S
shawn_he 已提交
1001
setMinimalDaysInFirstWeek(value: number): void
Z
zengyawen 已提交
1002 1003 1004

Sets the minimum number of days in the first week of a year.

S
shawn_he 已提交
1005 1006
**System capability**: SystemCapability.Global.I18n

S
shawn_he 已提交
1007
**Parameters**
S
shawn_he 已提交
1008

S
shawn_he 已提交
1009 1010
| Name  | Type    | Mandatory  | Description          |
| ----- | ------ | ---- | ------------ |
S
shawn_he 已提交
1011
| value | number | Yes   | Minimum number of days in the first week of a year.|
S
shawn_he 已提交
1012

S
shawn_he 已提交
1013
**Example**
S
shawn_he 已提交
1014 1015
  ```ts
  let calendar: I18n.Calendar = I18n.getCalendar("zh-Hans");
S
shawn_he 已提交
1016
  calendar.setMinimalDaysInFirstWeek(3);
S
shawn_he 已提交
1017
  let minimalDaysInFirstWeek: number = calendar.getMinimalDaysInFirstWeek(); // minimalDaysInFirstWeek = 3
S
shawn_he 已提交
1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028
  ```


### get<sup>8+</sup>

get(field: string): number

Obtains the value of the specified field in the **Calendar** object.

**System capability**: SystemCapability.Global.I18n

S
shawn_he 已提交
1029
**Parameters**
S
shawn_he 已提交
1030

S
shawn_he 已提交
1031 1032 1033
| Name  | Type    | Mandatory  | Description                                      |
| ----- | ------ | ---- | ---------------------------------------- |
| 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**.|
S
shawn_he 已提交
1034

S
shawn_he 已提交
1035
**Return value**
S
shawn_he 已提交
1036

S
shawn_he 已提交
1037 1038 1039
| Type    | Description                                      |
| ------ | ---------------------------------------- |
| 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**.|
S
shawn_he 已提交
1040

S
shawn_he 已提交
1041
**Example**
S
shawn_he 已提交
1042 1043
  ```ts
  let calendar: I18n.Calendar = I18n.getCalendar("zh-Hans");
S
shawn_he 已提交
1044
  calendar.set(2021, 10, 1, 8, 0, 0); // set time to 2021.10.1 08:00:00
S
shawn_he 已提交
1045
  let hourOfDay: number = calendar.get("hour_of_day"); // hourOfDay = 8
S
shawn_he 已提交
1046 1047 1048 1049 1050 1051 1052
  ```


### getDisplayName<sup>8+</sup>

getDisplayName(locale: string): string

S
shawn_he 已提交
1053
Obtains the displayed name of the **Calendar** object for the specified locale.
S
shawn_he 已提交
1054 1055 1056

**System capability**: SystemCapability.Global.I18n

S
shawn_he 已提交
1057
**Parameters**
S
shawn_he 已提交
1058

S
shawn_he 已提交
1059 1060
| Name   | Type    | Mandatory  | Description                                      |
| ------ | ------ | ---- | ---------------------------------------- |
S
shawn_he 已提交
1061
| locale | string | Yes   | Locale for the displayed name of the **Calendar** object. For example, displayed name of **buddhist** is **Buddhist&nbsp;Calendar** when the locale is set to **en-US**.|
S
shawn_he 已提交
1062

S
shawn_he 已提交
1063
**Return value**
S
shawn_he 已提交
1064

S
shawn_he 已提交
1065 1066
| Type    | Description                 |
| ------ | ------------------- |
S
shawn_he 已提交
1067
| string | Displayed name of the **Calendar** object for the specified locale.|
S
shawn_he 已提交
1068

S
shawn_he 已提交
1069
**Example**
S
shawn_he 已提交
1070 1071 1072
  ```ts
  let calendar: I18n.Calendar = I18n.getCalendar("en-US", "buddhist");
  let calendarName: string = calendar.getDisplayName("zh"); // calendarName = "Buddhist Calendar"
S
shawn_he 已提交
1073 1074 1075 1076 1077 1078 1079
  ```


### isWeekend<sup>8+</sup>

isWeekend(date?: Date): boolean

S
shawn_he 已提交
1080
Checks whether a given date is a weekend in the calendar.
S
shawn_he 已提交
1081 1082 1083

**System capability**: SystemCapability.Global.I18n

S
shawn_he 已提交
1084
**Parameters**
S
shawn_he 已提交
1085

S
shawn_he 已提交
1086 1087
| Name | Type  | Mandatory  | Description                                      |
| ---- | ---- | ---- | ---------------------------------------- |
S
shawn_he 已提交
1088
| 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.|
S
shawn_he 已提交
1089

S
shawn_he 已提交
1090
**Return value**
S
shawn_he 已提交
1091

S
shawn_he 已提交
1092 1093
| Type     | Description                                 |
| ------- | ----------------------------------- |
S
shawn_he 已提交
1094
| boolean | The value **true** indicates that the specified date is a weekend, and the value **false** indicates the opposite.|
S
shawn_he 已提交
1095

S
shawn_he 已提交
1096
**Example**
S
shawn_he 已提交
1097 1098
  ```ts
  let calendar: I18n.Calendar = I18n.getCalendar("zh-Hans");
S
shawn_he 已提交
1099
  calendar.set(2021, 11, 11, 8, 0, 0); // set time to 2021.11.11 08:00:00
S
shawn_he 已提交
1100
  calendar.isWeekend(); // false
S
shawn_he 已提交
1101
  let date: Date = new Date(2011, 11, 6, 9, 0, 0);
S
shawn_he 已提交
1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115
  calendar.isWeekend(date); // true
  ```


## PhoneNumberFormat<sup>8+</sup>


### constructor<sup>8+</sup>

constructor(country: string, options?: PhoneNumberFormatOptions)

Creates a **PhoneNumberFormat** object.

**System capability**: SystemCapability.Global.I18n
Z
zengyawen 已提交
1116

S
shawn_he 已提交
1117 1118
**Parameters**

S
shawn_he 已提交
1119 1120 1121
| Name    | Type                                      | Mandatory  | Description              |
| ------- | ---------------------------------------- | ---- | ---------------- |
| country | string                                   | Yes   | Country or region to which the phone number to be formatted belongs.|
S
shawn_he 已提交
1122
| options | [PhoneNumberFormatOptions](#phonenumberformatoptions8) | No   | Options of the **PhoneNumberFormat** object. The default value is **NATIONAL**. |
Z
zengyawen 已提交
1123

S
shawn_he 已提交
1124
**Example**
S
shawn_he 已提交
1125 1126 1127
  ```ts
  let option: I18n.PhoneNumberFormatOptions = {type: "E164"};
  let phoneNumberFormat: I18n.PhoneNumberFormat = new I18n.PhoneNumberFormat("CN", option);
S
shawn_he 已提交
1128 1129 1130 1131 1132 1133
  ```


### isValidNumber<sup>8+</sup>

isValidNumber(number: string): boolean
Z
zengyawen 已提交
1134 1135 1136

Checks whether the format of the specified phone number is valid.

S
shawn_he 已提交
1137 1138
**System capability**: SystemCapability.Global.I18n

S
shawn_he 已提交
1139
**Parameters**
S
shawn_he 已提交
1140

S
shawn_he 已提交
1141 1142 1143
| Name   | Type    | Mandatory  | Description       |
| ------ | ------ | ---- | --------- |
| number | string | Yes   | Phone number to be checked.|
S
shawn_he 已提交
1144

S
shawn_he 已提交
1145
**Return value**
S
shawn_he 已提交
1146

S
shawn_he 已提交
1147 1148
| Type     | Description                                   |
| ------- | ------------------------------------- |
S
shawn_he 已提交
1149
| boolean | The value **true** indicates that the phone number format is valid, and the value **false** indicates the opposite.|
S
shawn_he 已提交
1150

S
shawn_he 已提交
1151
**Example**
S
shawn_he 已提交
1152 1153 1154
  ```ts
  let phonenumberfmt: I18n.PhoneNumberFormat = new I18n.PhoneNumberFormat("CN");
  let isValidNumber: boolean = phonenumberfmt.isValidNumber("15812312312"); // isValidNumber = true
S
shawn_he 已提交
1155 1156 1157 1158 1159 1160
  ```


### format<sup>8+</sup>

format(number: string): string
Z
zengyawen 已提交
1161 1162 1163

Formats a phone number.

S
shawn_he 已提交
1164 1165
**System capability**: SystemCapability.Global.I18n

S
shawn_he 已提交
1166
**Parameters**
S
shawn_he 已提交
1167

S
shawn_he 已提交
1168 1169 1170
| Name   | Type    | Mandatory  | Description        |
| ------ | ------ | ---- | ---------- |
| number | string | Yes   | Phone number to be formatted.|
S
shawn_he 已提交
1171

S
shawn_he 已提交
1172
**Return value**
S
shawn_he 已提交
1173

S
shawn_he 已提交
1174 1175 1176
| Type    | Description        |
| ------ | ---------- |
| string | Formatted phone number.|
S
shawn_he 已提交
1177

S
shawn_he 已提交
1178
**Example**
S
shawn_he 已提交
1179 1180 1181
  ```ts
  let phonenumberfmt: I18n.PhoneNumberFormat = new I18n.PhoneNumberFormat("CN");
  let formattedPhoneNumber: string = phonenumberfmt.format("15812312312"); // formattedPhoneNumber = "158 1231 2312"
S
shawn_he 已提交
1182 1183
  ```

S
shawn_he 已提交
1184

S
shawn_he 已提交
1185
### getLocationName<sup>9+</sup>
S
shawn_he 已提交
1186

S
shawn_he 已提交
1187
getLocationName(number: string, locale: string): string
S
shawn_he 已提交
1188 1189 1190 1191 1192 1193

Obtains the home location of a phone number.

**System capability**: SystemCapability.Global.I18n

**Parameters**
S
shawn_he 已提交
1194

S
shawn_he 已提交
1195 1196
| Name   | Type    | Mandatory  | Description  |
| ------ | ------ | ---- | ---- |
S
shawn_he 已提交
1197 1198 1199 1200
| number | string | Yes   | Phone number.|
| locale | string | Yes   | Locale ID.|

**Return value**
S
shawn_he 已提交
1201

S
shawn_he 已提交
1202 1203
| Type    | Description      |
| ------ | -------- |
S
shawn_he 已提交
1204 1205 1206
| string | Home location of the phone number.|

**Example**
S
shawn_he 已提交
1207 1208 1209
  ```ts
  let phonenumberfmt: I18n.PhoneNumberFormat = new I18n.PhoneNumberFormat("CN");
  let locationName: string = phonenumberfmt.getLocationName("15812312345", "zh-CN"); // locationName = "Zhanjiang, Guangdong Province"
S
shawn_he 已提交
1210 1211
  ```

S
shawn_he 已提交
1212

S
shawn_he 已提交
1213
## PhoneNumberFormatOptions<sup>8+</sup>
S
shawn_he 已提交
1214 1215 1216

Defines the options for this PhoneNumberFormat object.

S
shawn_he 已提交
1217
**System capability**: SystemCapability.Global.I18n
S
shawn_he 已提交
1218

S
shawn_he 已提交
1219
| Name  | Type    | Readable  | Writable  | Description                                      |
S
shawn_he 已提交
1220
| ---- | ------ | ---- | ---- | ---------------------------------------- |
S
shawn_he 已提交
1221
| type | string | Yes   | Yes   | Format type of a phone number. The available options are as follows: E164,&nbsp;INTERNATIONAL,&nbsp;NATIONAL, and&nbsp;RFC3966.<br>- In API version 8, **type** is mandatory.<br>- In API version 9 or later, **type** is optional.|
S
shawn_he 已提交
1222 1223 1224


## UnitInfo<sup>8+</sup>
Z
zengyawen 已提交
1225 1226 1227

Defines the measurement unit information.

S
shawn_he 已提交
1228
**System capability**: SystemCapability.Global.I18n
S
shawn_he 已提交
1229

S
shawn_he 已提交
1230
| Name           | Type    | Readable  | Writable  | Description                                      |
S
shawn_he 已提交
1231 1232
| ------------- | ------ | ---- | ---- | ---------------------------------------- |
| unit          | string | Yes   | Yes   | Name of the measurement unit, for example, **meter**, **inch**, or **cup**.|
S
shawn_he 已提交
1233
| measureSystem | string | Yes   | Yes   | Measurement system. The value can be **SI**,&nbsp;**US**, or&nbsp;**UK**.|
S
shawn_he 已提交
1234 1235


S
shawn_he 已提交
1236
## getInstance<sup>8+</sup>
S
shawn_he 已提交
1237

S
shawn_he 已提交
1238
getInstance(locale?:string): IndexUtil
S
shawn_he 已提交
1239 1240 1241 1242 1243

Creates an **IndexUtil** object.

**System capability**: SystemCapability.Global.I18n

S
shawn_he 已提交
1244
**Parameters**
S
shawn_he 已提交
1245

S
shawn_he 已提交
1246 1247
| Name   | Type    | Mandatory  | Description                          |
| ------ | ------ | ---- | ---------------------------- |
S
shawn_he 已提交
1248
| locale | string | No   | A string containing locale information, including the language, optional script, and region. The default value is the system locale.|
S
shawn_he 已提交
1249

S
shawn_he 已提交
1250
**Return value**
S
shawn_he 已提交
1251

S
shawn_he 已提交
1252 1253
| Type                      | Description                   |
| ------------------------ | --------------------- |
S
shawn_he 已提交
1254
| [IndexUtil](#indexutil8) | **IndexUtil** object mapping to the **locale** object.|
S
shawn_he 已提交
1255

S
shawn_he 已提交
1256
**Example**
S
shawn_he 已提交
1257 1258
  ```ts
  let indexUtil: I18n.IndexUtil = I18n.getInstance("zh-CN");
S
shawn_he 已提交
1259 1260 1261
  ```


S
shawn_he 已提交
1262 1263 1264
## IndexUtil<sup>8+</sup>


S
shawn_he 已提交
1265 1266 1267 1268 1269 1270 1271 1272
### getIndexList<sup>8+</sup>

getIndexList(): Array&lt;string&gt;

Obtains the index list for this **locale** object.

**System capability**: SystemCapability.Global.I18n

S
shawn_he 已提交
1273
**Return value**
S
shawn_he 已提交
1274

S
shawn_he 已提交
1275 1276
| Type                 | Description                |
| ------------------- | ------------------ |
S
shawn_he 已提交
1277
| Array&lt;string&gt; | Index list for the **locale** object.|
S
shawn_he 已提交
1278

S
shawn_he 已提交
1279
**Example**
S
shawn_he 已提交
1280 1281
  ```ts
  let indexUtil: I18n.IndexUtil = I18n.getInstance("zh-CN");
S
shawn_he 已提交
1282 1283
  // indexList = [ "...", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N",
  //              "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "..." ]
S
shawn_he 已提交
1284
  let indexList: Array<string> = indexUtil.getIndexList();
S
shawn_he 已提交
1285 1286 1287 1288 1289
  ```


### addLocale<sup>8+</sup>

S
shawn_he 已提交
1290
addLocale(locale: string): void
S
shawn_he 已提交
1291

S
shawn_he 已提交
1292
Adds a **locale** object to the current index list.
S
shawn_he 已提交
1293 1294 1295

**System capability**: SystemCapability.Global.I18n

S
shawn_he 已提交
1296
**Parameters**
S
shawn_he 已提交
1297

S
shawn_he 已提交
1298 1299 1300
| Name   | Type    | Mandatory  | Description                          |
| ------ | ------ | ---- | ---------------------------- |
| locale | string | Yes   | A string containing locale information, including the language, optional script, and region.|
S
shawn_he 已提交
1301

S
shawn_he 已提交
1302
**Example**
S
shawn_he 已提交
1303 1304
  ```ts
  let indexUtil: I18n.IndexUtil = I18n.getInstance("zh-CN");
S
shawn_he 已提交
1305 1306 1307 1308 1309 1310 1311 1312
  indexUtil.addLocale("en-US");
  ```


### getIndex<sup>8+</sup>

getIndex(text: string): string

S
shawn_he 已提交
1313
Obtains the index of a **text** object.
S
shawn_he 已提交
1314 1315 1316

**System capability**: SystemCapability.Global.I18n

S
shawn_he 已提交
1317
**Parameters**
S
shawn_he 已提交
1318

S
shawn_he 已提交
1319 1320 1321
| Name | Type    | Mandatory  | Description          |
| ---- | ------ | ---- | ------------ |
| text | string | Yes   | **text** object whose index is to be obtained.|
S
shawn_he 已提交
1322

S
shawn_he 已提交
1323
**Return value**
S
shawn_he 已提交
1324

S
shawn_he 已提交
1325 1326 1327
| Type    | Description         |
| ------ | ----------- |
| string | Index of the **text** object.|
S
shawn_he 已提交
1328

S
shawn_he 已提交
1329
**Example**
S
shawn_he 已提交
1330 1331 1332
  ```ts
  let indexUtil: I18n.IndexUtil = I18n.getInstance("zh-CN");
  let index: string = indexUtil.getIndex("hi");  // index = "H"
S
shawn_he 已提交
1333 1334 1335
  ```


S
shawn_he 已提交
1336
## I18n.getLineInstance<sup>8+</sup>
S
shawn_he 已提交
1337

S
shawn_he 已提交
1338
getLineInstance(locale: string): BreakIterator
S
shawn_he 已提交
1339

S
shawn_he 已提交
1340
Obtains a [BreakIterator](#breakiterator8) object for text segmentation.
Z
zengyawen 已提交
1341

S
shawn_he 已提交
1342
**System capability**: SystemCapability.Global.I18n
Z
zengyawen 已提交
1343

S
shawn_he 已提交
1344
**Parameters**
S
shawn_he 已提交
1345

S
shawn_he 已提交
1346 1347 1348
| Name   | Type    | Mandatory  | Description                                      |
| ------ | ------ | ---- | ---------------------------------------- |
| 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.|
Z
zengyawen 已提交
1349

S
shawn_he 已提交
1350
**Return value**
S
shawn_he 已提交
1351

S
shawn_he 已提交
1352 1353 1354
| Type                              | Description         |
| -------------------------------- | ----------- |
| [BreakIterator](#breakiterator8) | [BreakIterator](#breakiterator8) object used for text segmentation.|
Z
zengyawen 已提交
1355

S
shawn_he 已提交
1356
**Example**
S
shawn_he 已提交
1357 1358
  ```ts
  let iterator: I18n.BreakIterator = I18n.getLineInstance("en");
S
shawn_he 已提交
1359
  ```
Z
zengyawen 已提交
1360 1361


S
shawn_he 已提交
1362
## BreakIterator<sup>8+</sup>
Z
zengyawen 已提交
1363 1364


S
shawn_he 已提交
1365
### setLineBreakText<sup>8+</sup>
Z
zengyawen 已提交
1366

S
shawn_he 已提交
1367
setLineBreakText(text: string): void
Z
zengyawen 已提交
1368

S
shawn_he 已提交
1369
Sets the text to be processed by the **BreakIterator** object.
Z
zengyawen 已提交
1370

S
shawn_he 已提交
1371
**System capability**: SystemCapability.Global.I18n
Z
zengyawen 已提交
1372

S
shawn_he 已提交
1373
**Parameters**
S
shawn_he 已提交
1374

S
shawn_he 已提交
1375 1376 1377
| Name | Type    | Mandatory  | Description                     |
| ---- | ------ | ---- | ----------------------- |
| text | string | Yes   | Text to be processed by the **BreakIterator** object.|
Z
zengyawen 已提交
1378

S
shawn_he 已提交
1379
**Example**
S
shawn_he 已提交
1380 1381
  ```ts
  let iterator: I18n.BreakIterator = I18n.getLineInstance("en");
S
shawn_he 已提交
1382
  iterator.setLineBreakText("Apple is my favorite fruit ."); // Set a short sentence as the text to be processed by the BreakIterator object.
S
shawn_he 已提交
1383
  ```
Z
zengyawen 已提交
1384 1385


S
shawn_he 已提交
1386
### getLineBreakText<sup>8+</sup>
Z
zengyawen 已提交
1387

S
shawn_he 已提交
1388
getLineBreakText(): string
Z
zengyawen 已提交
1389

S
shawn_he 已提交
1390
Obtains the text being processed by the **BreakIterator** object.
Z
zengyawen 已提交
1391

S
shawn_he 已提交
1392
**System capability**: SystemCapability.Global.I18n
Z
zengyawen 已提交
1393

S
shawn_he 已提交
1394
**Return value**
S
shawn_he 已提交
1395

S
shawn_he 已提交
1396 1397 1398
| Type    | Description                    |
| ------ | ---------------------- |
| string | Text being processed by the **BreakIterator** object.|
Z
zengyawen 已提交
1399

S
shawn_he 已提交
1400
**Example**
S
shawn_he 已提交
1401 1402
  ```ts
  let iterator: I18n.BreakIterator = I18n.getLineInstance("en");
S
shawn_he 已提交
1403
  iterator.setLineBreakText("Apple is my favorite fruit.");
S
shawn_he 已提交
1404
  let breakText: string = iterator.getLineBreakText(); // breakText = "Apple is my favorite fruit."
S
shawn_he 已提交
1405
  ```
Z
zengyawen 已提交
1406 1407


S
shawn_he 已提交
1408
### current<sup>8+</sup>
Z
zengyawen 已提交
1409

S
shawn_he 已提交
1410 1411
current(): number

S
shawn_he 已提交
1412
Obtains the position of the **BreakIterator** object in the text being processed.
S
shawn_he 已提交
1413 1414 1415

**System capability**: SystemCapability.Global.I18n

S
shawn_he 已提交
1416
**Return value**
S
shawn_he 已提交
1417

S
shawn_he 已提交
1418 1419 1420
| Type    | Description                         |
| ------ | --------------------------- |
| number | Position of the **BreakIterator** object in the text being processed.|
S
shawn_he 已提交
1421

S
shawn_he 已提交
1422
**Example**
S
shawn_he 已提交
1423 1424
  ```ts
  let iterator: I18n.BreakIterator = I18n.getLineInstance("en");
S
shawn_he 已提交
1425
  iterator.setLineBreakText("Apple is my favorite fruit.");
S
shawn_he 已提交
1426
  let currentPos: number = iterator.current(); // currentPos = 0
S
shawn_he 已提交
1427 1428 1429 1430 1431 1432 1433
  ```


### first<sup>8+</sup>

first(): number

S
shawn_he 已提交
1434
Puts the **BreakIterator** object to the first break point, which is always at the beginning of the processed text.
S
shawn_he 已提交
1435 1436 1437

**System capability**: SystemCapability.Global.I18n

S
shawn_he 已提交
1438
**Return value**
S
shawn_he 已提交
1439

S
shawn_he 已提交
1440 1441
| Type    | Description               |
| ------ | ----------------- |
S
shawn_he 已提交
1442
| number | Offset to the first break point of the processed text.|
S
shawn_he 已提交
1443

S
shawn_he 已提交
1444
**Example**
S
shawn_he 已提交
1445 1446
  ```ts
  let iterator: I18n.BreakIterator = I18n.getLineInstance("en");
S
shawn_he 已提交
1447
  iterator.setLineBreakText("Apple is my favorite fruit.");
S
shawn_he 已提交
1448
  let firstPos: number = iterator.first(); // firstPos = 0
S
shawn_he 已提交
1449 1450 1451 1452 1453 1454 1455
  ```


### last<sup>8+</sup>

last(): number

S
shawn_he 已提交
1456
Puts the **BreakIterator** object to the last break point, which is always the next position after the end of the processed text.
S
shawn_he 已提交
1457 1458 1459

**System capability**: SystemCapability.Global.I18n

S
shawn_he 已提交
1460
**Return value**
S
shawn_he 已提交
1461

S
shawn_he 已提交
1462 1463
| Type    | Description                |
| ------ | ------------------ |
S
shawn_he 已提交
1464
| number | Offset to the last break point of the processed text.|
S
shawn_he 已提交
1465

S
shawn_he 已提交
1466
**Example**
S
shawn_he 已提交
1467 1468
  ```ts
  let iterator: I18n.BreakIterator = I18n.getLineInstance("en");
S
shawn_he 已提交
1469
  iterator.setLineBreakText("Apple is my favorite fruit.");
S
shawn_he 已提交
1470
  let lastPos: number = iterator.last(); // lastPos = 27
S
shawn_he 已提交
1471 1472 1473 1474 1475 1476 1477
  ```


### next<sup>8+</sup>

next(index?: number): number

S
shawn_he 已提交
1478
Moves the **BreakIterator** object backward by the corresponding number of break points.
S
shawn_he 已提交
1479 1480 1481

**System capability**: SystemCapability.Global.I18n

S
shawn_he 已提交
1482
**Parameters**
S
shawn_he 已提交
1483

S
shawn_he 已提交
1484 1485
| Name  | Type    | Mandatory  | Description                                      |
| ----- | ------ | ---- | ---------------------------------------- |
S
shawn_he 已提交
1486
| 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**.|
S
shawn_he 已提交
1487

S
shawn_he 已提交
1488
**Return value**
S
shawn_he 已提交
1489

S
shawn_he 已提交
1490 1491
| Type    | Description                                      |
| ------ | ---------------------------------------- |
S
shawn_he 已提交
1492
| 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.|
S
shawn_he 已提交
1493

S
shawn_he 已提交
1494
**Example**
S
shawn_he 已提交
1495 1496
  ```ts
  let iterator: I18n.BreakIterator = I18n.getLineInstance("en");
S
shawn_he 已提交
1497
  iterator.setLineBreakText("Apple is my favorite fruit.");
S
shawn_he 已提交
1498
  let pos: number = iterator.first(); // pos = 0
S
shawn_he 已提交
1499 1500
  pos = iterator.next(); // pos = 6
  pos = iterator.next(10); // pos = -1
S
shawn_he 已提交
1501 1502 1503 1504 1505 1506 1507
  ```


### previous<sup>8+</sup>

previous(): number

S
shawn_he 已提交
1508
Moves the **BreakIterator** object forward by one break point.
S
shawn_he 已提交
1509 1510 1511

**System capability**: SystemCapability.Global.I18n

S
shawn_he 已提交
1512
**Return value**
S
shawn_he 已提交
1513

S
shawn_he 已提交
1514 1515
| Type    | Description                                      |
| ------ | ---------------------------------------- |
S
shawn_he 已提交
1516
| 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.|
Z
zengyawen 已提交
1517

S
shawn_he 已提交
1518
**Example**
S
shawn_he 已提交
1519 1520
  ```ts
  let iterator: I18n.BreakIterator = I18n.getLineInstance("en");
S
shawn_he 已提交
1521
  iterator.setLineBreakText("Apple is my favorite fruit.");
S
shawn_he 已提交
1522
  let pos: number = iterator.first(); // pos = 0
S
shawn_he 已提交
1523 1524
  pos = iterator.next(3); // pos = 12
  pos = iterator.previous(); // pos = 9
S
shawn_he 已提交
1525
  ```
Z
zengyawen 已提交
1526 1527


S
shawn_he 已提交
1528
### following<sup>8+</sup>
Z
zengyawen 已提交
1529

S
shawn_he 已提交
1530
following(offset: number): number
Z
zengyawen 已提交
1531

S
shawn_he 已提交
1532
Moves the **BreakIterator** to the break point following the specified position.
Z
zengyawen 已提交
1533

S
shawn_he 已提交
1534
**System capability**: SystemCapability.Global.I18n
Z
zengyawen 已提交
1535

S
shawn_he 已提交
1536
**Parameters**
S
shawn_he 已提交
1537

S
shawn_he 已提交
1538 1539
| Name   | Type    | Mandatory  | Description                                      |
| ------ | ------ | ---- | ---------------------------------------- |
S
shawn_he 已提交
1540
| offset | number | Yes   | Moves the **BreakIterator** to the break point following the specified position.|
Z
zengyawen 已提交
1541

S
shawn_he 已提交
1542
**Return value**
S
shawn_he 已提交
1543

S
shawn_he 已提交
1544 1545
| Type    | Description                                      |
| ------ | ---------------------------------------- |
S
shawn_he 已提交
1546
| number | The value **-1** is returned if the break point to which the **BreakIterator** object is moved is outside of the processed text.|
S
shawn_he 已提交
1547

S
shawn_he 已提交
1548
**Example**
S
shawn_he 已提交
1549 1550
  ```ts
  let iterator: I18n.BreakIterator = I18n.getLineInstance("en");
S
shawn_he 已提交
1551
  iterator.setLineBreakText("Apple is my favorite fruit.");
S
shawn_he 已提交
1552
  let pos: number = iterator.following(0); // pos = 6
S
shawn_he 已提交
1553 1554
  pos = iterator.following(100); // pos = -1
  pos = iterator.current(); // pos = 27
S
shawn_he 已提交
1555 1556 1557 1558 1559 1560 1561
  ```


### isBoundary<sup>8+</sup>

isBoundary(offset: number): boolean

S
shawn_he 已提交
1562
Checks whether the specified position of the text is a break point.
S
shawn_he 已提交
1563 1564 1565

**System capability**: SystemCapability.Global.I18n

S
shawn_he 已提交
1566
**Parameters**
S
shawn_he 已提交
1567

S
shawn_he 已提交
1568 1569
| Name   | Type    | Mandatory  | Description         |
| ------ | ------ | ---- | ----------- |
S
shawn_he 已提交
1570
| 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.|
S
shawn_he 已提交
1571

S
shawn_he 已提交
1572
**Return value**
S
shawn_he 已提交
1573

S
shawn_he 已提交
1574 1575
| Type     | Description                             |
| ------- | ------------------------------- |
S
shawn_he 已提交
1576
| boolean | The value **true** indicates that the position specified by the offset is a break point, and the value **false** indicates the opposite.|
S
shawn_he 已提交
1577

S
shawn_he 已提交
1578
**Example**
S
shawn_he 已提交
1579 1580
  ```ts
  let iterator: I18n.BreakIterator = I18n.getLineInstance("en");
S
shawn_he 已提交
1581
  iterator.setLineBreakText("Apple is my favorite fruit.");
S
shawn_he 已提交
1582
  let isBoundary: boolean = iterator.isBoundary(0); // isBoundary = true;
S
shawn_he 已提交
1583
  isBoundary = iterator.isBoundary(5); // isBoundary = false;
S
shawn_he 已提交
1584 1585 1586
  ```


S
shawn_he 已提交
1587
## I18n.getTimeZone<sup>7+</sup>
S
shawn_he 已提交
1588

S
shawn_he 已提交
1589
getTimeZone(zoneID?: string): TimeZone
S
shawn_he 已提交
1590

S
shawn_he 已提交
1591
Obtains the **TimeZone** object corresponding to the specified time zone ID.
S
shawn_he 已提交
1592 1593 1594

**System capability**: SystemCapability.Global.I18n

S
shawn_he 已提交
1595 1596 1597 1598
**Parameters**

| Name   | Type    | Mandatory  | Description   |
| ------ | ------ | ---- | ----- |
S
shawn_he 已提交
1599
| zondID | string | No   | Time zone ID. The default value is the system time zone.|
S
shawn_he 已提交
1600

S
shawn_he 已提交
1601
**Return value**
S
shawn_he 已提交
1602

S
shawn_he 已提交
1603 1604 1605
| Type      | Description          |
| -------- | ------------ |
| TimeZone | **TimeZone** object corresponding to the time zone ID.|
S
shawn_he 已提交
1606

S
shawn_he 已提交
1607
**Example**
S
shawn_he 已提交
1608 1609
  ```ts
  let timezone: I18n.TimeZone = I18n.getTimeZone();
S
shawn_he 已提交
1610 1611 1612
  ```


S
shawn_he 已提交
1613
## TimeZone
Z
zengyawen 已提交
1614 1615


S
shawn_he 已提交
1616
### getID
S
shawn_he 已提交
1617

S
shawn_he 已提交
1618
getID(): string
S
shawn_he 已提交
1619

S
shawn_he 已提交
1620
Obtains the ID of the specified **TimeZone** object.
S
shawn_he 已提交
1621

S
shawn_he 已提交
1622
**System capability**: SystemCapability.Global.I18n
S
shawn_he 已提交
1623

S
shawn_he 已提交
1624
**Return value**
S
shawn_he 已提交
1625

S
shawn_he 已提交
1626 1627 1628
| Type    | Description          |
| ------ | ------------ |
| string | Time zone ID corresponding to the **TimeZone** object.|
S
shawn_he 已提交
1629

S
shawn_he 已提交
1630
**Example**
S
shawn_he 已提交
1631 1632 1633
  ```ts
  let timezone: I18n.TimeZone = I18n.getTimeZone();
  let timezoneID: string = timezone.getID(); // timezoneID = "Asia/Shanghai"
S
shawn_he 已提交
1634 1635 1636
  ```


S
shawn_he 已提交
1637
### getDisplayName
S
shawn_he 已提交
1638 1639 1640

getDisplayName(locale?: string, isDST?: boolean): string

S
shawn_he 已提交
1641
Obtains the localized representation of a **TimeZone** object.
S
shawn_he 已提交
1642 1643 1644

**System capability**: SystemCapability.Global.I18n

S
shawn_he 已提交
1645
**Parameters**
S
shawn_he 已提交
1646

S
shawn_he 已提交
1647 1648
| Name   | Type     | Mandatory  | Description                  |
| ------ | ------- | ---- | -------------------- |
S
shawn_he 已提交
1649 1650
| locale | string  | No   | Locale ID. The default value is the system locale.               |
| isDST  | boolean | No   | Whether DST is considered in the localized representation of the **TimeZone** object. The default value is **false**.|
S
shawn_he 已提交
1651

S
shawn_he 已提交
1652
**Return value**
S
shawn_he 已提交
1653

S
shawn_he 已提交
1654 1655 1656
| Type    | Description           |
| ------ | ------------- |
| string | Representation of the **TimeZone** object in the specified locale.|
S
shawn_he 已提交
1657

S
shawn_he 已提交
1658
**Example**
S
shawn_he 已提交
1659 1660 1661
  ```ts
  let timezone: I18n.TimeZone = I18n.getTimeZone();
  let timezoneName: string = timezone.getDisplayName("zh-CN", false); // timezoneName = "China Standard Time"
S
shawn_he 已提交
1662 1663 1664
  ```


S
shawn_he 已提交
1665
### getRawOffset
S
shawn_he 已提交
1666 1667 1668 1669 1670 1671 1672

getRawOffset(): number

Obtains the offset between the time zone represented by a **TimeZone** object and the UTC time zone.

**System capability**: SystemCapability.Global.I18n

S
shawn_he 已提交
1673
**Return value**
S
shawn_he 已提交
1674

S
shawn_he 已提交
1675 1676 1677
| Type    | Description                 |
| ------ | ------------------- |
| number | Offset between the time zone represented by the **TimeZone** object and the UTC time zone.|
S
shawn_he 已提交
1678

S
shawn_he 已提交
1679
**Example**
S
shawn_he 已提交
1680 1681 1682
  ```ts
  let timezone: I18n.TimeZone = I18n.getTimeZone();
  let offset: number = timezone.getRawOffset(); // offset = 28800000
S
shawn_he 已提交
1683 1684 1685
  ```


S
shawn_he 已提交
1686
### getOffset
S
shawn_he 已提交
1687 1688 1689 1690 1691 1692 1693

getOffset(date?: number): number

Obtains the offset between the time zone represented by a **TimeZone** object and the UTC time zone at a certain time point.

**System capability**: SystemCapability.Global.I18n

S
shawn_he 已提交
1694
**Return value**
S
shawn_he 已提交
1695

S
shawn_he 已提交
1696 1697
| Type    | Description                     |
| ------ | ----------------------- |
S
shawn_he 已提交
1698
| number | Offset between the time zone represented by the **TimeZone** object and the UTC time zone at a certain time point. The default value is the system time zone.|
S
shawn_he 已提交
1699

S
shawn_he 已提交
1700
**Example**
S
shawn_he 已提交
1701 1702 1703
  ```ts
  let timezone: I18n.TimeZone = I18n.getTimeZone();
  let offset: number = timezone.getOffset(1234567890); // offset = 28800000
S
shawn_he 已提交
1704
  ```
S
shawn_he 已提交
1705

S
shawn_he 已提交
1706

S
shawn_he 已提交
1707 1708 1709 1710 1711 1712 1713 1714 1715
### getAvailableIDs<sup>9+</sup>

static getAvailableIDs(): Array&lt;string&gt;

Obtains the list of time zone IDs supported by the system.

**System capability**: SystemCapability.Global.I18n

**Return value**
S
shawn_he 已提交
1716

S
shawn_he 已提交
1717 1718
| Type                 | Description         |
| ------------------- | ----------- |
S
shawn_he 已提交
1719 1720 1721
| Array&lt;string&gt; | List of time zone IDs supported by the system.|

**Example**
S
shawn_he 已提交
1722
  ```ts
S
shawn_he 已提交
1723
  // 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
S
shawn_he 已提交
1724
  let ids: Array<string> = I18n.TimeZone.getAvailableIDs();
S
shawn_he 已提交
1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736
  ```


### getAvailableZoneCityIDs<sup>9+</sup>

static getAvailableZoneCityIDs(): Array&lt;string&gt;

Obtains the list of time zone city IDs supported by the system.

**System capability**: SystemCapability.Global.I18n

**Return value**
S
shawn_he 已提交
1737

S
shawn_he 已提交
1738 1739
| Type                 | Description           |
| ------------------- | ------------- |
S
shawn_he 已提交
1740 1741 1742
| Array&lt;string&gt; | List of time zone city IDs supported by the system.|

**Example**
S
shawn_he 已提交
1743
  ```ts
S
shawn_he 已提交
1744
  // 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
S
shawn_he 已提交
1745
  let cityIDs: Array<string> = I18n.TimeZone.getAvailableZoneCityIDs();
S
shawn_he 已提交
1746 1747 1748 1749 1750 1751 1752
  ```


### getCityDisplayName<sup>9+</sup>

static getCityDisplayName(cityID: string, locale: string): string

S
shawn_he 已提交
1753
Obtains the localized representation of a time zone city in the specified locale.
S
shawn_he 已提交
1754 1755 1756 1757

**System capability**: SystemCapability.Global.I18n

**Parameters**
S
shawn_he 已提交
1758

S
shawn_he 已提交
1759 1760
| Name   | Type    | Mandatory  | Description    |
| ------ | ------ | ---- | ------ |
S
shawn_he 已提交
1761
| cityID | string | Yes   | Time zone city ID.|
S
shawn_he 已提交
1762
| locale | string | Yes   | Locale ID.  |
S
shawn_he 已提交
1763 1764

**Return value**
S
shawn_he 已提交
1765

S
shawn_he 已提交
1766 1767
| Type    | Description                |
| ------ | ------------------ |
S
shawn_he 已提交
1768
| string | Localized representation of the time zone city in the specified locale.|
S
shawn_he 已提交
1769 1770

**Example**
S
shawn_he 已提交
1771
  ```ts
S
shawn_he 已提交
1772
  let displayName: string = I18n.TimeZone.getCityDisplayName("Shanghai", "zh-CN"); // displayName = "Shanghai (China)"
S
shawn_he 已提交
1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784
  ```


### getTimezoneFromCity<sup>9+</sup>

static getTimezoneFromCity(cityID: string): TimeZone

Obtains the **TimeZone** object corresponding to the specified time zone city ID.

**System capability**: SystemCapability.Global.I18n

**Parameters**
S
shawn_he 已提交
1785

S
shawn_he 已提交
1786 1787
| Name   | Type    | Mandatory  | Description    |
| ------ | ------ | ---- | ------ |
S
shawn_he 已提交
1788 1789 1790
| cityID | string | Yes   | Time zone city ID.|

**Return value**
S
shawn_he 已提交
1791

S
shawn_he 已提交
1792 1793
| Type      | Description         |
| -------- | ----------- |
S
shawn_he 已提交
1794 1795 1796
| TimeZone | **TimeZone** object corresponding to the specified time zone city ID.|

**Example**
S
shawn_he 已提交
1797
  ```ts
S
shawn_he 已提交
1798
  let timezone: I18n.TimeZone = I18n.TimeZone.getTimezoneFromCity("Shanghai");
S
shawn_he 已提交
1799 1800
  ```

S
shawn_he 已提交
1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822
### getTimezonesByLocation<sup>10+</sup>

static getTimezonesByLocation(longitude: number, latitude: number): Array&lt;TimeZone&gt;

Creates an array of **TimeZone** objects corresponding to the specified longitude and latitude.

**System capability**: SystemCapability.Global.I18n

**Parameters**

| Name    | Type    | Mandatory  | Description    |
| --------- | ------ | ---- | ------ |
| 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.|
| 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.|

**Return value**

| Type      | Description         |
| -------- | ----------- |
| Array&lt;[TimeZone](#timezone)&gt; | Array of **TimeZone** objects.|

**Example**
S
shawn_he 已提交
1823 1824 1825 1826
  ```ts
  let timezoneArray: Array<I18n.TimeZone> = I18n.TimeZone.getTimezonesByLocation(-118.1, 34.0);
  for (let i = 0; i < timezoneArray.length; i++) {
      let tzId: string = timezoneArray[i].getID();
S
shawn_he 已提交
1827 1828 1829
  }
  ```

S
shawn_he 已提交
1830

S
shawn_he 已提交
1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842
## Transliterator<sup>9+</sup>


### getAvailableIDs<sup>9+</sup>

static getAvailableIDs(): string[]

Obtains a list of IDs supported by the **Transliterator** object.

**System capability**: SystemCapability.Global.I18n

**Return value**
S
shawn_he 已提交
1843

S
shawn_he 已提交
1844 1845
| Type      | Description        |
| -------- | ---------- |
S
shawn_he 已提交
1846 1847 1848
| string[] | List of IDs supported by the **Transliterator** object.|

**Example**
S
shawn_he 已提交
1849
  ```ts
S
shawn_he 已提交
1850 1851
  // 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.
  // For more information, see ISO-15924.
S
shawn_he 已提交
1852
  let ids: string[] = I18n.Transliterator.getAvailableIDs();
S
shawn_he 已提交
1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864
  ```


### getInstance<sup>9+</sup>

static getInstance(id: string): Transliterator

Creates a **Transliterator** object.

**System capability**: SystemCapability.Global.I18n

**Parameters**
S
shawn_he 已提交
1865

S
shawn_he 已提交
1866 1867 1868
| Name | Type    | Mandatory  | Description      |
| ---- | ------ | ---- | -------- |
| id   | string | Yes   | ID supported by the **Transliterator** object.|
S
shawn_he 已提交
1869 1870

**Return value**
S
shawn_he 已提交
1871

S
shawn_he 已提交
1872 1873
| Type                                | Description   |
| ---------------------------------- | ----- |
S
shawn_he 已提交
1874 1875 1876
| [Transliterator](#transliterator9) | **Transliterator** object.|

**Example**
S
shawn_he 已提交
1877
  ```ts
S
shawn_he 已提交
1878
  let transliterator: I18n.Transliterator = I18n.Transliterator.getInstance("Any-Latn");
S
shawn_he 已提交
1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890
  ```


### transform<sup>9+</sup>

transform(text: string): string

Converts the input string from the source format to the target format.

**System capability**: SystemCapability.Global.I18n

**Parameters**
S
shawn_he 已提交
1891

S
shawn_he 已提交
1892 1893 1894
| Name | Type    | Mandatory  | Description    |
| ---- | ------ | ---- | ------ |
| text | string | Yes   | Input string.|
S
shawn_he 已提交
1895 1896

**Return value**
S
shawn_he 已提交
1897

S
shawn_he 已提交
1898 1899
| Type    | Description      |
| ------ | -------- |
S
shawn_he 已提交
1900 1901 1902
| string | Target string.|

**Example**
S
shawn_he 已提交
1903
  ```ts
S
shawn_he 已提交
1904 1905
  let transliterator: I18n.Transliterator = I18n.Transliterator.getInstance("Any-Latn");
  let res: string = transliterator.transform("China"); // res = "zhōng guó"
S
shawn_he 已提交
1906
  ```
S
shawn_he 已提交
1907

S
shawn_he 已提交
1908

S
shawn_he 已提交
1909 1910 1911 1912 1913 1914 1915
## Unicode<sup>9+</sup>


### isDigit<sup>9+</sup>

static isDigit(char: string): boolean

S
shawn_he 已提交
1916
Checks whether the input string is composed of digits.
S
shawn_he 已提交
1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929

**System capability**: SystemCapability.Global.I18n

**Parameters**

| Name | Type    | Mandatory  | Description   |
| ---- | ------ | ---- | ----- |
| char | string | Yes   | Input character.|

**Return value**

| Type     | Description                                  |
| ------- | ------------------------------------ |
S
shawn_he 已提交
1930
| boolean | The value **true** indicates that the input character is a digit, and the value **false** indicates the opposite.|
S
shawn_he 已提交
1931 1932

**Example**
S
shawn_he 已提交
1933 1934
  ```ts
  let isdigit: boolean = I18n.Unicode.isDigit("1");  // isdigit = true
S
shawn_he 已提交
1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955
  ```


### isSpaceChar<sup>9+</sup>

static isSpaceChar(char: string): boolean

Checks whether the input character is a space.

**System capability**: SystemCapability.Global.I18n

**Parameters**

| Name | Type    | Mandatory  | Description   |
| ---- | ------ | ---- | ----- |
| char | string | Yes   | Input character.|

**Return value**

| Type     | Description                                    |
| ------- | -------------------------------------- |
S
shawn_he 已提交
1956
| boolean | The value **true** indicates that the input character is a space, and the value **false** indicates the opposite.|
S
shawn_he 已提交
1957 1958

**Example**
S
shawn_he 已提交
1959 1960
  ```ts
  let isspacechar: boolean = I18n.Unicode.isSpaceChar("a");  // isspacechar = false
S
shawn_he 已提交
1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981
  ```


### isWhitespace<sup>9+</sup>

static isWhitespace(char: string): boolean

Checks whether the input character is a white space.

**System capability**: SystemCapability.Global.I18n

**Parameters**

| Name | Type    | Mandatory  | Description   |
| ---- | ------ | ---- | ----- |
| char | string | Yes   | Input character.|

**Return value**

| Type     | Description                                    |
| ------- | -------------------------------------- |
S
shawn_he 已提交
1982
| boolean | The value **true** indicates that the input character is a white space, and the value **false** indicates the opposite.|
S
shawn_he 已提交
1983 1984

**Example**
S
shawn_he 已提交
1985 1986
  ```ts
  let iswhitespace: boolean = I18n.Unicode.isWhitespace("a");  // iswhitespace = false
S
shawn_he 已提交
1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007
  ```


### isRTL<sup>9+</sup>

static isRTL(char: string): boolean

Checks whether the input character is of the right to left (RTL) language.

**System capability**: SystemCapability.Global.I18n

**Parameters**

| Name | Type    | Mandatory  | Description   |
| ---- | ------ | ---- | ----- |
| char | string | Yes   | Input character.|

**Return value**

| Type     | Description                                      |
| ------- | ---------------------------------------- |
S
shawn_he 已提交
2008
| boolean | The value **true** indicates that the input character is of the RTL language, and the value **false** indicates the opposite.|
S
shawn_he 已提交
2009 2010

**Example**
S
shawn_he 已提交
2011 2012
  ```ts
  let isrtl: boolean = I18n.Unicode.isRTL("a");  // isrtl = false
S
shawn_he 已提交
2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033
  ```


### isIdeograph<sup>9+</sup>

static isIdeograph(char: string): boolean

Checks whether the input character is an ideographic character.

**System capability**: SystemCapability.Global.I18n

**Parameters**

| Name | Type    | Mandatory  | Description   |
| ---- | ------ | ---- | ----- |
| char | string | Yes   | Input character.|

**Return value**

| Type     | Description                                      |
| ------- | ---------------------------------------- |
S
shawn_he 已提交
2034
| boolean | The value **true** indicates that the input character is an ideographic character, and the value **false** indicates the opposite.|
S
shawn_he 已提交
2035 2036

**Example**
S
shawn_he 已提交
2037 2038
  ```ts
  let isideograph: boolean = I18n.Unicode.isIdeograph("a");  // isideograph = false
S
shawn_he 已提交
2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059
  ```


### isLetter<sup>9+</sup>

static isLetter(char: string): boolean

Checks whether the input character is a letter.

**System capability**: SystemCapability.Global.I18n

**Parameters**

| Name | Type    | Mandatory  | Description   |
| ---- | ------ | ---- | ----- |
| char | string | Yes   | Input character.|

**Return value**

| Type     | Description                                  |
| ------- | ------------------------------------ |
S
shawn_he 已提交
2060
| boolean | The value **true** indicates that the input character is a letter, and the value **false** indicates the opposite.|
S
shawn_he 已提交
2061 2062

**Example**
S
shawn_he 已提交
2063 2064
  ```ts
  let isletter: boolean = I18n.Unicode.isLetter("a");  // isletter = true
S
shawn_he 已提交
2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085
  ```


### isLowerCase<sup>9+</sup>

static isLowerCase(char: string): boolean

Checks whether the input character is a lowercase letter.

**System capability**: SystemCapability.Global.I18n

**Parameters**

| Name | Type    | Mandatory  | Description   |
| ---- | ------ | ---- | ----- |
| char | string | Yes   | Input character.|

**Return value**

| Type     | Description                                      |
| ------- | ---------------------------------------- |
S
shawn_he 已提交
2086
| boolean | The value **true** indicates that the input character is a lowercase letter, and the value **false** indicates the opposite.|
S
shawn_he 已提交
2087 2088

**Example**
S
shawn_he 已提交
2089 2090
  ```ts
  let islowercase: boolean = I18n.Unicode.isLowerCase("a");  // islowercase = true
S
shawn_he 已提交
2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111
  ```


### isUpperCase<sup>9+</sup>

static isUpperCase(char: string): boolean

Checks whether the input character is an uppercase letter.

**System capability**: SystemCapability.Global.I18n

**Parameters**

| Name | Type    | Mandatory  | Description   |
| ---- | ------ | ---- | ----- |
| char | string | Yes   | Input character.|

**Return value**

| Type     | Description                                      |
| ------- | ---------------------------------------- |
S
shawn_he 已提交
2112
| boolean | The value **true** indicates that the input character is an uppercase letter, and the value **false** indicates the opposite.|
S
shawn_he 已提交
2113 2114

**Example**
S
shawn_he 已提交
2115 2116
  ```ts
  let isuppercase: boolean = I18n.Unicode.isUpperCase("a");  // isuppercase = false
S
shawn_he 已提交
2117 2118 2119 2120 2121 2122 2123
  ```


### getType<sup>9+</sup>

static getType(char: string): string

S
shawn_he 已提交
2124
Obtains the category value of the input string.
S
shawn_he 已提交
2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137

**System capability**: SystemCapability.Global.I18n

**Parameters**

| Name | Type    | Mandatory  | Description   |
| ---- | ------ | ---- | ----- |
| char | string | Yes   | Input character.|

**Return value**

| Type    | Description         |
| ------ | ----------- |
S
shawn_he 已提交
2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174
| string | Category value of the input character.|

The following table lists only the general category values. For more details, see the Unicode Standard.

| Name| Value| Description|
| ---- | -------- | ---------- |
| U_UNASSIGNED | U_UNASSIGNED | Non-category for unassigned and non-character code points.|
| U_GENERAL_OTHER_TYPES | U_GENERAL_OTHER_TYPES | Same as **U_UNASSIGNED**.|
| U_UPPERCASE_LETTER | U_UPPERCASE_LETTER | Uppercase letter.|
| U_LOWERCASE_LETTER | U_LOWERCASE_LETTER | Lowercase letter. |
| U_TITLECASE_LETTER | U_TITLECASE_LETTER | Title case letter.|
| U_MODIFIER_LETTER | U_MODIFIER_LETTER | Modifier letter.|
| U_OTHER_LETTER | U_OTHER_LETTER | Letters other than the uppercase letter, lowercase letter, title case letter, and modifier letter.|
| U_NON_SPACING_MARK | U_NON_SPACING_MARK | Non-spacing mark, such as the accent symbol **'** and the variable symbol **#**.|
| U_ENCLOSING_MARK | U_ENCLOSING_MARK | Enclosing mark, for example, a circle or a box.|
| U_COMBINING_SPACING_MARK | U_COMBINING_SPACING_MARK | Spacing mark, for example, the vowel symbol **[]**.|
| U_DECIMAL_DIGIT_NUMBER | U_DECIMAL_DIGIT_NUMBER | Decimal number.|
| U_LETTER_NUMBER | U_LETTER_NUMBER | Letter and number (including Roman numeral).|
| U_OTHER_NUMBER | U_OTHER_NUMBER | Other numbers, which are used as encryption symbols, marker symbols, or non-Arabic numerals, such as **@**, **#**, **(1)**, and **①**.|
| U_SPACE_SEPARATOR | U_SPACE_SEPARATOR | Space separator, for example, a space character, uninterrupted space character, or space character with a fixed width.|
| U_LINE_SEPARATOR | U_LINE_SEPARATOR | Line separator.|
| U_PARAGRAPH_SEPARATOR | U_PARAGRAPH_SEPARATOR | Paragraph separator.|
| U_CONTROL_CHAR | U_CONTROL_CHAR | Control character.|
| U_FORMAT_CHAR | U_FORMAT_CHAR | Format character.|
| U_PRIVATE_USE_CHAR | U_PRIVATE_USE_CHAR | Privately used character, for example, a company logo.|
| U_SURROGATE | U_SURROGATE | Surrogate, which is used to represent supplementary characters in UTF-16.|
| U_DASH_PUNCTUATION | U_DASH_PUNCTUATION | Dash punctuation.|
| U_START_PUNCTUATION | U_START_PUNCTUATION | Start punctuation, for example, the left parenthesis.|
| U_END_PUNCTUATION | U_END_PUNCTUATION | End punctuation, for example, the right parenthesis.|
| U_INITIAL_PUNCTUATION | U_INITIAL_PUNCTUATION | Initial punctuation, for example, the left double quotation mark or left single quotation mark.|
| U_FINAL_PUNCTUATION | U_FINAL_PUNCTUATION | Final punctuation, for example, the right double quotation mark or right single quotation mark.|
| U_CONNECTOR_PUNCTUATION | U_CONNECTOR_PUNCTUATION | Connector punctuation.|
| U_OTHER_PUNCTUATION | U_OTHER_PUNCTUATION | Other punctuations.|
| U_MATH_SYMBOL | U_MATH_SYMBOL | Mathematical symbol.|
| U_CURRENCY_SYMBOL | U_CURRENCY_SYMBOL | Currency symbol.|
| U_MODIFIER_SYMBOL | U_MODIFIER_SYMBOL | Modifier symbol.|
| U_OTHER_SYMBOL | U_OTHER_SYMBOL | Other symbols.|
S
shawn_he 已提交
2175 2176

**Example**
S
shawn_he 已提交
2177 2178
  ```ts
  let type: string = I18n.Unicode.getType("a"); // type = "U_LOWERCASE_LETTER"
S
shawn_he 已提交
2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199
  ```

## I18NUtil<sup>9+</sup>


### unitConvert<sup>9+</sup>

static unitConvert(fromUnit: UnitInfo, toUnit: UnitInfo, value: number, locale: string, style?: string): string

Converts one measurement unit into another and formats the unit based on the specified locale and style.

**System capability**: SystemCapability.Global.I18n

**Parameters**

| Name     | Type                    | Mandatory  | Description                                      |
| -------- | ---------------------- | ---- | ---------------------------------------- |
| fromUnit | [UnitInfo](#unitinfo8) | Yes   | Measurement unit to be converted.                                |
| toUnit   | [UnitInfo](#unitinfo8) | Yes   | Measurement unit to be converted to.                                |
| value    | number                 | Yes   | Value of the measurement unit to be converted.                            |
| locale   | string                 | Yes   | Locale used for formatting, for example, **zh-Hans-CN**.               |
S
shawn_he 已提交
2200
| style    | string                 | No   | Style used for formatting. The value can be **long**, **short**, or **narrow**. The default value is **short**.|
S
shawn_he 已提交
2201 2202 2203 2204 2205

**Return value**

| Type    | Description                     |
| ------ | ----------------------- |
S
shawn_he 已提交
2206
| string | string obtained after formatting based on the measurement unit specified by **toUnit**.|
S
shawn_he 已提交
2207 2208

**Example**
S
shawn_he 已提交
2209 2210 2211 2212
  ```ts
  let fromUnit: I18n.UnitInfo = {unit: "cup", measureSystem: "US"};
  let toUnit: I18n.UnitInfo = {unit: "liter", measureSystem: "SI"};
  let res: string = I18n.I18NUtil.unitConvert(fromUnit, toUnit, 1000, "en-US", "long"); // res = 236.588 liters
S
shawn_he 已提交
2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233
  ```


### getDateOrder<sup>9+</sup>

static getDateOrder(locale: string): string

Obtains the sequence of the year, month, and day in the specified locale.

**System capability**: SystemCapability.Global.I18n

**Parameters**

| Name   | Type    | Mandatory  | Description                       |
| ------ | ------ | ---- | ------------------------- |
| locale | string | Yes   | Locale used for formatting, for example, **zh-Hans-CN**.|

**Return value**

| Type    | Description                 |
| ------ | ------------------- |
S
shawn_he 已提交
2234
| string | Sequence of the year, month, and day in the locale.|
S
shawn_he 已提交
2235 2236

**Example**
S
shawn_he 已提交
2237 2238
  ```ts
  let order: string = I18n.I18NUtil.getDateOrder("zh-CN");  // order = "y-L-d"
S
shawn_he 已提交
2239
  ```
S
shawn_he 已提交
2240 2241


S
shawn_he 已提交
2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264
## Normalizer<sup>10+</sup>

### getInstance<sup>10+</sup>

static getInstance(mode: NormalizerMode): Normalizer

Obtains a **Normalizer** object for text normalization.

**System capability**: SystemCapability.Global.I18n

**Parameters**

| Name   | Type    | Mandatory  | Description                       |
| ------ | ------ | ---- | ------------------------- |
| mode | [NormalizerMode](#normalizermode10) | Yes   | Text normalization mode.|

**Return value**

| Type    | Description                 |
| ------ | ------------------- |
| [Normalizer](#normalizer10) | **Normalizer** object for text normalization.|

**Example**
S
shawn_he 已提交
2265 2266
  ```ts
  let normalizer: I18n.Normalizer = I18n.Normalizer.getInstance(I18n.NormalizerMode.NFC);
S
shawn_he 已提交
2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290
  ```


### normalize<sup>10+</sup>

normalize(text: string): string

Normalizes text strings.

**System capability**: SystemCapability.Global.I18n

**Parameters**

| Name   | Type    | Mandatory  | Description                       |
| ------ | ------ | ---- | ------------------------- |
| text | string | Yes   | Text strings to be normalized.|

**Return value**

| Type    | Description                 |
| ------ | ------------------- |
| string | Normalized text strings.|

**Example**
S
shawn_he 已提交
2291 2292 2293
  ```ts
  let normalizer: I18n.Normalizer = I18n.Normalizer.getInstance(I18n.NormalizerMode.NFC);
  let normalizedText: string = normalizer.normalize('\u1E9B\u0323'); // normalizedText = \u1E9B\u0323
S
shawn_he 已提交
2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310
  ```


## NormalizerMode<sup>10+</sup>

Enumerates text normalization modes.

**System capability**: SystemCapability.Global.I18n

| Name| Value| Description|
| -------- | -------- | -------- |
| NFC | 1 | NFC.|
| NFD | 2 | NFD.|
| NFKC | 3 | NFKC.|
| NFKD | 4 | NFKD.|


S
shawn_he 已提交
2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324
## SystemLocaleManager<sup>10+</sup>


### constructor<sup>10+</sup>

constructor()

Creates a **SystemLocaleManager** object.

**System API**: This is a system API.

**System capability**: SystemCapability.Global.I18n

**Example**
S
shawn_he 已提交
2325 2326
  ```ts
  let systemLocaleManager: I18n.SystemLocaleManager = new I18n.SystemLocaleManager();
S
shawn_he 已提交
2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361
  ```


### getLanguageInfoArray<sup>10+</sup>

getLanguageInfoArray(languages: Array&lt;string&gt;, options?: SortOptions): Array&lt;LocaleItem&gt;

Obtains the language sorting array.

**System API**: This is a system API.

**System capability**: SystemCapability.Global.I18n

**Parameters**

|   Name |      Type     | Mandatory|     Description     |
| --------- | ------------- | ---- | ------------- |
| languages | Array&lt;string&gt; | Yes  | List of languages to be sorted.|
| options   | [SortOptions](#sortoptions10)   | No  | Language sorting option.|

**Return value**

|       Type       |         Description         |
| ----------------- | -------------------- |
| Array&lt;[LocaleItem](#localeitem10)&gt; | Language list after sorting.|

**Error codes**

For details about the error codes, see [I18N Error Codes](../errorcodes/errorcode-i18n.md).

| ID | Error Message                  |
| ------ | ---------------------- |
| 890001 | param value not valid  |

**Example**
S
shawn_he 已提交
2362 2363 2364
  ```ts
  import { BusinessError } from '@ohos.base';
  
S
shawn_he 已提交
2365
  // Assume that the system language is zh-Hans, the system region is CN, and the system locale is zh-Hans-CN.
S
shawn_he 已提交
2366 2367 2368
  let systemLocaleManager: I18n.SystemLocaleManager = new I18n.SystemLocaleManager();
  let languages: string[] = ["zh-Hans", "en-US", "pt", "ar"];
  let sortOptions: I18n.SortOptions = {locale: "zh-Hans-CN", isUseLocalName: true, isSuggestedFirst: true};
S
shawn_he 已提交
2369
  try {
S
shawn_he 已提交
2370 2371
      // The language list after sorting is [zh-Hans, en-US, pt, ar].
      let sortedLanguages: Array<I18n.LocaleItem> = systemLocaleManager.getLanguageInfoArray(languages, sortOptions);
S
shawn_he 已提交
2372
  } catch(error) {
S
shawn_he 已提交
2373
      let err: BusinessError = error as BusinessError;
S
shawn_he 已提交
2374
      console.error(`call systemLocaleManager.getLanguageInfoArray failed, error code: ${err.code}, message: ${err.message}.`);
S
shawn_he 已提交
2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393
  }
  ```


### getRegionInfoArray<sup>10+</sup>

getRegionInfoArray(regions: Array&lt;string&gt;, options?: SortOptions): Array&lt;LocaleItem&gt;

Obtains the country/region sorting array.

**System API**: This is a system API.

**System capability**: SystemCapability.Global.I18n

**Parameters**

|   Name |      Type     | Mandatory|     Description     |
| --------- | ------------- | ---- | ------------- |
| regions   | Array&lt;string&gt; | Yes  | List of countries/regions to be sorted.|
S
shawn_he 已提交
2394
| 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**.|
S
shawn_he 已提交
2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410

**Return value**

|       Type       |         Description         |
| ----------------- | -------------------- |
| Array&lt;[LocaleItem](#localeitem10)&gt; | Country/region list after sorting.|

**Error codes**

For details about the error codes, see [I18N Error Codes](../errorcodes/errorcode-i18n.md).

| ID | Error Message                  |
| ------ | ---------------------- |
| 890001 | param value not valid  |

**Example**
S
shawn_he 已提交
2411 2412 2413
  ```ts
  import { BusinessError } from '@ohos.base';
  
S
shawn_he 已提交
2414
  // Assume that the system language is zh-Hans, the system region is CN, and the system locale is zh-Hans-CN.
S
shawn_he 已提交
2415 2416 2417
  let systemLocaleManager: I18n.SystemLocaleManager = new I18n.SystemLocaleManager();
  let regions: string[] = ["CN", "US", "PT", "EG"];
  let sortOptions: I18n.SortOptions = {locale: "zh-Hans-CN", isUseLocalName: false, isSuggestedFirst: true};
S
shawn_he 已提交
2418
  try {
S
shawn_he 已提交
2419 2420
      // The country/region list after sorting is [CN, EG, US, PT].
      let sortedRegions: Array<I18n.LocaleItem> = systemLocaleManager.getRegionInfoArray(regions, sortOptions);
S
shawn_he 已提交
2421
  } catch(error) {
S
shawn_he 已提交
2422
      let err: BusinessError = error as BusinessError;
S
shawn_he 已提交
2423
      console.error(`call systemLocaleManager.getRegionInfoArray failed, error code: ${err.code}, message: ${err.message}.`);
S
shawn_he 已提交
2424 2425 2426
  }
  ```

S
shawn_he 已提交
2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443
### getTimeZoneCityItemArray<sup>10+</sup>

static getTimeZoneCityItemArray(): Array&lt;TimeZoneCityItem&gt;

Obtains the array of time zone city items after sorting.

**System API**: This is a system API.

**System capability**: SystemCapability.Global.I18n

**Return value**

|       Type       |         Description         |
| ----------------- | -------------------- |
| Array&lt;[TimeZoneCityItem](#timezonecityitem10)&gt; | Array of time zone city items.|

**Example**
S
shawn_he 已提交
2444 2445 2446
  ```ts
  import { BusinessError } from '@ohos.base';
  
S
shawn_he 已提交
2447
  try {
S
shawn_he 已提交
2448 2449 2450 2451
    let timeZoneCityItemArray: Array<I18n.TimeZoneCityItem> = I18n.SystemLocaleManager.getTimeZoneCityItemArray();
    for (let i = 0; i < timeZoneCityItemArray.length; i++) {
        console.log(timeZoneCityItemArray[i].zoneId + ", " + timeZoneCityItemArray[i].cityId + ", " + timeZoneCityItemArray[i].cityDisplayName +
            ", " + timeZoneCityItemArray[i].offset + "\r\n");
S
shawn_he 已提交
2452 2453
    }
  } catch(error) {
S
shawn_he 已提交
2454
    let err: BusinessError = error as BusinessError;
S
shawn_he 已提交
2455
    console.error(`call SystemLocaleManager.getTimeZoneCityItemArray failed, error code: ${err.code}, message: ${err.message}.`);
S
shawn_he 已提交
2456 2457
  }
  ```
S
shawn_he 已提交
2458 2459 2460 2461 2462

## LocaleItem<sup>10+</sup>

Represents the list of languages or countries/regions sorted by **SystemLocaleManager**.

S
shawn_he 已提交
2463 2464
**System API**: This is a system API.

S
shawn_he 已提交
2465 2466 2467 2468 2469 2470
**System capability**: SystemCapability.Global.I18n

| Name           | Type           |  Mandatory  |  Description                                  |
| --------------- | --------------- | ------ | --------------------------------------- |
| id              | string          |   Yes  | Language code or country/region code, for example, **zh** or **CN**.   |
| suggestionType  | [SuggestionType](#suggestiontype10)  |   Yes | Language or country/region suggestion type.                 |
S
shawn_he 已提交
2471
| displayName     | string          |  Yes  | Displayed name of ID in the locale of **SystemLocaleManager**.|
S
shawn_he 已提交
2472 2473
| localName       | string          |  No  | Local name of the ID.                          |

S
shawn_he 已提交
2474 2475 2476 2477
## TimeZoneCityItem<sup>10+</sup>

Represents the type of time zone city items.

S
shawn_he 已提交
2478 2479
**System API**: This is a system API.

S
shawn_he 已提交
2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490
**System capability**: SystemCapability.Global.I18n

| Name           | Type            |  Mandatory  |  Description                                  |
| --------------- | --------------- | ------  | --------------------------------------- |
| zoneId          | string          |   Yes   | Time zone ID, for example, **Asia/Shanghai**.             |
| cityId          | string          |   Yes   | City ID, for example, **Shanghai**.                  |
| cityDisplayName | string          |   Yes   | Displayed name of the city ID in the system locale.         |
| offset          | int             |   Yes   | Offset of the time zone ID.                        |
| zoneDisplayName | string          |   Yes   | Displayed name of the time zone ID in the system locale.         |
| rawOffset       | int             |   No   | Row offset of the time zone ID.                      |

S
shawn_he 已提交
2491 2492 2493 2494 2495

## SuggestionType<sup>10+</sup>

Represents the language or country/region suggestion type.

S
shawn_he 已提交
2496 2497
**System API**: This is a system API.

S
shawn_he 已提交
2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510
**System capability**: SystemCapability.Global.I18n

| Name                  | Value | Description  |
| ---------------------- | ---- | ---- |
| SUGGESTION_TYPE_NONE   | 0x00 | Not a recommended language or country/region.|
| SUGGESTION_TYPE_RELATED| 0x01 | Country/region recommended by the system language or language recommended by the system country/region.|
| SUGGESTION_TYPE_SIM    | 0x02 | Language recommended by the country/region of the SIM card.|


## SortOptions<sup>10+<sup>

Represents the language or country/region sorting option.

S
shawn_he 已提交
2511 2512
**System API**: This is a system API.

S
shawn_he 已提交
2513 2514 2515 2516
**System capability**: SystemCapability.Global.I18n

| Name           | Type           |  Mandatory|   Description                                |
| --------------- | --------------- | ---- | --------------------------------------- |
S
shawn_he 已提交
2517 2518 2519
| locale          | string          |  No | System locale, for example, **zh-Hans-CN**. The default value of **locale** is the system locale.   |
| 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**.               |
| 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**. |
S
shawn_he 已提交
2520 2521


S
shawn_he 已提交
2522
## I18n.getDisplayCountry<sup>(deprecated)</sup>
S
shawn_he 已提交
2523 2524 2525 2526 2527

getDisplayCountry(country: string, locale: string, sentenceCase?: boolean): string

Obtains the localized script for the specified country.

S
shawn_he 已提交
2528
This API is deprecated since API version 9. You are advised to use [System.getDisplayCountry](#getdisplaycountry9).
S
shawn_he 已提交
2529 2530 2531 2532 2533 2534 2535 2536 2537

**System capability**: SystemCapability.Global.I18n

**Parameters**

| Name         | Type     | Mandatory  | Description              |
| ------------ | ------- | ---- | ---------------- |
| country      | string  | Yes   | Specified country.           |
| locale       | string  | Yes   | Locale ID.    |
S
shawn_he 已提交
2538
| sentenceCase | boolean | No   | Whether to use sentence case for the localized script. The default value is **true**.|
S
shawn_he 已提交
2539 2540 2541 2542 2543 2544 2545 2546

**Return value**

| Type    | Description           |
| ------ | ------------- |
| string | Localized script for the specified country.|

**Example**
S
shawn_he 已提交
2547 2548
  ```ts
  let countryName: string = I18n.getDisplayCountry("zh-CN", "en-GB", true); // countryName = true
S
shawn_he 已提交
2549
  countryName = I18n.getDisplayCountry("zh-CN", "en-GB"); // countryName = true
S
shawn_he 已提交
2550 2551 2552
  ```


S
shawn_he 已提交
2553
## I18n.getDisplayLanguage<sup>(deprecated)</sup>
S
shawn_he 已提交
2554 2555 2556 2557 2558

getDisplayLanguage(language: string, locale: string, sentenceCase?: boolean): string

Obtains the localized script for the specified language.

S
shawn_he 已提交
2559
This API is deprecated since API version 9. You are advised to use [System.getDisplayLanguage](#getdisplaylanguage9).
S
shawn_he 已提交
2560 2561 2562 2563 2564 2565 2566 2567 2568

**System capability**: SystemCapability.Global.I18n

**Parameters**

| Name         | Type     | Mandatory  | Description              |
| ------------ | ------- | ---- | ---------------- |
| language     | string  | Yes   | Specified language.           |
| locale       | string  | Yes   | Locale ID.    |
S
shawn_he 已提交
2569
| sentenceCase | boolean | No   | Whether to use sentence case for the localized script. The default value is **true**.|
S
shawn_he 已提交
2570 2571 2572 2573 2574 2575 2576 2577

**Return value**

| Type    | Description           |
| ------ | ------------- |
| string | Localized script for the specified language.|

**Example**
S
shawn_he 已提交
2578 2579
  ```ts
  let languageName: string = I18n.getDisplayLanguage("zh", "en-GB", true); // languageName = "Chinese"
S
shawn_he 已提交
2580
  languageName = I18n.getDisplayLanguage("zh", "en-GB"); // languageName = "Chinese"
S
shawn_he 已提交
2581 2582 2583
  ```


S
shawn_he 已提交
2584
## I18n.getSystemLanguage<sup>(deprecated)</sup>
S
shawn_he 已提交
2585 2586 2587 2588 2589

getSystemLanguage(): string

Obtains the system language.

S
shawn_he 已提交
2590
This API is deprecated since API version 9. You are advised to use [System.getSystemLanguage](#getsystemlanguage9).
S
shawn_he 已提交
2591 2592 2593 2594 2595 2596 2597 2598 2599 2600

**System capability**: SystemCapability.Global.I18n

**Return value**

| Type    | Description     |
| ------ | ------- |
| string | System language ID.|

**Example**
S
shawn_he 已提交
2601 2602
  ```ts
  let systemLanguage: string = I18n.getSystemLanguage(); // Obtain the current system language.
S
shawn_he 已提交
2603 2604 2605
  ```


S
shawn_he 已提交
2606
## I18n.getSystemRegion<sup>(deprecated)</sup>
S
shawn_he 已提交
2607 2608 2609 2610 2611

getSystemRegion(): string

Obtains the system region.

S
shawn_he 已提交
2612
This API is deprecated since API version 9. You are advised to use [System.getSystemRegion](#getsystemregion9).
S
shawn_he 已提交
2613 2614 2615 2616 2617 2618 2619 2620 2621 2622

**System capability**: SystemCapability.Global.I18n

**Return value**

| Type    | Description     |
| ------ | ------- |
| string | System region ID.|

**Example**
S
shawn_he 已提交
2623 2624
  ```ts
  let region: string = I18n.getSystemRegion(); // Obtain the current system region.
S
shawn_he 已提交
2625 2626 2627
  ```


S
shawn_he 已提交
2628
## I18n.getSystemLocale<sup>(deprecated)</sup>
S
shawn_he 已提交
2629 2630 2631 2632 2633

getSystemLocale(): string

Obtains the system locale.

S
shawn_he 已提交
2634
This API is deprecated since API version 9. You are advised to use [System.getSystemLocale](#getsystemlocale9).
S
shawn_he 已提交
2635 2636 2637 2638 2639 2640 2641 2642 2643 2644

**System capability**: SystemCapability.Global.I18n

**Return value**

| Type    | Description     |
| ------ | ------- |
| string | System locale ID.|

**Example**
S
shawn_he 已提交
2645 2646
  ```ts
  let locale: string = I18n.getSystemLocale (); // Obtain the system locale.
S
shawn_he 已提交
2647 2648 2649
  ```


S
shawn_he 已提交
2650
## I18n.is24HourClock<sup>(deprecated)</sup>
S
shawn_he 已提交
2651 2652 2653 2654 2655

is24HourClock(): boolean

Checks whether the 24-hour clock is used.

S
shawn_he 已提交
2656
This API is deprecated since API version 9. You are advised to use [System.is24HourClock](#is24hourclock9).
S
shawn_he 已提交
2657 2658 2659 2660 2661 2662 2663

**System capability**: SystemCapability.Global.I18n

**Return value**

| Type     | Description                                      |
| ------- | ---------------------------------------- |
S
shawn_he 已提交
2664
| boolean | The value **true** indicates that the 24-hour clock is used, and the value **false** indicates the opposite.|
S
shawn_he 已提交
2665 2666

**Example**
S
shawn_he 已提交
2667 2668
  ```ts
  let is24HourClock: boolean = I18n.is24HourClock();
S
shawn_he 已提交
2669 2670 2671
  ```


S
shawn_he 已提交
2672
## I18n.set24HourClock<sup>(deprecated)</sup>
S
shawn_he 已提交
2673 2674 2675 2676 2677

set24HourClock(option: boolean): boolean

Sets the 24-hour clock.

S
shawn_he 已提交
2678
This API is deprecated since API version 9. You are advised to use [System.set24HourClock](#set24hourclock9).
S
shawn_he 已提交
2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693

**Permission required**: ohos.permission.UPDATE_CONFIGURATION

**System capability**: SystemCapability.Global.I18n

**Parameters**

| Name   | Type     | Mandatory  | Description                                      |
| ------ | ------- | ---- | ---------------------------------------- |
| 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.|

**Return value**

| Type     | Description                           |
| ------- | ----------------------------- |
S
shawn_he 已提交
2694
| boolean | The value **true** indicates that the 24-hour clock is enabled, and the value **false** indicates the opposite.|
S
shawn_he 已提交
2695 2696

**Example**
S
shawn_he 已提交
2697
  ```ts
S
shawn_he 已提交
2698
  // Set the system time to the 24-hour clock.
S
shawn_he 已提交
2699
  let success: boolean = I18n.set24HourClock(true);
S
shawn_he 已提交
2700 2701 2702
  ```


S
shawn_he 已提交
2703
## I18n.addPreferredLanguage<sup>(deprecated)</sup>
S
shawn_he 已提交
2704 2705 2706 2707 2708

addPreferredLanguage(language: string, index?: number): boolean

Adds a preferred language to the specified position on the preferred language list.

S
shawn_he 已提交
2709
This API is supported since API version 8 and is deprecated since API version 9. You are advised to use [System.addPreferredLanguage](#addpreferredlanguage9).
S
shawn_he 已提交
2710 2711 2712 2713 2714 2715 2716 2717 2718 2719

**Permission required**: ohos.permission.UPDATE_CONFIGURATION

**System capability**: SystemCapability.Global.I18n

**Parameters**

| Name     | Type    | Mandatory  | Description        |
| -------- | ------ | ---- | ---------- |
| language | string | Yes   | Preferred language to add. |
S
shawn_he 已提交
2720
| index    | number | No   | Position to which the preferred language is added. The default value is the length of the preferred language list.|
S
shawn_he 已提交
2721 2722 2723 2724 2725

**Return value**

| Type     | Description                           |
| ------- | ----------------------------- |
S
shawn_he 已提交
2726
| boolean | The value **true** indicates that the preferred language is successfully added, and the value **false** indicates the opposite.|
S
shawn_he 已提交
2727 2728

**Example**
S
shawn_he 已提交
2729
  ```ts
S
shawn_he 已提交
2730
  // Add zh-CN to the preferred language list.
S
shawn_he 已提交
2731 2732 2733
  let language: string = 'zh-CN';
  let index: number = 0;
  let success: boolean = I18n.addPreferredLanguage(language, index);
S
shawn_he 已提交
2734 2735 2736
  ```


S
shawn_he 已提交
2737
## I18n.removePreferredLanguage<sup>(deprecated)</sup>
S
shawn_he 已提交
2738 2739 2740 2741 2742

removePreferredLanguage(index: number): boolean

Deletes a preferred language from the specified position on the preferred language list.

S
shawn_he 已提交
2743
This API is supported since API version 8 and is deprecated since API version 9. You are advised to use [System.removePreferredLanguage](#removepreferredlanguage9).
S
shawn_he 已提交
2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758

**Permission required**: ohos.permission.UPDATE_CONFIGURATION

**System capability**: SystemCapability.Global.I18n

**Parameters**

| Name  | Type    | Mandatory  | Description                   |
| ----- | ------ | ---- | --------------------- |
| index | number | Yes   | Position of the preferred language to delete.|

**Return value**

| Type     | Description                           |
| ------- | ----------------------------- |
S
shawn_he 已提交
2759
| boolean | The value **true** indicates that the preferred language is deleted, and the value **false** indicates the opposite.|
S
shawn_he 已提交
2760 2761

**Example**
S
shawn_he 已提交
2762
  ```ts
S
shawn_he 已提交
2763
  // Delete the first preferred language from the preferred language list.
S
shawn_he 已提交
2764 2765
  let index: number = 0;
  let success: boolean = I18n.removePreferredLanguage(index);
S
shawn_he 已提交
2766 2767 2768
  ```


S
shawn_he 已提交
2769
## I18n.getPreferredLanguageList<sup>(deprecated)</sup>
S
shawn_he 已提交
2770 2771 2772

getPreferredLanguageList(): Array&lt;string&gt;

S
shawn_he 已提交
2773
Obtains the list of preferred languages.
S
shawn_he 已提交
2774

S
shawn_he 已提交
2775
This API is supported since API version 8 and is deprecated since API version 9. You are advised to use [System.getPreferredLanguageList](#getpreferredlanguagelist9).
S
shawn_he 已提交
2776 2777 2778 2779 2780 2781 2782

**System capability**: SystemCapability.Global.I18n

**Return value**

| Type                 | Description       |
| ------------------- | --------- |
S
shawn_he 已提交
2783
| Array&lt;string&gt; | List of preferred languages.|
S
shawn_he 已提交
2784 2785

**Example**
S
shawn_he 已提交
2786 2787
  ```ts
  let preferredLanguageList: Array<string> = I18n.getPreferredLanguageList(); // Obtain the preferred language list.
S
shawn_he 已提交
2788 2789 2790
  ```


S
shawn_he 已提交
2791
## I18n.getFirstPreferredLanguage<sup>(deprecated)</sup>
S
shawn_he 已提交
2792 2793 2794 2795 2796

getFirstPreferredLanguage(): string

Obtains the first language in the preferred language list.

S
shawn_he 已提交
2797
This API is supported since API version 8 and is deprecated since API version 9. You are advised to use [System.getFirstPreferredLanguage](#getfirstpreferredlanguage9).
S
shawn_he 已提交
2798 2799 2800 2801 2802 2803 2804 2805 2806 2807

**System capability**: SystemCapability.Global.I18n

**Return value**

| Type    | Description            |
| ------ | -------------- |
| string | First language in the preferred language list.|

**Example**
S
shawn_he 已提交
2808 2809
  ```ts
  let firstPreferredLanguage: string = I18n.getFirstPreferredLanguage();
S
shawn_he 已提交
2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821
  ```


## Util<sup>(deprecated)</sup>


### unitConvert<sup>(deprecated)</sup>

static unitConvert(fromUnit: UnitInfo, toUnit: UnitInfo, value: number, locale: string, style?: string): string

Converts one measurement unit into another and formats the unit based on the specified locale and style.

S
shawn_he 已提交
2822
This API is supported since API version 8 and is deprecated since API version 9. You are advised to use [unitConvert](#unitconvert9).
S
shawn_he 已提交
2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833

**System capability**: SystemCapability.Global.I18n

**Parameters**

| Name     | Type                    | Mandatory  | Description                                      |
| -------- | ---------------------- | ---- | ---------------------------------------- |
| fromUnit | [UnitInfo](#unitinfo8) | Yes   | Measurement unit to be converted.                                |
| toUnit   | [UnitInfo](#unitinfo8) | Yes   | Measurement unit to be converted to.                                |
| value    | number                 | Yes   | Value of the measurement unit to be converted.                            |
| locale   | string                 | Yes   | Locale used for formatting, for example, **zh-Hans-CN**.               |
S
shawn_he 已提交
2834
| style    | string                 | No   | Style used for formatting. The value can be **long**, **short**, or **narrow**. The default value is **short**.|
S
shawn_he 已提交
2835 2836 2837 2838 2839

**Return value**

| Type    | Description                     |
| ------ | ----------------------- |
S
shawn_he 已提交
2840
| string | string obtained after formatting based on the measurement unit specified by **toUnit**.|
S
shawn_he 已提交
2841 2842 2843 2844 2845 2846 2847 2848 2849


## Character<sup>(deprecated)</sup>


### isDigit<sup>(deprecated)</sup>

static isDigit(char: string): boolean

S
shawn_he 已提交
2850
Checks whether the input string is composed of digits.
S
shawn_he 已提交
2851

S
shawn_he 已提交
2852
This API is supported since API version 8 and is deprecated since API version 9. You are advised to use [isDigit](#isdigit9).
S
shawn_he 已提交
2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865

**System capability**: SystemCapability.Global.I18n

**Parameters**

| Name | Type    | Mandatory  | Description   |
| ---- | ------ | ---- | ----- |
| char | string | Yes   | Input character.|

**Return value**

| Type     | Description                                  |
| ------- | ------------------------------------ |
S
shawn_he 已提交
2866
| boolean | The value **true** indicates that the input character is a digit, and the value **false** indicates the opposite.|
S
shawn_he 已提交
2867 2868 2869 2870 2871 2872 2873 2874


### isSpaceChar<sup>(deprecated)</sup>

static isSpaceChar(char: string): boolean

Checks whether the input character is a space.

S
shawn_he 已提交
2875
This API is supported since API version 8 and is deprecated since API version 9. You are advised to use [isSpaceChar](#isspacechar9).
S
shawn_he 已提交
2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888

**System capability**: SystemCapability.Global.I18n

**Parameters**

| Name | Type    | Mandatory  | Description   |
| ---- | ------ | ---- | ----- |
| char | string | Yes   | Input character.|

**Return value**

| Type     | Description                                    |
| ------- | -------------------------------------- |
S
shawn_he 已提交
2889
| boolean | The value **true** indicates that the input character is a space, and the value **false** indicates the opposite.|
S
shawn_he 已提交
2890 2891 2892 2893 2894 2895 2896 2897


### isWhitespace<sup>(deprecated)</sup>

static isWhitespace(char: string): boolean

Checks whether the input character is a white space.

S
shawn_he 已提交
2898
This API is supported since API version 8 and is deprecated since API version 9. You are advised to use [isWhitespace](#iswhitespace9).
S
shawn_he 已提交
2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911

**System capability**: SystemCapability.Global.I18n

**Parameters**

| Name | Type    | Mandatory  | Description   |
| ---- | ------ | ---- | ----- |
| char | string | Yes   | Input character.|

**Return value**

| Type     | Description                                    |
| ------- | -------------------------------------- |
S
shawn_he 已提交
2912
| boolean | The value **true** indicates that the input character is a white space, and the value **false** indicates the opposite.|
S
shawn_he 已提交
2913 2914 2915 2916 2917 2918 2919 2920


### isRTL<sup>(deprecated)</sup>

static isRTL(char: string): boolean

Checks whether the input character is of the right to left (RTL) language.

S
shawn_he 已提交
2921
This API is supported since API version 8 and is deprecated since API version 9. You are advised to use [isRTL](#isrtl9).
S
shawn_he 已提交
2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934

**System capability**: SystemCapability.Global.I18n

**Parameters**

| Name | Type    | Mandatory  | Description   |
| ---- | ------ | ---- | ----- |
| char | string | Yes   | Input character.|

**Return value**

| Type     | Description                                      |
| ------- | ---------------------------------------- |
S
shawn_he 已提交
2935
| boolean | The value **true** indicates that the input character is of the RTL language, and the value **false** indicates the opposite.|
S
shawn_he 已提交
2936 2937 2938 2939 2940 2941 2942 2943


### isIdeograph<sup>(deprecated)</sup>

static isIdeograph(char: string): boolean

Checks whether the input character is an ideographic character.

S
shawn_he 已提交
2944
This API is supported since API version 8 and is deprecated since API version 9. You are advised to use [isIdeograph](#isideograph9).
S
shawn_he 已提交
2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957

**System capability**: SystemCapability.Global.I18n

**Parameters**

| Name | Type    | Mandatory  | Description   |
| ---- | ------ | ---- | ----- |
| char | string | Yes   | Input character.|

**Return value**

| Type     | Description                                      |
| ------- | ---------------------------------------- |
S
shawn_he 已提交
2958
| boolean | The value **true** indicates that the input character is an ideographic character, and the value **false** indicates the opposite.|
S
shawn_he 已提交
2959 2960 2961 2962 2963 2964 2965 2966


### isLetter<sup>(deprecated)</sup>

static isLetter(char: string): boolean

Checks whether the input character is a letter.

S
shawn_he 已提交
2967
This API is supported since API version 8 and is deprecated since API version 9. You are advised to use [isLetter](#isletter9).
S
shawn_he 已提交
2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980

**System capability**: SystemCapability.Global.I18n

**Parameters**

| Name | Type    | Mandatory  | Description   |
| ---- | ------ | ---- | ----- |
| char | string | Yes   | Input character.|

**Return value**

| Type     | Description                                  |
| ------- | ------------------------------------ |
S
shawn_he 已提交
2981
| boolean | The value **true** indicates that the input character is a letter, and the value **false** indicates the opposite.|
S
shawn_he 已提交
2982 2983 2984 2985 2986 2987 2988 2989


### isLowerCase<sup>(deprecated)</sup>

static isLowerCase(char: string): boolean

Checks whether the input character is a lowercase letter.

S
shawn_he 已提交
2990
This API is supported since API version 8 and is deprecated since API version 9. You are advised to use [isLowerCase](#islowercase9).
S
shawn_he 已提交
2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003

**System capability**: SystemCapability.Global.I18n

**Parameters**

| Name | Type    | Mandatory  | Description   |
| ---- | ------ | ---- | ----- |
| char | string | Yes   | Input character.|

**Return value**

| Type     | Description                                      |
| ------- | ---------------------------------------- |
S
shawn_he 已提交
3004
| boolean | The value **true** indicates that the input character is a lowercase letter, and the value **false** indicates the opposite.|
S
shawn_he 已提交
3005 3006 3007 3008 3009 3010 3011 3012


### isUpperCase<sup>(deprecated)</sup>

static isUpperCase(char: string): boolean

Checks whether the input character is an uppercase letter.

S
shawn_he 已提交
3013
This API is supported since API version 8 and is deprecated since API version 9. You are advised to use [isUpperCase](#isuppercase9).
S
shawn_he 已提交
3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026

**System capability**: SystemCapability.Global.I18n

**Parameters**

| Name | Type    | Mandatory  | Description   |
| ---- | ------ | ---- | ----- |
| char | string | Yes   | Input character.|

**Return value**

| Type     | Description                                      |
| ------- | ---------------------------------------- |
S
shawn_he 已提交
3027
| boolean | The value **true** indicates that the input character is an uppercase letter, and the value **false** indicates the opposite.|
S
shawn_he 已提交
3028 3029 3030 3031 3032 3033


### getType<sup>(deprecated)</sup>

static getType(char: string): string

S
shawn_he 已提交
3034
Obtains the type of the input string.
S
shawn_he 已提交
3035

S
shawn_he 已提交
3036
This API is supported since API version 8 and is deprecated since API version 9. You are advised to use [getType](#gettype9).
S
shawn_he 已提交
3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049

**System capability**: SystemCapability.Global.I18n

**Parameters**

| Name | Type    | Mandatory  | Description   |
| ---- | ------ | ---- | ----- |
| char | string | Yes   | Input character.|

**Return value**

| Type    | Description         |
| ------ | ----------- |
S
shawn_he 已提交
3050
| string | Category value of the input character.|