@@ -9,7 +9,7 @@ APIs are provided to access the system language and region information.
...
@@ -9,7 +9,7 @@ APIs are provided to access the system language and region information.
### Available APIs
### Available APIs
| Module | API | Description |
| Module | API | Description |
| -------- | -------- | -------- |
| -------- | -------- | -------- |
| ohos.i18n | getSystemLanguage(): string | Obtains the system language. |
| ohos.i18n | getSystemLanguage(): string | Obtains the system language. |
| ohos.i18n | getSystemRegion(): string | Obtains the system region. |
| ohos.i18n | getSystemRegion(): string | Obtains the system region. |
...
@@ -22,7 +22,7 @@ APIs are provided to access the system language and region information.
...
@@ -22,7 +22,7 @@ APIs are provided to access the system language and region information.
### How to Develop
### How to Develop
1. Obtain the system language.
1. Obtain the system language.<br>
Call the **getSystemLanguage** method to obtain the system language (**i18n** is the name of the imported module).
Call the **getSystemLanguage** method to obtain the system language (**i18n** is the name of the imported module).
...
@@ -30,21 +30,21 @@ APIs are provided to access the system language and region information.
...
@@ -30,21 +30,21 @@ APIs are provided to access the system language and region information.
var language = i18n.getSystemLanguage();
var language = i18n.getSystemLanguage();
```
```
2. Obtains the system region.
2. Obtain the system region.<br>
Call the **getSystemRegion** method to obtain the system region.
Call the **getSystemRegion** method to obtain the system region.
```
```
var region = i18n.getSystemRegion();
var region = i18n.getSystemRegion();
```
```
3. Obtain the system locale.
3. Obtain the system locale.<br>
Call the **getSystemLocale** method to obtain the system locale.
Call the **getSystemLocale** method to obtain the system locale.
```
```
var locale = i18n.getSystemLocale();
var locale = i18n.getSystemLocale();
```
```
4. Check whether the locale's language is RTL.
4. Check whether the locale's language is RTL.<br>
Call the **isRTL** method to check whether the locale's language is RTL.
Call the **isRTL** method to check whether the locale's language is RTL.
...
@@ -52,14 +52,14 @@ APIs are provided to access the system language and region information.
...
@@ -52,14 +52,14 @@ APIs are provided to access the system language and region information.
var rtl = i18n.isRTL("zh-CN");
var rtl = i18n.isRTL("zh-CN");
```
```
5. Check whether the system uses a 24-hour clock.
5. Check whether the system uses a 24-hour clock.<br>
Call the **is24HourClock** method to check whether the system uses a 24-hour clock.
Call the **is24HourClock** method to check whether the system uses a 24-hour clock.
```
```
var hourClock = i18n.is24HourClock();
var hourClock = i18n.is24HourClock();
```
```
6. Obtain the localized display of a language.
6. Obtain the localized display of a language.<br>
Call the **getDisplayLanguage** method to obtain the localized display of a language. **language** indicates the language to be localized, **locale** indicates the locale, and **sentenceCase** indicates whether the first letter of the result must be capitalized.
Call the **getDisplayLanguage** method to obtain the localized display of a language. **language** indicates the language to be localized, **locale** indicates the locale, and **sentenceCase** indicates whether the first letter of the result must be capitalized.
```
```
...
@@ -69,7 +69,7 @@ APIs are provided to access the system language and region information.
...
@@ -69,7 +69,7 @@ APIs are provided to access the system language and region information.
var localizedLanguage = i18n.getDisplayLanguage(language, locale, sentenceCase);
var localizedLanguage = i18n.getDisplayLanguage(language, locale, sentenceCase);
```
```
7. Obtain the localized display of a country.
7. Obtain the localized display of a country.<br>
Call the **getDisplayCountry** method to obtain the localized display of a country. **country** indicates the country to be localized, **locale** indicates the locale, and **sentenceCase** indicates whether the first letter of the result must be capitalized.
Call the **getDisplayCountry** method to obtain the localized display of a country. **country** indicates the country to be localized, **locale** indicates the locale, and **sentenceCase** indicates whether the first letter of the result must be capitalized.
```
```
...
@@ -105,7 +105,7 @@ APIs are provided to access the system language and region information.
...
@@ -105,7 +105,7 @@ APIs are provided to access the system language and region information.
### How to Develop
### How to Develop
1. Instantiate a **Calendar** object.
1. Instantiate a **Calendar** object.<br>
Call the **getCalendar** method to obtain the time zone object of a specific locale and type (**i18n** is the name of the imported module). **type** indicates the valid calendar type, for example, **buddhist**, **chinese**, **coptic**, **ethiopic**, **hebrew**, **gregory**, **indian**, **islamic_civil**, **islamic_tbla**, **islamic_umalqura**, **japanese**, and **persian**. If **type** is left unspecified, the default calendar type of the locale is used.
Call the **getCalendar** method to obtain the time zone object of a specific locale and type (**i18n** is the name of the imported module). **type** indicates the valid calendar type, for example, **buddhist**, **chinese**, **coptic**, **ethiopic**, **hebrew**, **gregory**, **indian**, **islamic_civil**, **islamic_tbla**, **islamic_umalqura**, **japanese**, and **persian**. If **type** is left unspecified, the default calendar type of the locale is used.
...
@@ -113,7 +113,7 @@ APIs are provided to access the system language and region information.
...
@@ -113,7 +113,7 @@ APIs are provided to access the system language and region information.
var calendar = i18n.getCalendar("zh-CN", "gregory);
var calendar = i18n.getCalendar("zh-CN", "gregory);
```
```
2. Set the time for the **Calendar** object.
2. Set the time for the **Calendar** object.<br>
Call the **setTime** method to set the time of the **Calendar** object. This method receives two types of parameters. One is a **Date** object, and the other is a value indicating the number of milliseconds elapsed since January 1, 1970, 00:00:00 GMT.
Call the **setTime** method to set the time of the **Calendar** object. This method receives two types of parameters. One is a **Date** object, and the other is a value indicating the number of milliseconds elapsed since January 1, 1970, 00:00:00 GMT.
```
```
...
@@ -123,14 +123,14 @@ APIs are provided to access the system language and region information.
...
@@ -123,14 +123,14 @@ APIs are provided to access the system language and region information.
calendar.setTime(date2);
calendar.setTime(date2);
```
```
3. Set the year, month, day, hour, minute, and second for the **Calendar** object.
3. Set the year, month, day, hour, minute, and second for the **Calendar** object.<br>
Call the **set** method to set the year, month, day, hour, minute, and second for the **Calendar** object.
Call the **set** method to set the year, month, day, hour, minute, and second for the **Calendar** object.
```
```
calendar.set(2021, 12, 21, 6, 0, 0)
calendar.set(2021, 12, 21, 6, 0, 0)
```
```
4. Set and obtain the time zone for the **Calendar** object.
4. Set and obtain the time zone for the **Calendar** object.<br>
Call the **setTimeZone** and **getTimeZone** methods to set and obtain the time zone for the **Calendar** object. The **setTimeZone** method requires an input string to indicate the time zone to be set.
Call the **setTimeZone** and **getTimeZone** methods to set and obtain the time zone for the **Calendar** object. The **setTimeZone** method requires an input string to indicate the time zone to be set.
...
@@ -139,7 +139,7 @@ APIs are provided to access the system language and region information.
...
@@ -139,7 +139,7 @@ APIs are provided to access the system language and region information.
var timezone = calendar.getTimeZone();
var timezone = calendar.getTimeZone();
```
```
5. Set and obtain the first day of a week for the **Calendar** object.
5. Set and obtain the first day of a week for the **Calendar** object.<br>
Call the **setFirstDayOfWeek** and **getFirstDayOfWeek** methods to set and obtain the first day of a week for the **Calendar** object. **setFirstDayOfWeek** must be set to a value indicating the first day of a week. The value **1** indicates Sunday, and the value **7** indicates Saturday.
Call the **setFirstDayOfWeek** and **getFirstDayOfWeek** methods to set and obtain the first day of a week for the **Calendar** object. **setFirstDayOfWeek** must be set to a value indicating the first day of a week. The value **1** indicates Sunday, and the value **7** indicates Saturday.
...
@@ -148,7 +148,7 @@ APIs are provided to access the system language and region information.
...
@@ -148,7 +148,7 @@ APIs are provided to access the system language and region information.
var firstDayOfWeek = calendar.getFirstDayOfWeek();
var firstDayOfWeek = calendar.getFirstDayOfWeek();
```
```
6. Set and obtain the minimum count of days in the first week for the **Calendar** object.
6. Set and obtain the minimum count of days in the first week for the **Calendar** object.<br>
Call the **setMinimalDaysInFirstWeek** and **getMinimalDaysInFirstWeek** methods to set and obtain the minimum count of days in the first week for the **Calendar** object.
Call the **setMinimalDaysInFirstWeek** and **getMinimalDaysInFirstWeek** methods to set and obtain the minimum count of days in the first week for the **Calendar** object.
```
```
...
@@ -156,7 +156,7 @@ APIs are provided to access the system language and region information.
...
@@ -156,7 +156,7 @@ APIs are provided to access the system language and region information.
var minimalDaysInFirstWeek = calendar.getMinimalDaysInFirstWeek();
var minimalDaysInFirstWeek = calendar.getMinimalDaysInFirstWeek();
```
```
7. Obtain the localized display of the **Calendar** object.
7. Obtain the localized display of the **Calendar** object.<br>
Call the **getDisplayName** method to obtain the localized display of the **Calendar** object.
Call the **getDisplayName** method to obtain the localized display of the **Calendar** object.
...
@@ -164,7 +164,7 @@ APIs are provided to access the system language and region information.
...
@@ -164,7 +164,7 @@ APIs are provided to access the system language and region information.
var localizedName = calendar.getDisplayName("zh-CN");
var localizedName = calendar.getDisplayName("zh-CN");
```
```
8. Check whether a date is a weekend.
8. Check whether a date is a weekend.<br>
Call the **isWeekend** method to determine whether the input date is a weekend.
Call the **isWeekend** method to determine whether the input date is a weekend.
...
@@ -181,7 +181,7 @@ APIs are provided to access the system language and region information.
...
@@ -181,7 +181,7 @@ APIs are provided to access the system language and region information.
| ohos.i18n | isValidNumber(number: string): boolean<sup>8+</sup> | Checks whether the value of **number** is a phone number in the correct format. |
| ohos.i18n | isValidNumber(number: string): boolean<sup>8+</sup> | Checks whether the value of **number** is a phone number in the correct format. |
...
@@ -190,7 +190,7 @@ APIs are provided to access the system language and region information.
...
@@ -190,7 +190,7 @@ APIs are provided to access the system language and region information.
### How to Develop
### How to Develop
1. Instantiate a **PhoneNumberFormat** object.
1. Instantiate a **PhoneNumberFormat** object.<br>
Call the **PhoneNumberFormat** constructor to instantiate a **PhoneNumberFormat** object. The country code and formatting options of the phone number need to be passed into this constructor. The formatting options are optional, including a style option. Values of this option include: **E164**, **INTERNATIONAL**, **NATIONAL**, and **RFC3966**.
Call the **PhoneNumberFormat** constructor to instantiate a **PhoneNumberFormat** object. The country code and formatting options of the phone number need to be passed into this constructor. The formatting options are optional, including a style option. Values of this option include: **E164**, **INTERNATIONAL**, **NATIONAL**, and **RFC3966**.
...
@@ -258,7 +258,7 @@ An API can be called to implement measurement conversion.
...
@@ -258,7 +258,7 @@ An API can be called to implement measurement conversion.
### How to Develop
### How to Develop
1. Instantiate an **IndexUtil** object.
1. Instantiate an **IndexUtil** object.<br>
Call the **getInstance** method to instantiate an **IndexUtil** object for a specific locale. When the **locale** parameter is empty, instantiate an **IndexUtil** object of the default locale.
Call the **getInstance** method to instantiate an **IndexUtil** object for a specific locale. When the **locale** parameter is empty, instantiate an **IndexUtil** object of the default locale.
...
@@ -266,21 +266,21 @@ An API can be called to implement measurement conversion.
...
@@ -266,21 +266,21 @@ An API can be called to implement measurement conversion.
var indexUtil = getInstance("zh-CN");
var indexUtil = getInstance("zh-CN");
```
```
2. Obtain the index list.
2. Obtain the index list.<br>
Call the **getIndexList** method to obtain the alphabet index list of the current locale.
Call the **getIndexList** method to obtain the alphabet index list of the current locale.
```
```
var indexList = indexUtil.getIndexList();
var indexList = indexUtil.getIndexList();
```
```
3. Add an index.
3. Add an index.<br>
Call the **addLocale** method to add the alphabet index of a new locale to the current index list.
Call the **addLocale** method to add the alphabet index of a new locale to the current index list.
```
```
indexUtil.addLocale("ar")
indexUtil.addLocale("ar")
```
```
4. Obtain the index of a string.
4. Obtain the index of a string.<br>
Call the **getIndex** method to obtain the alphabet index of a string.
Call the **getIndex** method to obtain the alphabet index of a string.
```
```
...
@@ -312,7 +312,7 @@ When a text is displayed in more than one line, [BreakIterator](../reference/api
...
@@ -312,7 +312,7 @@ When a text is displayed in more than one line, [BreakIterator](../reference/api
### How to Develop
### How to Develop
1. Instantiate a **BreakIterator** object.
1. Instantiate a **BreakIterator** object.<br>
Call the **getLineInstance** method to instantiate a **BreakIterator** object.
Call the **getLineInstance** method to instantiate a **BreakIterator** object.
...
@@ -321,7 +321,7 @@ When a text is displayed in more than one line, [BreakIterator](../reference/api
...
@@ -321,7 +321,7 @@ When a text is displayed in more than one line, [BreakIterator](../reference/api
var breakIterator = i18n.getLineInstance(locale);
var breakIterator = i18n.getLineInstance(locale);
```
```
2. Set and access the text that requires line breaking.
2. Set and access the text that requires line breaking.<br>
Call the **setLineBreakText** and **getLineBreakText** methods to set and access the text that requires line breaking.
Call the **setLineBreakText** and **getLineBreakText** methods to set and access the text that requires line breaking.
...
@@ -331,7 +331,7 @@ When a text is displayed in more than one line, [BreakIterator](../reference/api
...
@@ -331,7 +331,7 @@ When a text is displayed in more than one line, [BreakIterator](../reference/api
var breakText = breakIterator.getLineBreakText();
var breakText = breakIterator.getLineBreakText();
```
```
3. Obtain the current position of the **BreakIterator** object.
3. Obtain the current position of the **BreakIterator** object.<br>
Call the **current** method to obtain the current position of the **BreakIterator** object in the text being processed.
Call the **current** method to obtain the current position of the **BreakIterator** object in the text being processed.
...
@@ -339,7 +339,7 @@ When a text is displayed in more than one line, [BreakIterator](../reference/api
...
@@ -339,7 +339,7 @@ When a text is displayed in more than one line, [BreakIterator](../reference/api
var pos = breakIterator.current();
var pos = breakIterator.current();
```
```
4. Set the position of a **BreakIterator** object.
4. Set the position of a **BreakIterator** object.<br>
The following APIs are provided to adjust the **first**, **last**, **next**, **previous**, or **following** position of the **BreakIterator** object in the text to be processed.
The following APIs are provided to adjust the **first**, **last**, **next**, **previous**, or **following** position of the **BreakIterator** object in the text to be processed.
...
@@ -355,7 +355,7 @@ When a text is displayed in more than one line, [BreakIterator](../reference/api
...
@@ -355,7 +355,7 @@ When a text is displayed in more than one line, [BreakIterator](../reference/api
var followingPos = breakIterator.following(10);
var followingPos = breakIterator.following(10);
```
```
5. Determine whether a position is a break point.
5. Determine whether a position is a break point.<br>
Call the **isBoundary** method to determine whether a position is a break point. If yes, **true** is returned and the **BreakIterator** object is moved to this position. If no, **false** is returned and the **BreakIterator** object is moved to a break point after this position.
Call the **isBoundary** method to determine whether a position is a break point. If yes, **true** is returned and the **BreakIterator** object is moved to this position. If no, **false** is returned and the **BreakIterator** object is moved to a break point after this position.