>- 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.
>- This module contains enhanced i18n APIs, which are not defined in ECMA 402.
> - 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.
>
> - This module contains enhanced i18n APIs, which are not defined in ECMA 402.
## Modules to Import<a name="s56d19203690d4782bfc74069abb6bd71"></a>
<td class="cellrowborder" valign="top" width="66.06%" headers="mcps1.1.5.1.4 "><p id="p199051053209"><a name="p199051053209"></a><a name="p199051053209"></a>Whether to use sentence case for the localized script.</p>
<td class="cellrowborder" valign="top" width="66.06%" headers="mcps1.1.5.1.4 "><p id="p13665145612315"><a name="p13665145612315"></a><a name="p13665145612315"></a>Whether to use sentence case for the localized script.</p>
<td class="cellrowborder" valign="top" width="77.24%" headers="mcps1.1.3.1.2 "><p id="p1426512364278"><a name="p1426512364278"></a><a name="p1426512364278"></a>The value <strong id="b19401141034713"><a name="b19401141034713"></a><a name="b19401141034713"></a>true</strong> indicates that the localized script is displayed from right to left, and value <strong id="b1140191054710"><a name="b1140191054710"></a><a name="b1140191054710"></a>false</strong> indicates the opposite.</p>
</td>
</tr>
</tbody>
</table>
- Example
```
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.
<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.5.1.4 "><p id="p142092114452"><a name="p142092114452"></a><a name="p142092114452"></a>Date to be set for the <strong id="b1825112714818"><a name="b1825112714818"></a><a name="b1825112714818"></a>Calendar</strong> object.</p>
</td>
</tr>
</tbody>
</table>
- Example
```
var calendar = I18n.getCalendar("en-US", "gregory");
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\).
<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.5.1.4 "><p id="p9524104532320"><a name="p9524104532320"></a><a name="p9524104532320"></a>Number of milliseconds that have elapsed since the Unix epoch.</p>
</td>
</tr>
</tbody>
</table>
- Example
```
var calendar = I18n.getCalendar("en-US", "gregory");
<td class="cellrowborder" valign="top" width="77.24%" headers="mcps1.1.3.1.2 "><p id="p1235634134317"><a name="p1235634134317"></a><a name="p1235634134317"></a>Start day of a week. The value <strong id="b1142754320316"><a name="b1142754320316"></a><a name="b1142754320316"></a>1</strong> indicates Sunday, and value <strong id="b343334343113"><a name="b343334343113"></a><a name="b343334343113"></a>7</strong> indicates Saturday.</p>
<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.5.1.4 "><p id="p73431922121210"><a name="p73431922121210"></a><a name="p73431922121210"></a>Start day of a week. The value <strong id="b166613239283"><a name="b166613239283"></a><a name="b166613239283"></a>1</strong> indicates Sunday, and value <strong id="b10661923142819"><a name="b10661923142819"></a><a name="b10661923142819"></a>7</strong> indicates Saturday.</p>
Obtains the minimum number of days in the first week of a year.
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| locale | string | Yes| Valid locale value, for example, **zh-Hans-CN**.|
| 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. If this parameter is left unspecified, the default calendar type of the specified locale is used.|
| date | Date | Yes| Date to be set for the **Calendar** object.|
- Example
```
var calendar = I18n.getCalendar("en-US", "gregory");
var date = new Date(2021, 10, 7, 8, 0, 0, 0);
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).
<td class="cellrowborder" valign="top" width="77.24%" headers="mcps1.1.3.1.2 "><p id="p195721334308"><a name="p195721334308"></a><a name="p195721334308"></a>Minimum number of days in the first week of a year.</p>
</td>
</tr>
</tbody>
</table>
- Example
### getMinimalDaysInFirstWeek<sup>8+</sup>
```
var calendar = I18n.getCalendar("zh-Hans");
calendar.getMinimalDaysInFirstWeek();
```
getMinimalDaysInFirstWeek(): number
Obtains the minimum number of days in the first week of a year.
<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.5.1.4 "><p id="p756935102918"><a name="p756935102918"></a><a name="p756935102918"></a>Minimum number of days in the first week of a year.</p>
<td class="cellrowborder" valign="top" width="77.24%" headers="mcps1.1.3.1.2 "><p id="p197430101589"><a name="p197430101589"></a><a name="p197430101589"></a>Value of the specified field. For example, if the year in the internal date of this <strong id="b713617105454"><a name="b713617105454"></a><a name="b713617105454"></a>Calendar</strong> object is <strong id="b4545113104514"><a name="b4545113104514"></a><a name="b4545113104514"></a>1990</strong>, the <strong id="b1780019104518"><a name="b1780019104518"></a><a name="b1780019104518"></a>get("year")</strong> function will return <strong id="b857122216453"><a name="b857122216453"></a><a name="b857122216453"></a>1990</strong>.</p>
</td>
</tr>
</tbody>
</table>
- Example
```
var calendar = I18n.getCalendar("zh-Hans");
calendar.setTime(2021, 10, 1, 8, 0, 0); // set time to 2021.10.1 08:00:00
<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.5.1.4 "><p id="p1943754204711"><a name="p1943754204711"></a><a name="p1943754204711"></a>Locale for which the name of the <strong id="b153411615135514"><a name="b153411615135514"></a><a name="b153411615135514"></a>Calendar</strong> object is displayed. For example, if <strong id="b15956959165512"><a name="b15956959165512"></a><a name="b15956959165512"></a>locale</strong> is <strong id="b3135193195616"><a name="b3135193195616"></a><a name="b3135193195616"></a>en-US</strong>, the name of the Buddhist calendar will be <strong id="b1136103015554"><a name="b1136103015554"></a><a name="b1136103015554"></a>Buddhist Calendar</strong>.</p>
<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.5.1.4 "><p id="p759790184716"><a name="p759790184716"></a><a name="p759790184716"></a>Specified date in this <strong id="b12909151184614"><a name="b12909151184614"></a><a name="b12909151184614"></a>Calendar</strong> object. If this parameter is left unspecified, the system checks whether the current date in the <strong id="b5327113114916"><a name="b5327113114916"></a><a name="b5327113114916"></a>Calendar</strong> object is a weekend.</p>
<td class="cellrowborder" valign="top" width="77.24%" headers="mcps1.1.3.1.2 "><p id="p134689131085"><a name="p134689131085"></a><a name="p134689131085"></a>The value true indicates that the date is a weekend, and value <strong id="b1878515462424"><a name="b1878515462424"></a><a name="b1878515462424"></a>false</strong> indicates a weekday.</p>
</td>
</tr>
</tbody>
</table>
- Example
```
var calendar = I18n.getCalendar("zh-Hans");
calendar.setTime(2021, 11, 11, 8, 0, 0); // Set the time to 2021.11.11 08:00:00.
| 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.|
- Return value
| 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**.|
- Example
```
var calendar = i18n.getCalendar("zh-Hans");
calendar.setTime(2021, 10, 1, 8, 0, 0); // set time to 2021.10.1 08:00:00
calendar.get("hour_of_day"); // 8
```
### getDisplayName<sup>8+</sup>
getDisplayName(locale: string): string
Obtains the name of the **Calendar** object displayed for the specified locale.
| locale | string | Yes| Locale for which the name of the **Calendar** object is displayed. For example, if **locale** is **en-US**, the name of the Buddhist calendar will be **Buddhist Calendar**.|
- Return value
| Type| Description|
| -------- | -------- |
| string | Name of the **Calendar** object displayed for the specified locale.|
- Example
```
var calendar = i18n.getCalendar("en-US", "buddhist");
calendar.getDisplayName("zh"); // Obtain the name of the Buddhist calendar in zh.
```
### isWeekend<sup>8+</sup>
isWeekend(date?: Date): boolean
Checks whether the specified date in this **Calendar** object is a weekend.
| date | Date | No| Specified date in this **Calendar** object. If this parameter is left unspecified, the system checks whether the current date in the **Calendar** object is a weekend.|
- Return value
| Type| Description|
| -------- | -------- |
| boolean | The value **true** indicates that the date is a weekend, and value **false** indicates a weekday.|
- Example
```
var calendar = i18n.getCalendar("zh-Hans");
calendar.setTime(2021, 11, 11, 8, 0, 0); // set time to 2021.11.11 08:00:00
<tdclass="cellrowborder"valign="top"width="59.61742826780022%"headers="mcps1.1.5.1.4 "><pid="p0628344161114"><aname="p0628344161114"></a><aname="p0628344161114"></a>Country or region to which the phone number to be formatted belongs.</p>
<tdclass="cellrowborder"valign="top"width="59.61742826780022%"headers="mcps1.1.5.1.4 "><pid="p2629134411115"><aname="p2629134411115"></a><aname="p2629134411115"></a>Options of the <strongid="b133271441355"><aname="b133271441355"></a><aname="b133271441355"></a>PhoneNumberFormat</strong> object.</p>
</td>
</tr>
</tbody>
</table>
- Example
```
var phoneNumberFormat= new I18n.PhoneNumberFormat("CN", {"type": "E164"});
<td class="cellrowborder" valign="top" width="59.61742826780022%" headers="mcps1.1.5.1.4 "><p id="p1993323202316"><a name="p1993323202316"></a><a name="p1993323202316"></a>Phone number to be checked.</p>
<td class="cellrowborder" valign="top" width="79.95%" headers="mcps1.1.3.1.2 "><p id="p159346329238"><a name="p159346329238"></a><a name="p159346329238"></a>The value <strong id="b655418371355"><a name="b655418371355"></a><a name="b655418371355"></a>true</strong> indicates the phone number format is valid, and value <strong id="b551063319513"><a name="b551063319513"></a><a name="b551063319513"></a>false</strong> indicates the opposite.</p>
</td>
</tr>
</tbody>
</table>
- Example
```
var phonenumberfmt = new I18n.PhoneNumberFormat("CN");
<td class="cellrowborder" valign="top" width="59.61742826780022%" headers="mcps1.1.5.1.4 "><p id="p8420204113328"><a name="p8420204113328"></a><a name="p8420204113328"></a>Phone number to be formatted.</p>
<tdclass="cellrowborder"valign="top"width="52.449999999999996%"headers="mcps1.1.6.1.5 "><pid="p781453518814"><aname="p781453518814"></a><aname="p781453518814"></a>Format type of a phone number. The available options are as follows: <strongid="b2090653219128"><aname="b2090653219128"></a><aname="b2090653219128"></a>E164</strong>, <strongid="b8729133516126"><aname="b8729133516126"></a><aname="b8729133516126"></a>INTERNATIONAL</strong>, <strongid="b78591736171217"><aname="b78591736171217"></a><aname="b78591736171217"></a>NATIONAL</strong>, and <strongid="b427354020121"><aname="b427354020121"></a><aname="b427354020121"></a>RFC3966</strong>.</p>
| type | string | Yes| Yes| Format type of a phone number. The value can be **E164**, **INTERNATIONAL**, **NATIONAL**, or **RFC3966**.<br>**System capability**: SystemCapability.Global.I18n|
<tdclass="cellrowborder"valign="top"width="52.449999999999996%"headers="mcps1.1.6.1.5 "><pid="p28171511181914"><aname="p28171511181914"></a><aname="p28171511181914"></a>Name of the measurement unit, for example, <strongid="b01831838118"><aname="b01831838118"></a><aname="b01831838118"></a>meter</strong>, <strongid="b16720174116"><aname="b16720174116"></a><aname="b16720174116"></a>inch</strong>, or <strongid="b8771567115"><aname="b8771567115"></a><aname="b8771567115"></a>cup</strong>.</p>
<tdclass="cellrowborder"valign="top"width="52.449999999999996%"headers="mcps1.1.6.1.5 "><pid="p167223061914"><aname="p167223061914"></a><aname="p167223061914"></a>Measurement system. The value can be <strongid="b94239164313"><aname="b94239164313"></a><aname="b94239164313"></a>SI</strong>, <strongid="b9791317137"><aname="b9791317137"></a><aname="b9791317137"></a>US</strong>, or <strongid="b81571719033"><aname="b81571719033"></a><aname="b81571719033"></a>UK</strong>.</p>
| unit | string | Yes| Yes| Name of the measurement unit, for example, **meter**, **inch**, or **cup**.|
| measureSystem | string | Yes| Yes| Measurement system. The value can be **SI**, **US**, or **UK**.<br>**System capability**: SystemCapability.Global.I18n|
<td class="cellrowborder" valign="top" width="59.61742826780022%" headers="mcps1.1.5.1.4 "><p id="p3326154515136"><a name="p3326154515136"></a><a name="p3326154515136"></a>Measurement unit to be converted.</p>
<td class="cellrowborder" valign="top" width="59.61742826780022%" headers="mcps1.1.5.1.4 "><p id="p185841414140"><a name="p185841414140"></a><a name="p185841414140"></a>Measurement unit to be converted to.</p>
<td class="cellrowborder" valign="top" width="59.61742826780022%" headers="mcps1.1.5.1.4 "><p id="p59502617146"><a name="p59502617146"></a><a name="p59502617146"></a>Value of the measurement unit to be converted.</p>
<td class="cellrowborder" valign="top" width="59.61742826780022%" headers="mcps1.1.5.1.4 "><p id="p575069171414"><a name="p575069171414"></a><a name="p575069171414"></a>Locale used for formatting, for example, <strong id="b8984198172911"><a name="b8984198172911"></a><a name="b8984198172911"></a>zh-Hans-CN</strong>.</p>
<td class="cellrowborder" valign="top" width="59.61742826780022%" headers="mcps1.1.5.1.4 "><p id="p12452181271416"><a name="p12452181271416"></a><a name="p12452181271416"></a>Style used for formatting. The value can be <strong id="b13885195303818"><a name="b13885195303818"></a><a name="b13885195303818"></a>long</strong>, <strong id="b965955523812"><a name="b965955523812"></a><a name="b965955523812"></a>short</strong>, or <strong id="b15861057203811"><a name="b15861057203811"></a><a name="b15861057203811"></a>medium</strong>.</p>
<td class="cellrowborder" valign="top" width="79.95%" headers="mcps1.1.3.1.2 "><p id="p20327845141310"><a name="p20327845141310"></a><a name="p20327845141310"></a>Character string obtained after formatting based on the measurement unit specified by <strong id="b14371143487"><a name="b14371143487"></a><a name="b14371143487"></a>toUnit</strong>.</p>
<td class="cellrowborder" valign="top" width="79.95%" headers="mcps1.1.3.1.2 "><p id="p1085095982419"><a name="p1085095982419"></a><a name="p1085095982419"></a>Index list for this locale.</p>
<td class="cellrowborder" valign="top" width="59.61742826780022%" headers="mcps1.1.5.1.4 "><p id="p17539177165113"><a name="p17539177165113"></a><a name="p17539177165113"></a><strong id="b345663119182"><a name="b345663119182"></a><a name="b345663119182"></a>text</strong> object whose index is to be obtained.</p>
<td class="cellrowborder" valign="top" width="79.95%" headers="mcps1.1.3.1.2 "><p id="p4164142145313"><a name="p4164142145313"></a><a name="p4164142145313"></a>The value <strong id="b3814161419326"><a name="b3814161419326"></a><a name="b3814161419326"></a>true</strong> indicates that the input character is a digit, and value <strong id="b06351730113213"><a name="b06351730113213"></a><a name="b06351730113213"></a>false</strong> indicates the opposite.</p>
</td>
</tr>
</tbody>
</table>
- Example
```
var isdigit = Character.isDigit("1"); // Return true.
<td class="cellrowborder" valign="top" width="79.95%" headers="mcps1.1.3.1.2 "><p id="p1210245243410"><a name="p1210245243410"></a><a name="p1210245243410"></a>The value <strong id="b42481754183718"><a name="b42481754183718"></a><a name="b42481754183718"></a>true</strong> indicates that the input character is a space, and value <strong id="b2248165443715"><a name="b2248165443715"></a><a name="b2248165443715"></a>false</strong> indicates the opposite.</p>
</td>
</tr>
</tbody>
</table>
- Example
```
var isspacechar = Character.isSpaceChar("a"); // Return false.
<td class="cellrowborder" valign="top" width="79.95%" headers="mcps1.1.3.1.2 "><p id="p330710269413"><a name="p330710269413"></a><a name="p330710269413"></a>The value <strong id="b6934348153810"><a name="b6934348153810"></a><a name="b6934348153810"></a>true</strong> indicates that the input character is a white space, and value <strong id="b1794094873813"><a name="b1794094873813"></a><a name="b1794094873813"></a>false</strong> indicates the opposite.</p>
</td>
</tr>
</tbody>
</table>
- Example
```
var iswhitespace = Character.isWhitespace("a"); // Return false.
<td class="cellrowborder" valign="top" width="79.95%" headers="mcps1.1.3.1.2 "><p id="p11296131944316"><a name="p11296131944316"></a><a name="p11296131944316"></a>The value <strong id="b336183710499"><a name="b336183710499"></a><a name="b336183710499"></a>true</strong> indicates that the input character is of the RTL language, and value <strong id="b93673764913"><a name="b93673764913"></a><a name="b93673764913"></a>false</strong> indicates the opposite.</p>
</td>
</tr>
</tbody>
</table>
- Example
```
var isrtl = Character.isRTL("a"); // Return false.
<td class="cellrowborder" valign="top" width="79.95%" headers="mcps1.1.3.1.2 "><p id="p1238110284470"><a name="p1238110284470"></a><a name="p1238110284470"></a>The value <strong id="b16492153345214"><a name="b16492153345214"></a><a name="b16492153345214"></a>true</strong> indicates that the input character is an ideographic character, and value <strong id="b44924338527"><a name="b44924338527"></a><a name="b44924338527"></a>false</strong> indicates the opposite.</p>
</td>
</tr>
</tbody>
</table>
- Example
```
var isideograph = Character.isIdeograph("a"); // Return false.
<td class="cellrowborder" valign="top" width="79.95%" headers="mcps1.1.3.1.2 "><p id="p813353654910"><a name="p813353654910"></a><a name="p813353654910"></a>The value <strong id="b1364011716543"><a name="b1364011716543"></a><a name="b1364011716543"></a>true</strong> indicates that the input character is a letter, and value <strong id="b1564013745415"><a name="b1564013745415"></a><a name="b1564013745415"></a>false</strong> indicates the opposite.</p>
</td>
</tr>
</tbody>
</table>
- Example
```
var isletter = Character.isLetter("a"); // Return true.
<td class="cellrowborder" valign="top" width="79.95%" headers="mcps1.1.3.1.2 "><p id="p19546124855120"><a name="p19546124855120"></a><a name="p19546124855120"></a>The value <strong id="b1611413487548"><a name="b1611413487548"></a><a name="b1611413487548"></a>true</strong> indicates that the input character is a lowercase letter, and value <strong id="b411484895417"><a name="b411484895417"></a><a name="b411484895417"></a>false</strong> indicates the opposite.</p>
</td>
</tr>
</tbody>
</table>
- Example
```
var islowercase = Character.isLowerCase("a"); // Return true.
<td class="cellrowborder" valign="top" width="79.95%" headers="mcps1.1.3.1.2 "><p id="p1552813513525"><a name="p1552813513525"></a><a name="p1552813513525"></a>The value <strong id="b17483125210558"><a name="b17483125210558"></a><a name="b17483125210558"></a>true</strong> indicates that the input character is an uppercase letter, and value <strong id="b1448915285516"><a name="b1448915285516"></a><a name="b1448915285516"></a>false</strong> indicates the opposite.</p>
</td>
</tr>
</tbody>
</table>
- Example
```
var isuppercase = Character.isUpperCase("a"); // Return false.
<td class="cellrowborder" valign="top" width="66.06339366063393%" headers="mcps1.1.5.1.4 "><p id="p16122192612166"><a name="p16122192612166"></a><a name="p16122192612166"></a>Valid locale value, for example, <strong id="b1619069580"><a name="b1619069580"></a><a name="b1619069580"></a>zh-Hans-CN</strong>. The <a href="#section1312302611613">BreakIterator</a> object segments text according to the rules of the specified locale.</p>
<td class="cellrowborder" valign="top" width="77.24%" headers="mcps1.1.3.1.2 "><p id="p41231726101615"><a name="p41231726101615"></a><a name="p41231726101615"></a>Break iterator used for text segmentation.</p>
<td class="cellrowborder" valign="top" width="66.06339366063393%" headers="mcps1.1.5.1.4 "><p id="p10751194713229"><a name="p10751194713229"></a><a name="p10751194713229"></a>Text to be processed by the <a href="#section1312302611613">BreakIterator</a> object.</p>
| 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.|
<td class="cellrowborder" valign="top" width="77.24%" headers="mcps1.1.3.1.2 "><p id="p184954143512"><a name="p184954143512"></a><a name="p184954143512"></a>Position of the <a href="#section1312302611613">BreakIterator</a> object in the text being processed.</p>
</td>
</tr>
</tbody>
</table>
- Return value
| Type| Description|
| -------- | -------- |
| [BreakIterator](#breakiterator8) | [BreakIterator](#breakiterator8) object used for text segmentation.|
- Example
```
i18n.getLineInstance("en");
```
- Example
```
var iterator = I18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit.");
<td class="cellrowborder" valign="top" width="77.24%" headers="mcps1.1.3.1.2 "><p id="p5570132112394"><a name="p5570132112394"></a><a name="p5570132112394"></a>Offset to the first text boundary of the processed text.</p>
</td>
</tr>
</tbody>
</table>
### setLineBreakText<sup>8+</sup>
- Example
setLineBreakText(text: string): void
```
iterator = I18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit.");
breakIter.first(); // 0
```
Sets the text to be processed by the [BreakIterator](#breakiterator8) object.
| text | string | Yes| Text to be processed by the **BreakIterator** object.|
last\(\): number
- Example
```
iterator = I18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit.");
```
Puts the [BreakIterator](#section1312302611613) object to the last text boundary, which is always the next position after the end of the processed text.
<td class="cellrowborder" valign="top" width="77.24%" headers="mcps1.1.3.1.2 "><p id="p142981556104212"><a name="p142981556104212"></a><a name="p142981556104212"></a>Offset of the last text boundary of the processed text.</p>
</td>
</tr>
</tbody>
</table>
### getLineBreakText<sup>8+</sup>
getLineBreakText(): string
- Example
```
var iterator = I18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit.");
iterator.last(); // 27
```
Obtains the text being processed by the [BreakIterator](#breakiterator8) object.
| string | Text being processed by the **BreakIterator** object.|
next\(index?: number\): number
- Example
```
iterator = I18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit.");
iterator.getLineBreakText(); // Apple is my favorite fruit.
```
Moves the [BreakIterator](#section1312302611613) object backward by the specified number of text boundaries if the specified index is a positive number. If the index is a negative number, the [BreakIterator](#section1312302611613) object will be moved forward by the corresponding number of text boundaries. If no index is specified, the index will be treated as **1**.
<td class="cellrowborder" valign="top" width="66.06339366063393%" headers="mcps1.1.5.1.4 "><p id="p157113716161"><a name="p157113716161"></a><a name="p157113716161"></a>Number of text boundaries by which the <a href="#section1312302611613">BreakIterator</a> object is moved. A positive value indicates that the text boundary is moved backward, and a negative value indicates the opposite. If no index is specified, the index will be treated as <strong id="b195933232918"><a name="b195933232918"></a><a name="b195933232918"></a>1</strong>.</p>
<td class="cellrowborder" valign="top" width="77.24%" headers="mcps1.1.3.1.2 "><p id="p13133111851319"><a name="p13133111851319"></a><a name="p13133111851319"></a>Position of the <a href="#section1312302611613">BreakIterator</a> object in the text after it is moved by the specified number of text boundaries. The value <strong id="b4493281401"><a name="b4493281401"></a><a name="b4493281401"></a>-1</strong> is returned if the position of the <a href="#section1312302611613">BreakIterator</a> object is outside of the processed text after it is moved by the specified number of text boundaries.</p>
</td>
</tr>
</tbody>
</table>
- Example
```
var iterator = I18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit.");
<td class="cellrowborder" valign="top" width="77.24%" headers="mcps1.1.3.1.2 "><p id="p313510183133"><a name="p313510183133"></a><a name="p313510183133"></a>Position of the <a href="#section1312302611613">BreakIterator</a> object in the text after it is moved to the previous text boundary. The value <strong id="b152571690117"><a name="b152571690117"></a><a name="b152571690117"></a>-1</strong> is returned if the position of the <a href="#section1312302611613">BreakIterator</a> object is outside of the processed text after it is moved by the specified number of text boundaries.</p>
</td>
</tr>
</tbody>
</table>
- Example
```
var iterator = I18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit.");
<td class="cellrowborder" valign="top" width="66.06339366063393%" headers="mcps1.1.5.1.4 "><p id="p1274585312307"><a name="p1274585312307"></a><a name="p1274585312307"></a>Offset to the position before the text boundary to which the <a href="#section1312302611613">BreakIterator</a> object is moved.</p>
<td class="cellrowborder" valign="top" width="77.24%" headers="mcps1.1.3.1.2 "><p id="p1374625317301"><a name="p1374625317301"></a><a name="p1374625317301"></a>The value <strong id="b1066631131915"><a name="b1066631131915"></a><a name="b1066631131915"></a>-1</strong> is returned if the text boundary to which the <a href="#section1312302611613">BreakIterator</a> object is moved is outside of the processed text.</p>
</td>
</tr>
</tbody>
</table>
- Example
```
var iterator = I18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit.");
Checks whether the position specified by the offset is a text boundary. If **true** is returned, the [BreakIterator](#section1312302611613) object is moved to the position specified by the offset. If **false** is returned, the [BreakIterator](#section1312302611613) object is moved to the text boundary after the position specified by the offset, which is equivalent to calling [following\(offset\)](#section1743155314301).
<td class="cellrowborder" valign="top" width="77.24%" headers="mcps1.1.3.1.2 "><p id="p291165623012"><a name="p291165623012"></a><a name="p291165623012"></a>The value <strong id="b910010472195"><a name="b910010472195"></a><a name="b910010472195"></a>true</strong> indicates that the position specified by the offset is a text boundary, and value <strong id="b4301203582014"><a name="b4301203582014"></a><a name="b4301203582014"></a>false</strong> indicates the opposite.</p>
</td>
</tr>
</tbody>
</table>
- Example
```
var iterator = I18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit.");
| number | Offset of the last text boundary of the processed text.|
- Example
```
iterator = I18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit.");
iterator.last(); // 27
```
### next<sup>8+</sup>
next(index?: number): number
Moves the [BreakIterator](#breakiterator8) object backward by the specified number of text boundaries if the specified index is a positive number. If the index is a negative number, the [BreakIterator](#breakiterator8) object will be moved forward by the corresponding number of text boundaries. If no index is specified, the index will be treated as **1**.
| index | number | No| Number of text boundaries by which the [BreakIterator](#breakiterator8) object is moved. A positive value indicates that the text boundary is moved backward, and a negative value indicates the opposite. If no index is specified, the index will be treated as **1**.|
- Return value
| Type| Description|
| -------- | -------- |
| number | Position of the [BreakIterator](#breakiterator8) object in the text after it is moved by the specified number of text boundaries. 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 text boundaries.|
- Example
```
iterator = I18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit.");
iterator.first(); // 0
iterator.next(); // 6
iterator.next(10); // -1
```
### previous<sup>8+</sup>
previous(): number
Moves the [BreakIterator](#breakiterator8) object to the previous text boundary.
| number | Position of the [BreakIterator](#breakiterator8) object in the text after it is moved to the previous text boundary. 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 text boundaries.|
- Return values
- Example
```
iterator = I18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit.");
<td class="cellrowborder" valign="top" width="79.95%" headers="mcps1.1.3.1.2 "><p id="p1748010175390"><a name="p1748010175390"></a><a name="p1748010175390"></a>The value <strong id="b19194155614566"><a name="b19194155614566"></a><a name="b19194155614566"></a>true</strong> indicates that the 24-hour clock is used, and value <strong id="b181941956185614"><a name="b181941956185614"></a><a name="b181941956185614"></a>false</strong> indicates the opposite.</p>
</td>
</tr>
</tbody>
</table>
### following<sup>8+</sup>
- Example
following(offset: number): number
```
var is24HourClock = i18n.is24HourClock();
```
Moves the [BreakIterator](#breakiterator8) object to the text boundary after the position specified by the offset. Position of the [BreakIterator](#breakiterator8) object after it is moved to the text boundary after the position specified by the offset.
| offset | number | Yes| Offset to the position before the text boundary to which the [BreakIterator](#breakiterator8) object is moved.|
set24HourClock\(option: boolean\): boolean
- Return value
| Type| Description|
| -------- | -------- |
| number | The value **-1** is returned if the text boundary to which the [BreakIterator](#breakiterator8) object is moved is outside of the processed text.|
- Example
```
iterator = I18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit.");
iterator.following(0); // 6
iterator.following(100); // -1
iterator.current(); // 27
```
### isBoundary<sup>8+</sup>
isBoundary(offset: number): boolean
Checks whether the position specified by the offset is a text boundary. If **true** is returned, the [BreakIterator](#breakiterator8) object is moved to the position specified by the offset. If **false** is returned, the [BreakIterator](#breakiterator8) object is moved to the text boundary after the position specified by the offset, which is equivalent to calling [following](#following8)(offset).
<td class="cellrowborder" valign="top" width="59.61742826780022%" headers="mcps1.1.5.1.4 "><p id="p148651140114219"><a name="p148651140114219"></a><a name="p148651140114219"></a>Whether to enable the 24-hour clock. The value <strong id="b689195563"><a name="b689195563"></a><a name="b689195563"></a>true</strong> means to enable the 24-hour clock, and value <strong id="b1589185866"><a name="b1589185866"></a><a name="b1589185866"></a>false</strong> means the opposite.</p>
<td class="cellrowborder" valign="top" width="79.95%" headers="mcps1.1.3.1.2 "><p id="p9866540184217"><a name="p9866540184217"></a><a name="p9866540184217"></a>The value <strong id="b15855131872"><a name="b15855131872"></a><a name="b15855131872"></a>true</strong> indicates that the 24-hour clock is enabled, and value <strong id="b178561317714"><a name="b178561317714"></a><a name="b178561317714"></a>false</strong> indicates the opposite.</p>
| option | boolean | Yes| Whether to enable the 24-hour clock. The value **true** means to enable the 24-hour clock, and value **false** means the opposite.|
- Return value
| Type| Description|
| -------- | -------- |
| boolean | The value **true** indicates that the 24-hour clock is enabled, and value **false** indicates the opposite.|
<td class="cellrowborder" valign="top" width="59.61742826780022%" headers="mcps1.1.5.1.4 "><p id="p14019219311"><a name="p14019219311"></a><a name="p14019219311"></a>Position to which the preferred language is added.</p>
<td class="cellrowborder" valign="top" width="79.95%" headers="mcps1.1.3.1.2 "><p id="p1626712619118"><a name="p1626712619118"></a><a name="p1626712619118"></a>The value <strong id="b92874433115"><a name="b92874433115"></a><a name="b92874433115"></a>true</strong> indicates that the preferred language is added, and value <strong id="b1028774381119"><a name="b1028774381119"></a><a name="b1028774381119"></a>false</strong> indicates the opposite.</p>
</td>
</tr>
</tbody>
</table>
- Example
```
// Add zh-CN to the preferred language list.
var language = 'zh-CN';
var index = 0;
var success = i18n.addPreferredLanguage(langauge, index);
<td class="cellrowborder" valign="top" width="59.61742826780022%" headers="mcps1.1.5.1.4 "><p id="p0873252171016"><a name="p0873252171016"></a><a name="p0873252171016"></a>Position of the preferred language to delete.</p>
<td class="cellrowborder" valign="top" width="79.95%" headers="mcps1.1.3.1.2 "><p id="p1487495219109"><a name="p1487495219109"></a><a name="p1487495219109"></a>The value <strong id="b714042831817"><a name="b714042831817"></a><a name="b714042831817"></a>true</strong> indicates that the preferred language is deleted, and value <strong id="b9140182881818"><a name="b9140182881818"></a><a name="b9140182881818"></a>false</strong> indicates the opposite.</p>
</td>
</tr>
</tbody>
</table>
- Example
```
// Delete the first preferred language from the preferred language list.
var index = 0;
var success = i18n.removePreferredLanguage(index);
<td class="cellrowborder" valign="top" width="79.95%" headers="mcps1.1.3.1.2 "><p id="p54511512101816"><a name="p54511512101816"></a><a name="p54511512101816"></a>Preferred language that best matches the HAP resource.</p>
</td>
</tr>
</tbody>
</table>
## i18n.getFirstPreferredLanguage<sup>8+</sup>
getFirstPreferredLanguage(): string
Obtains the preferred language that best matches the HAP resource.