提交 d3f7899a 编写于 作者: S shawn_he

update doc

Signed-off-by: Nshawn_he <shawn.he@huawei.com>
上级 4c088a70
...@@ -34,7 +34,7 @@ Obtains the localized script for the specified language. ...@@ -34,7 +34,7 @@ Obtains the localized script for the specified language.
| string | Localized script for the specified language.| | string | Localized script for the specified language.|
**Example** **Example**
``` ```js
i18n.getDisplayLanguage("zh", "en-GB", true); i18n.getDisplayLanguage("zh", "en-GB", true);
i18n.getDisplayLanguage("zh", "en-GB"); i18n.getDisplayLanguage("zh", "en-GB");
``` ```
...@@ -61,7 +61,7 @@ Obtains the localized script for the specified country. ...@@ -61,7 +61,7 @@ Obtains the localized script for the specified country.
| string | Localized script for the specified country.| | string | Localized script for the specified country.|
**Example** **Example**
``` ```js
i18n.getDisplayCountry("zh-CN", "en-GB", true); i18n.getDisplayCountry("zh-CN", "en-GB", true);
i18n.getDisplayCountry("zh-CN", "en-GB"); i18n.getDisplayCountry("zh-CN", "en-GB");
``` ```
...@@ -86,7 +86,7 @@ Checks whether the localized script for the specified language is displayed from ...@@ -86,7 +86,7 @@ Checks whether the localized script for the specified language is displayed from
| boolean | Returns **true** if the localized script is displayed from right to left; returns **false** otherwise.| | boolean | Returns **true** if the localized script is displayed from right to left; returns **false** otherwise.|
**Example** **Example**
``` ```js
i18n.isRTL("zh-CN");// Since Chinese is not written from right to left, false is returned. 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. i18n.isRTL("ar-EG");// Since Arabic is written from right to left, true is returned.
``` ```
...@@ -106,7 +106,7 @@ Obtains the system language. ...@@ -106,7 +106,7 @@ Obtains the system language.
| string | System language ID.| | string | System language ID.|
**Example** **Example**
``` ```js
i18n.getSystemLanguage(); i18n.getSystemLanguage();
``` ```
...@@ -134,7 +134,7 @@ This is a system API. ...@@ -134,7 +134,7 @@ This is a system API.
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example** **Example**
``` ```js
i18n.setSystemLanguage('zh'); i18n.setSystemLanguage('zh');
``` ```
...@@ -155,7 +155,7 @@ Obtains the list of system languages. ...@@ -155,7 +155,7 @@ Obtains the list of system languages.
| Array&lt;string&gt; | List of the IDs of system languages.| | Array&lt;string&gt; | List of the IDs of system languages.|
**Example** **Example**
``` ```js
i18n.getSystemLanguages(); i18n.getSystemLanguages();
``` ```
...@@ -181,7 +181,7 @@ Obtains the list of countries and regions supported for the specified language. ...@@ -181,7 +181,7 @@ Obtains the list of countries and regions supported for the specified language.
| Array&lt;string&gt; | List of the IDs of the countries and regions supported for the specified language.| | Array&lt;string&gt; | List of the IDs of the countries and regions supported for the specified language.|
**Example** **Example**
``` ```js
i18n.getSystemCountries('zh'); i18n.getSystemCountries('zh');
``` ```
...@@ -200,7 +200,7 @@ Obtains the system region. ...@@ -200,7 +200,7 @@ Obtains the system region.
| string | System region ID.| | string | System region ID.|
**Example** **Example**
``` ```js
i18n.getSystemRegion(); i18n.getSystemRegion();
``` ```
...@@ -228,7 +228,7 @@ This is a system API. ...@@ -228,7 +228,7 @@ This is a system API.
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example** **Example**
``` ```js
i18n.setSystemRegion('CN'); i18n.setSystemRegion('CN');
``` ```
...@@ -247,7 +247,7 @@ Obtains the system locale. ...@@ -247,7 +247,7 @@ Obtains the system locale.
| string | System locale ID.| | string | System locale ID.|
**Example** **Example**
``` ```js
i18n.getSystemLocale(); i18n.getSystemLocale();
``` ```
...@@ -275,7 +275,7 @@ This is a system API. ...@@ -275,7 +275,7 @@ This is a system API.
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example** **Example**
``` ```js
i18n.setSystemLocale('zh-CN'); i18n.setSystemLocale('zh-CN');
``` ```
...@@ -302,7 +302,7 @@ Checks whether the system language matches the specified region. ...@@ -302,7 +302,7 @@ Checks whether the system language matches the specified region.
| boolean | Returns **true** if the system language matches the specified region; returns **false** otherwise.| | boolean | Returns **true** if the system language matches the specified region; returns **false** otherwise.|
**Example** **Example**
``` ```js
i18n.isSuggested('zh', 'CN'); i18n.isSuggested('zh', 'CN');
``` ```
...@@ -327,7 +327,7 @@ Obtains a **Calendar** object. ...@@ -327,7 +327,7 @@ Obtains a **Calendar** object.
| [Calendar](#calendar8) | **Calendar** object.| | [Calendar](#calendar8) | **Calendar** object.|
**Example** **Example**
``` ```js
i18n.getCalendar("zh-Hans", "gregory"); i18n.getCalendar("zh-Hans", "gregory");
``` ```
...@@ -349,7 +349,7 @@ Sets the date for this **Calendar** object. ...@@ -349,7 +349,7 @@ Sets the date for this **Calendar** object.
| date | Date | Yes | Date to be set for the **Calendar** object.| | date | Date | Yes | Date to be set for the **Calendar** object.|
**Example** **Example**
``` ```js
var calendar = i18n.getCalendar("en-US", "gregory"); var calendar = i18n.getCalendar("en-US", "gregory");
var date = new Date(2021, 10, 7, 8, 0, 0, 0); var date = new Date(2021, 10, 7, 8, 0, 0, 0);
calendar.setTime(date); calendar.setTime(date);
...@@ -370,7 +370,7 @@ Sets the date and time for this **Calendar** object. The value is represented by ...@@ -370,7 +370,7 @@ Sets the date and time for this **Calendar** object. The value is represented by
| time | number | Yes | Number of milliseconds that have elapsed since the Unix epoch.| | time | number | Yes | Number of milliseconds that have elapsed since the Unix epoch.|
**Example** **Example**
``` ```js
var calendar = i18n.getCalendar("en-US", "gregory"); var calendar = i18n.getCalendar("en-US", "gregory");
calendar.setTime(10540800000); calendar.setTime(10540800000);
``` ```
...@@ -395,7 +395,7 @@ Sets the year, month, day, hour, minute, and second for this **Calendar** object ...@@ -395,7 +395,7 @@ Sets the year, month, day, hour, minute, and second for this **Calendar** object
| second | number | No | Second to set. | | second | number | No | Second to set. |
**Example** **Example**
``` ```js
var calendar = i18n.getCalendar("zh-Hans"); var calendar = i18n.getCalendar("zh-Hans");
calendar.set(2021, 10, 1, 8, 0, 0); // set time to 2021.10.1 08:00:00 calendar.set(2021, 10, 1, 8, 0, 0); // set time to 2021.10.1 08:00:00
``` ```
...@@ -415,7 +415,7 @@ Sets the time zone of this **Calendar** object. ...@@ -415,7 +415,7 @@ Sets the time zone of this **Calendar** object.
| timezone | string | Yes | Time zone, for example, **Asia/Shanghai**.| | timezone | string | Yes | Time zone, for example, **Asia/Shanghai**.|
**Example** **Example**
``` ```js
var calendar = i18n.getCalendar("zh-Hans"); var calendar = i18n.getCalendar("zh-Hans");
calendar.setTimeZone("Asia/Shanghai"); calendar.setTimeZone("Asia/Shanghai");
``` ```
...@@ -435,7 +435,7 @@ Obtains the time zone of this **Calendar** object. ...@@ -435,7 +435,7 @@ Obtains the time zone of this **Calendar** object.
| string | Time zone of the **Calendar** object.| | string | Time zone of the **Calendar** object.|
**Example** **Example**
``` ```js
var calendar = i18n.getCalendar("zh-Hans"); var calendar = i18n.getCalendar("zh-Hans");
calendar.setTimeZone("Asia/Shanghai"); calendar.setTimeZone("Asia/Shanghai");
calendar.getTimeZone(); // Asia/Shanghai" calendar.getTimeZone(); // Asia/Shanghai"
...@@ -456,7 +456,7 @@ Obtains the start day of a week for this **Calendar** object. ...@@ -456,7 +456,7 @@ Obtains the start day of a week for this **Calendar** object.
| number | Start day of a week. The value **1** indicates Sunday, and the value **7** indicates Saturday.| | number | Start day of a week. The value **1** indicates Sunday, and the value **7** indicates Saturday.|
**Example** **Example**
``` ```js
var calendar = i18n.getCalendar("en-US", "gregory"); var calendar = i18n.getCalendar("en-US", "gregory");
calendar.getFirstDayOfWeek(); calendar.getFirstDayOfWeek();
``` ```
...@@ -476,7 +476,7 @@ Sets the start day of a week for this **Calendar** object. ...@@ -476,7 +476,7 @@ Sets the start day of a week for this **Calendar** object.
| value | number | No | Start day of a week. The value **1** indicates Sunday, and the value **7** indicates Saturday.| | value | number | No | Start day of a week. The value **1** indicates Sunday, and the value **7** indicates Saturday.|
**Example** **Example**
``` ```js
var calendar = i18n.getCalendar("zh-Hans"); var calendar = i18n.getCalendar("zh-Hans");
calendar.setFirstDayOfWeek(0); calendar.setFirstDayOfWeek(0);
``` ```
...@@ -496,7 +496,7 @@ Obtains the minimum number of days in the first week of a year. ...@@ -496,7 +496,7 @@ Obtains the minimum number of days in the first week of a year.
| number | Minimum number of days in the first week of a year.| | number | Minimum number of days in the first week of a year.|
**Example** **Example**
``` ```js
var calendar = i18n.getCalendar("zh-Hans"); var calendar = i18n.getCalendar("zh-Hans");
calendar.getMinimalDaysInFirstWeek(); calendar.getMinimalDaysInFirstWeek();
``` ```
...@@ -516,7 +516,7 @@ Sets the minimum number of days in the first week of a year. ...@@ -516,7 +516,7 @@ Sets the minimum number of days in the first week of a year.
| value | number | No | Minimum number of days in the first week of a year.| | value | number | No | Minimum number of days in the first week of a year.|
**Example** **Example**
``` ```js
var calendar = i18n.getCalendar("zh-Hans"); var calendar = i18n.getCalendar("zh-Hans");
calendar.setMinimalDaysInFirstWeek(3); calendar.setMinimalDaysInFirstWeek(3);
``` ```
...@@ -541,7 +541,7 @@ Obtains the value of the specified field in the **Calendar** object. ...@@ -541,7 +541,7 @@ Obtains the value of the specified field in the **Calendar** object.
| 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**.| | 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** **Example**
``` ```js
var calendar = i18n.getCalendar("zh-Hans"); var calendar = i18n.getCalendar("zh-Hans");
calendar.set(2021, 10, 1, 8, 0, 0); // set time to 2021.10.1 08:00:00 calendar.set(2021, 10, 1, 8, 0, 0); // set time to 2021.10.1 08:00:00
calendar.get("hour_of_day"); // 8 calendar.get("hour_of_day"); // 8
...@@ -567,7 +567,7 @@ Obtains the name of the **Calendar** object displayed for the specified locale. ...@@ -567,7 +567,7 @@ Obtains the name of the **Calendar** object displayed for the specified locale.
| string | Name of the **Calendar** object displayed for the specified locale.| | string | Name of the **Calendar** object displayed for the specified locale.|
**Example** **Example**
``` ```js
var calendar = i18n.getCalendar("en-US", "buddhist"); var calendar = i18n.getCalendar("en-US", "buddhist");
calendar.getDisplayName("zh"); // Obtain the name of the Buddhist calendar in zh. calendar.getDisplayName("zh"); // Obtain the name of the Buddhist calendar in zh.
``` ```
...@@ -592,7 +592,7 @@ Checks whether the specified date in this **Calendar** object is a weekend. ...@@ -592,7 +592,7 @@ Checks whether the specified date in this **Calendar** object is a weekend.
| boolean | Returns **true** if the date is a weekend; returns **false** if the date is a weekday.| | boolean | Returns **true** if the date is a weekend; returns **false** if the date is a weekday.|
**Example** **Example**
``` ```js
var calendar = i18n.getCalendar("zh-Hans"); var calendar = i18n.getCalendar("zh-Hans");
calendar.set(2021, 11, 11, 8, 0, 0); // set time to 2021.11.11 08:00:00 calendar.set(2021, 11, 11, 8, 0, 0); // set time to 2021.11.11 08:00:00
calendar.isWeekend(); // false calendar.isWeekend(); // false
...@@ -619,7 +619,7 @@ Parameters ...@@ -619,7 +619,7 @@ Parameters
| options | [PhoneNumberFormatOptions](#phonenumberformatoptions8) | No | Options of the **PhoneNumberFormat** object. | | options | [PhoneNumberFormatOptions](#phonenumberformatoptions8) | No | Options of the **PhoneNumberFormat** object. |
**Example** **Example**
``` ```js
var phoneNumberFormat= new i18n.PhoneNumberFormat("CN", {"type": "E164"}); var phoneNumberFormat= new i18n.PhoneNumberFormat("CN", {"type": "E164"});
``` ```
...@@ -643,7 +643,7 @@ Checks whether the format of the specified phone number is valid. ...@@ -643,7 +643,7 @@ Checks whether the format of the specified phone number is valid.
| boolean | Returns **true** if the phone number format is valid; returns **false** otherwise.| | boolean | Returns **true** if the phone number format is valid; returns **false** otherwise.|
**Example** **Example**
``` ```js
var phonenumberfmt = new i18n.PhoneNumberFormat("CN"); var phonenumberfmt = new i18n.PhoneNumberFormat("CN");
phonenumberfmt.isValidNumber("15812312312"); phonenumberfmt.isValidNumber("15812312312");
``` ```
...@@ -668,9 +668,9 @@ Formats a phone number. ...@@ -668,9 +668,9 @@ Formats a phone number.
| string | Formatted phone number.| | string | Formatted phone number.|
**Example** **Example**
``` ```js
var phonenumberfmt = new i18n.PhoneNumberFormat("CN"); var phonenumberfmt = new i18n.PhoneNumberFormat("CN");
phonenumberfmt.format("15812312312"); phonenumberfmt.isValidNumber("15812312312");
``` ```
### getLocationName<sup>8+</sup> ### getLocationName<sup>8+</sup>
...@@ -693,11 +693,10 @@ Obtains the home location of a phone number. ...@@ -693,11 +693,10 @@ Obtains the home location of a phone number.
| string | Home location of the phone number.| | string | Home location of the phone number.|
**Example** **Example**
```js
var phonenumberfmt = new i18n.PhoneNumberFormat("CN");
phonenumberfmt.isValidNumber("15812312312");
``` ```
var location = i18n.PhoneNumberFormat.getLocationName('15812312345', 'zh-CN');
```
## PhoneNumberFormatOptions<sup>8+</sup> ## PhoneNumberFormatOptions<sup>8+</sup>
...@@ -749,7 +748,7 @@ Converts one measurement unit into another and formats the unit based on the spe ...@@ -749,7 +748,7 @@ Converts one measurement unit into another and formats the unit based on the spe
| string | Character string obtained after formatting based on the measurement unit specified by **toUnit**.| | string | Character string obtained after formatting based on the measurement unit specified by **toUnit**.|
**Example** **Example**
``` ```js
i18n.Util.unitConvert({unit: "cup", measureSystem: "US"}, {unit: "liter", measureSystem: "SI"}, 1000, "en-US", "long"); i18n.Util.unitConvert({unit: "cup", measureSystem: "US"}, {unit: "liter", measureSystem: "SI"}, 1000, "en-US", "long");
``` ```
...@@ -773,7 +772,7 @@ Creates an **IndexUtil** object. ...@@ -773,7 +772,7 @@ Creates an **IndexUtil** object.
| [IndexUtil](#indexutil8) | **IndexUtil** object mapping to the specified locale.| | [IndexUtil](#indexutil8) | **IndexUtil** object mapping to the specified locale.|
**Example** **Example**
``` ```js
var indexUtil= i18n.getInstance("zh-CN"); var indexUtil= i18n.getInstance("zh-CN");
``` ```
...@@ -795,7 +794,7 @@ Obtains the index list for this **locale** object. ...@@ -795,7 +794,7 @@ Obtains the index list for this **locale** object.
| Array&lt;string&gt; | Index list for this **locale** object.| | Array&lt;string&gt; | Index list for this **locale** object.|
**Example** **Example**
``` ```js
var indexUtil = i18n.getInstance("zh-CN"); var indexUtil = i18n.getInstance("zh-CN");
var indexList = indexUtil.getIndexList(); var indexList = indexUtil.getIndexList();
``` ```
...@@ -815,7 +814,7 @@ Adds the index of the new **locale** object to the index list. ...@@ -815,7 +814,7 @@ Adds the index of the new **locale** object to the index list.
| locale | string | Yes | A string containing locale information, including the language, optional script, and region.| | locale | string | Yes | A string containing locale information, including the language, optional script, and region.|
**Example** **Example**
``` ```js
var indexUtil = i18n.getInstance("zh-CN"); var indexUtil = i18n.getInstance("zh-CN");
indexUtil.addLocale("en-US"); indexUtil.addLocale("en-US");
``` ```
...@@ -840,7 +839,7 @@ Obtains the index of a text object. ...@@ -840,7 +839,7 @@ Obtains the index of a text object.
| string | Index of the **text** object.| | string | Index of the **text** object.|
**Example** **Example**
``` ```js
var indexUtil= i18n.getInstance("zh-CN"); var indexUtil= i18n.getInstance("zh-CN");
indexUtil.getIndex("hi"); // Return h. indexUtil.getIndex("hi"); // Return h.
``` ```
...@@ -868,7 +867,7 @@ Checks whether the input character string is composed of digits. ...@@ -868,7 +867,7 @@ Checks whether the input character string is composed of digits.
| boolean | Returns **true** if the input character is a digit; returns **false** otherwise.| | boolean | Returns **true** if the input character is a digit; returns **false** otherwise.|
**Example** **Example**
``` ```js
var isdigit = i18n.Character.isDigit("1"); // Return true. var isdigit = i18n.Character.isDigit("1"); // Return true.
``` ```
...@@ -892,7 +891,7 @@ Checks whether the input character is a space. ...@@ -892,7 +891,7 @@ Checks whether the input character is a space.
| boolean | Returns **true** if the input character is a space; returns **false** otherwise.| | boolean | Returns **true** if the input character is a space; returns **false** otherwise.|
**Example** **Example**
``` ```js
var isspacechar = i18n.Character.isSpaceChar("a"); // Return false. var isspacechar = i18n.Character.isSpaceChar("a"); // Return false.
``` ```
...@@ -916,7 +915,7 @@ Checks whether the input character is a white space. ...@@ -916,7 +915,7 @@ Checks whether the input character is a white space.
| boolean | Returns **true** if the input character is a white space; returns **false** otherwise.| | boolean | Returns **true** if the input character is a white space; returns **false** otherwise.|
**Example** **Example**
``` ```js
var isspacechar = i18n.Character.isSpaceChar("a"); // Return false. var isspacechar = i18n.Character.isSpaceChar("a"); // Return false.
``` ```
...@@ -940,7 +939,7 @@ Checks whether the input character is of the right to left (RTL) language. ...@@ -940,7 +939,7 @@ Checks whether the input character is of the right to left (RTL) language.
| boolean | Returns **true** if the input character is of the RTL language; returns **false** otherwise.| | boolean | Returns **true** if the input character is of the RTL language; returns **false** otherwise.|
**Example** **Example**
``` ```js
var isrtl = i18n.Character.isRTL("a"); // Return false. var isrtl = i18n.Character.isRTL("a"); // Return false.
``` ```
...@@ -964,7 +963,7 @@ Checks whether the input character is an ideographic character. ...@@ -964,7 +963,7 @@ Checks whether the input character is an ideographic character.
| boolean | Returns **true** if the input character is an ideographic character; returns **false** otherwise.| | boolean | Returns **true** if the input character is an ideographic character; returns **false** otherwise.|
**Example** **Example**
``` ```js
var isideograph = i18n.Character.isIdeograph("a"); // Return false. var isideograph = i18n.Character.isIdeograph("a"); // Return false.
``` ```
...@@ -988,7 +987,7 @@ Checks whether the input character is a letter. ...@@ -988,7 +987,7 @@ Checks whether the input character is a letter.
| boolean | Returns **true** if the input character is a letter; returns **false** otherwise.| | boolean | Returns **true** if the input character is a letter; returns **false** otherwise.|
**Example** **Example**
``` ```js
var isletter = i18n.Character.isLetter("a"); // Return true. var isletter = i18n.Character.isLetter("a"); // Return true.
``` ```
...@@ -1012,7 +1011,7 @@ Checks whether the input character is a lowercase letter. ...@@ -1012,7 +1011,7 @@ Checks whether the input character is a lowercase letter.
| boolean | Returns **true** if the input character is a lowercase letter; returns **false** otherwise.| | boolean | Returns **true** if the input character is a lowercase letter; returns **false** otherwise.|
**Example** **Example**
``` ```js
var islowercase = i18n.Character.isLowerCase("a"); // Return true. var islowercase = i18n.Character.isLowerCase("a"); // Return true.
``` ```
...@@ -1036,7 +1035,7 @@ Checks whether the input character is an uppercase letter. ...@@ -1036,7 +1035,7 @@ Checks whether the input character is an uppercase letter.
| boolean | Returns **true** if the input character is an uppercase letter; returns **false** otherwise.| | boolean | Returns **true** if the input character is an uppercase letter; returns **false** otherwise.|
**Example** **Example**
``` ```js
var isuppercase = i18n.Character.isUpperCase("a"); // Return false. var isuppercase = i18n.Character.isUpperCase("a"); // Return false.
``` ```
...@@ -1060,7 +1059,7 @@ Obtains the type of the input character string. ...@@ -1060,7 +1059,7 @@ Obtains the type of the input character string.
| string | Type of the input character.| | string | Type of the input character.|
**Example** **Example**
``` ```js
var type = i18n.Character.getType("a"); var type = i18n.Character.getType("a");
``` ```
...@@ -1084,7 +1083,7 @@ Obtains a [BreakIterator](#breakiterator8) object for text segmentation. ...@@ -1084,7 +1083,7 @@ Obtains a [BreakIterator](#breakiterator8) object for text segmentation.
| [BreakIterator](#breakiterator8) | [BreakIterator](#breakiterator8) object used for text segmentation.| | [BreakIterator](#breakiterator8) | [BreakIterator](#breakiterator8) object used for text segmentation.|
**Example** **Example**
``` ```js
var iterator = i18n.getLineInstance("en"); var iterator = i18n.getLineInstance("en");
``` ```
...@@ -1106,7 +1105,7 @@ Sets the text to be processed by the [BreakIterator](#breakiterator8) object. ...@@ -1106,7 +1105,7 @@ Sets the text to be processed by the [BreakIterator](#breakiterator8) object.
| text | string | Yes | Text to be processed by the **BreakIterator** object.| | text | string | Yes | Text to be processed by the **BreakIterator** object.|
**Example** **Example**
``` ```js
var iterator = i18n.getLineInstance("en"); var iterator = i18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit."); iterator.setLineBreakText("Apple is my favorite fruit.");
``` ```
...@@ -1126,7 +1125,7 @@ Obtains the text being processed by the [BreakIterator](#breakiterator8) object. ...@@ -1126,7 +1125,7 @@ Obtains the text being processed by the [BreakIterator](#breakiterator8) object.
| string | Text being processed by the **BreakIterator** object.| | string | Text being processed by the **BreakIterator** object.|
**Example** **Example**
``` ```js
var iterator = i18n.getLineInstance("en"); var iterator = i18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit."); iterator.setLineBreakText("Apple is my favorite fruit.");
iterator.getLineBreakText(); // Apple is my favorite fruit. iterator.getLineBreakText(); // Apple is my favorite fruit.
...@@ -1147,7 +1146,7 @@ Obtains the position of the [BreakIterator](#breakiterator8) object in the text ...@@ -1147,7 +1146,7 @@ Obtains the position of the [BreakIterator](#breakiterator8) object in the text
| number | Position of the **BreakIterator** object in the text being processed.| | number | Position of the **BreakIterator** object in the text being processed.|
**Example** **Example**
``` ```js
var iterator = i18n.getLineInstance("en"); var iterator = i18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit."); iterator.setLineBreakText("Apple is my favorite fruit.");
iterator.current(); // 0 iterator.current(); // 0
...@@ -1168,7 +1167,7 @@ Puts the [BreakIterator](#breakiterator8) object to the first text boundary, whi ...@@ -1168,7 +1167,7 @@ Puts the [BreakIterator](#breakiterator8) object to the first text boundary, whi
| number | Offset to the first text boundary of the processed text.| | number | Offset to the first text boundary of the processed text.|
**Example** **Example**
``` ```js
var iterator = i18n.getLineInstance("en"); var iterator = i18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit."); iterator.setLineBreakText("Apple is my favorite fruit.");
iterator.first(); // 0 iterator.first(); // 0
...@@ -1189,7 +1188,7 @@ Puts the [BreakIterator](#breakiterator8) object to the last text boundary, whic ...@@ -1189,7 +1188,7 @@ Puts the [BreakIterator](#breakiterator8) object to the last text boundary, whic
| number | Offset of the last text boundary of the processed text.| | number | Offset of the last text boundary of the processed text.|
**Example** **Example**
``` ```js
var iterator = i18n.getLineInstance("en"); var iterator = i18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit."); iterator.setLineBreakText("Apple is my favorite fruit.");
iterator.last(); // 27 iterator.last(); // 27
...@@ -1215,7 +1214,7 @@ Moves the [BreakIterator](#breakiterator8) object backward by the specified numb ...@@ -1215,7 +1214,7 @@ Moves the [BreakIterator](#breakiterator8) object backward by the specified numb
| 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.| | 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** **Example**
``` ```js
var iterator = i18n.getLineInstance("en"); var iterator = i18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit."); iterator.setLineBreakText("Apple is my favorite fruit.");
iterator.first(); // 0 iterator.first(); // 0
...@@ -1238,7 +1237,7 @@ Moves the [BreakIterator](#breakiterator8) object to the previous text boundary. ...@@ -1238,7 +1237,7 @@ 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.| | 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.|
**Example** **Example**
``` ```js
var iterator = i18n.getLineInstance("en"); var iterator = i18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit."); iterator.setLineBreakText("Apple is my favorite fruit.");
iterator.first(); // 0 iterator.first(); // 0
...@@ -1266,7 +1265,7 @@ Moves the [BreakIterator](#breakiterator8) object to the text boundary after the ...@@ -1266,7 +1265,7 @@ Moves the [BreakIterator](#breakiterator8) object to the text boundary after the
| number | The value **-1** is returned if the text boundary to which the [BreakIterator](#breakiterator8) object is moved is outside of the processed text.| | 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** **Example**
``` ```js
var iterator = i18n.getLineInstance("en"); var iterator = i18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit."); iterator.setLineBreakText("Apple is my favorite fruit.");
iterator.following(0); // 6 iterator.following(0); // 6
...@@ -1294,7 +1293,7 @@ Checks whether the position specified by the offset is a text boundary. If **tru ...@@ -1294,7 +1293,7 @@ Checks whether the position specified by the offset is a text boundary. If **tru
| boolean | Returns **true** if the position specified by the offset is a text boundary; returns **false** otherwise.| | boolean | Returns **true** if the position specified by the offset is a text boundary; returns **false** otherwise.|
**Example** **Example**
``` ```js
var iterator = i18n.getLineInstance("en"); var iterator = i18n.getLineInstance("en");
iterator.setLineBreakText("Apple is my favorite fruit."); iterator.setLineBreakText("Apple is my favorite fruit.");
iterator.isBoundary(0); // true; iterator.isBoundary(0); // true;
...@@ -1316,7 +1315,7 @@ Checks whether the 24-hour clock is used. ...@@ -1316,7 +1315,7 @@ Checks whether the 24-hour clock is used.
| boolean | Returns **true** if the 24-hour clock is used; returns **false** otherwise.| | boolean | Returns **true** if the 24-hour clock is used; returns **false** otherwise.|
**Example** **Example**
``` ```js
var is24HourClock = i18n.is24HourClock(); var is24HourClock = i18n.is24HourClock();
``` ```
...@@ -1342,7 +1341,7 @@ Sets the 24-hour clock. ...@@ -1342,7 +1341,7 @@ Sets the 24-hour clock.
| boolean | Returns **true** if the 24-hour clock is enabled; returns **false** otherwise.| | boolean | Returns **true** if the 24-hour clock is enabled; returns **false** otherwise.|
**Example** **Example**
``` ```js
// Set the system time to the 24-hour clock. // Set the system time to the 24-hour clock.
var success = i18n.set24HourClock(true); var success = i18n.set24HourClock(true);
``` ```
...@@ -1370,7 +1369,7 @@ Adds a preferred language to the specified position on the preferred language li ...@@ -1370,7 +1369,7 @@ Adds a preferred language to the specified position on the preferred language li
| boolean | Returns **true** if the preferred language is successfully added; returns **false** otherwise.| | boolean | Returns **true** if the preferred language is successfully added; returns **false** otherwise.|
**Example** **Example**
``` ```js
// Add zh-CN to the preferred language list. // Add zh-CN to the preferred language list.
var language = 'zh-CN'; var language = 'zh-CN';
var index = 0; var index = 0;
...@@ -1399,7 +1398,7 @@ Deletes a preferred language from the specified position on the preferred langua ...@@ -1399,7 +1398,7 @@ Deletes a preferred language from the specified position on the preferred langua
| boolean | Returns **true** if the preferred language is deleted; returns **false** otherwise.| | boolean | Returns **true** if the preferred language is deleted; returns **false** otherwise.|
**Example** **Example**
``` ```js
// Delete the first preferred language from the preferred language list. // Delete the first preferred language from the preferred language list.
var index = 0; var index = 0;
var success = i18n.removePreferredLanguage(index); var success = i18n.removePreferredLanguage(index);
...@@ -1420,7 +1419,7 @@ Obtains the list of preferred languages. ...@@ -1420,7 +1419,7 @@ Obtains the list of preferred languages.
| Array&lt;string&gt; | List of preferred languages.| | Array&lt;string&gt; | List of preferred languages.|
**Example** **Example**
``` ```js
var preferredLanguageList = i18n.getPreferredLanguageList(); var preferredLanguageList = i18n.getPreferredLanguageList();
``` ```
...@@ -1439,7 +1438,7 @@ Obtains the first language in the preferred language list. ...@@ -1439,7 +1438,7 @@ Obtains the first language in the preferred language list.
| string | First language in the preferred language list.| | string | First language in the preferred language list.|
**Example** **Example**
``` ```js
var firstPreferredLanguage = i18n.getFirstPreferredLanguage(); var firstPreferredLanguage = i18n.getFirstPreferredLanguage();
``` ```
...@@ -1458,7 +1457,7 @@ Obtains the preferred language of an application. ...@@ -1458,7 +1457,7 @@ Obtains the preferred language of an application.
| string | Preferred language of the application.| | string | Preferred language of the application.|
**Example** **Example**
``` ```js
var appPreferredLanguage = i18n.getAppPreferredLanguage(); var appPreferredLanguage = i18n.getAppPreferredLanguage();
``` ```
...@@ -1482,7 +1481,7 @@ Obtains the **TimeZone** object corresponding to the specified time zone ID. ...@@ -1482,7 +1481,7 @@ Obtains the **TimeZone** object corresponding to the specified time zone ID.
| TimeZone | **TimeZone** object corresponding to the time zone ID.| | TimeZone | **TimeZone** object corresponding to the time zone ID.|
**Example** **Example**
``` ```js
var timezone = i18n.getTimeZone(); var timezone = i18n.getTimeZone();
``` ```
...@@ -1504,7 +1503,7 @@ Obtains the ID of the specified **TimeZone** object. ...@@ -1504,7 +1503,7 @@ Obtains the ID of the specified **TimeZone** object.
| string | Time zone ID corresponding to the **TimeZone** object.| | string | Time zone ID corresponding to the **TimeZone** object.|
**Example** **Example**
``` ```js
var timezone = i18n.getTimeZone(); var timezone = i18n.getTimeZone();
timezone.getID(); timezone.getID();
``` ```
...@@ -1530,7 +1529,7 @@ Obtains the representation of a **TimeZone** object in the specified locale. ...@@ -1530,7 +1529,7 @@ Obtains the representation of a **TimeZone** object in the specified locale.
| string | Representation of the **TimeZone** object in the specified locale.| | string | Representation of the **TimeZone** object in the specified locale.|
**Example** **Example**
``` ```js
var timezone = i18n.getTimeZone(); var timezone = i18n.getTimeZone();
timezone.getDisplayName("zh-CN", false); timezone.getDisplayName("zh-CN", false);
``` ```
...@@ -1550,7 +1549,7 @@ Obtains the offset between the time zone represented by a **TimeZone** object an ...@@ -1550,7 +1549,7 @@ Obtains the offset between the time zone represented by a **TimeZone** object an
| number | Offset between the time zone represented by the **TimeZone** object and the UTC time zone.| | number | Offset between the time zone represented by the **TimeZone** object and the UTC time zone.|
**Example** **Example**
``` ```js
var timezone = i18n.getTimeZone(); var timezone = i18n.getTimeZone();
timezone.getRawOffset(); timezone.getRawOffset();
``` ```
...@@ -1570,7 +1569,7 @@ Obtains the offset between the time zone represented by a **TimeZone** object an ...@@ -1570,7 +1569,7 @@ Obtains the offset between the time zone represented by a **TimeZone** object an
| number | Offset between the time zone represented by the **TimeZone** object and the UTC time zone at a certain time point.| | number | Offset between the time zone represented by the **TimeZone** object and the UTC time zone at a certain time point.|
**Example** **Example**
``` ```js
var timezone = i18n.getTimeZone(); var timezone = i18n.getTimeZone();
timezone.getOffset(1234567890); timezone.getOffset(1234567890);
``` ```
...@@ -1589,7 +1588,7 @@ Obtains the list of time zone IDs supported by the system. ...@@ -1589,7 +1588,7 @@ Obtains the list of time zone IDs supported by the system.
| Array&lt;string&gt; | List of time zone IDs supported by the system.| | Array&lt;string&gt; | List of time zone IDs supported by the system.|
**Example** **Example**
``` ```js
var ids = i18n.TimeZone.getAvailableIDs(); var ids = i18n.TimeZone.getAvailableIDs();
``` ```
...@@ -1608,7 +1607,7 @@ Obtains the list of time zone city IDs supported by the system. ...@@ -1608,7 +1607,7 @@ Obtains the list of time zone city IDs supported by the system.
| Array&lt;string&gt; | List of time zone city IDs supported by the system.| | Array&lt;string&gt; | List of time zone city IDs supported by the system.|
**Example** **Example**
``` ```js
var cityIDs = i18n.TimeZone.getAvailableZoneCityIDs(); var cityIDs = i18n.TimeZone.getAvailableZoneCityIDs();
``` ```
...@@ -1633,7 +1632,7 @@ Obtains the localized display of a time zone city in the specified locale. ...@@ -1633,7 +1632,7 @@ Obtains the localized display of a time zone city in the specified locale.
| string | Localized display of the time zone city in the specified locale.| | string | Localized display of the time zone city in the specified locale.|
**Example** **Example**
``` ```js
var displayName = i18n.TimeZone.getCityDisplayName("Shanghai", "zh-CN"); var displayName = i18n.TimeZone.getCityDisplayName("Shanghai", "zh-CN");
``` ```
...@@ -1657,7 +1656,7 @@ Obtains the **TimeZone** object corresponding to the specified time zone city ID ...@@ -1657,7 +1656,7 @@ Obtains the **TimeZone** object corresponding to the specified time zone city ID
| TimeZone | **TimeZone** object corresponding to the specified time zone city ID.| | TimeZone | **TimeZone** object corresponding to the specified time zone city ID.|
**Example** **Example**
``` ```js
var timezone = i18n.TimeZone.getTimezoneFromCity("Shanghai"); var timezone = i18n.TimeZone.getTimezoneFromCity("Shanghai");
``` ```
...@@ -1684,7 +1683,7 @@ This is a system API. ...@@ -1684,7 +1683,7 @@ This is a system API.
| boolean | Result indicating whether the local digit switch is successfully set. The value **true** indicates that the local digit switch is successfully set, and the value **false** indicates the opposite.| | boolean | Result indicating whether the local digit switch is successfully set. The value **true** indicates that the local digit switch is successfully set, and the value **false** indicates the opposite.|
**Example** **Example**
``` ```js
var status = i18n.setUsingLocalDigit(true); var status = i18n.setUsingLocalDigit(true);
``` ```
...@@ -1703,6 +1702,6 @@ Checks whether the local digit switch is turned on. ...@@ -1703,6 +1702,6 @@ Checks whether the local digit switch is turned on.
| boolean | Result indicating whether the local digit switch is turned on. The value **true** indicates that the local digit switch is turned on, and the value **false** indicates the opposite.| | boolean | Result indicating whether the local digit switch is turned on. The value **true** indicates that the local digit switch is turned on, and the value **false** indicates the opposite.|
**Example** **Example**
``` ```js
var status = i18n.getUsingLocalDigit(); var status = i18n.getUsingLocalDigit();
``` ```
...@@ -536,7 +536,7 @@ Parameters ...@@ -536,7 +536,7 @@ Parameters
**Example** **Example**
``` ```
var pluralRules= new Intl.PluraRules("zh-CN", {"localeMatcher": "lookup", "type": "cardinal"}); var pluralRules= new Intl.PluralRules("zh-CN", {"localeMatcher": "lookup", "type": "cardinal"});
``` ```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册