From 8c10764d616cf7cfe85c37b2207e44f6b2ec2957 Mon Sep 17 00:00:00 2001 From: king_he <6384784@qq.com> Date: Thu, 26 May 2022 02:16:27 +0000 Subject: [PATCH] update en/application-dev/internationalization/i18n-guidelines.md. Signed-off-by: king_he <6384784@qq.com> --- .../internationalization/i18n-guidelines.md | 76 +++++++++---------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/en/application-dev/internationalization/i18n-guidelines.md b/en/application-dev/internationalization/i18n-guidelines.md index 1be7b7dff8..4b1d2c4998 100644 --- a/en/application-dev/internationalization/i18n-guidelines.md +++ b/en/application-dev/internationalization/i18n-guidelines.md @@ -9,7 +9,7 @@ APIs are provided to access the system language and region information. ### Available APIs - | Module | API | Description | +| Module | API | Description | | -------- | -------- | -------- | | ohos.i18n | getSystemLanguage(): string | Obtains the system language. | | ohos.i18n | getSystemRegion(): string | Obtains the system region. | @@ -22,7 +22,7 @@ APIs are provided to access the system language and region information. ### How to Develop -1. Obtain the system language. +1. Obtain the system language.
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. var language = i18n.getSystemLanguage(); ``` -2. Obtains the system region. +2. Obtain the system region.
Call the **getSystemRegion** method to obtain the system region. ``` var region = i18n.getSystemRegion(); ``` -3. Obtain the system locale. +3. Obtain the system locale.
Call the **getSystemLocale** method to obtain the system locale. ``` var locale = i18n.getSystemLocale(); ``` -4. Check whether the locale's language is RTL. +4. Check whether the locale's language is RTL.
Call the **isRTL** method to check whether the locale's language is RTL. @@ -52,15 +52,15 @@ APIs are provided to access the system language and region information. var rtl = i18n.isRTL("zh-CN"); ``` -5. Check whether the system uses a 24-hour clock. - Call the **is24HourClock** method to check whether the system uses a 24-hour clock. +5. 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(); ``` -6. Obtain the localized display of a language. - 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. +6. Obtain the localized display of a language.
+ 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. ``` var language = "en"; @@ -69,8 +69,8 @@ APIs are provided to access the system language and region information. var localizedLanguage = i18n.getDisplayLanguage(language, locale, sentenceCase); ``` -7. Obtain the localized display of a country. - 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. +7. Obtain the localized display of a country.
+ 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. ``` var country = "US"; @@ -105,7 +105,7 @@ APIs are provided to access the system language and region information. ### How to Develop -1. Instantiate a **Calendar** object. +1. Instantiate a **Calendar** object.
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,8 +113,8 @@ APIs are provided to access the system language and region information. var calendar = i18n.getCalendar("zh-CN", "gregory); ``` -2. Set the time for the **Calendar** object. - 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. +2. Set the time for the **Calendar** object.
+ 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. ``` var date1 = new Date(); @@ -123,14 +123,14 @@ APIs are provided to access the system language and region information. calendar.setTime(date2); ``` -3. 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. +3. 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) ``` -4. Set and obtain the time zone for the **Calendar** object. +4. Set and obtain the time zone for the **Calendar** object.
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. 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.
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,15 +148,15 @@ APIs are provided to access the system language and region information. var firstDayOfWeek = calendar.getFirstDayOfWeek(); ``` -6. 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. +6. 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. ``` calendar.setMinimalDaysInFirstWeek(3); var minimalDaysInFirstWeek = calendar.getMinimalDaysInFirstWeek(); ``` -7. Obtain the localized display of the **Calendar** object. +7. 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. var localizedName = calendar.getDisplayName("zh-CN"); ``` -8. Check whether a date is a weekend. +8. Check whether a 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. ### Available APIs - | Module | API | Description | +| Module | API | Description | | -------- | -------- | -------- | | ohos.i18n | constructor(country: string, options?: PhoneNumberFormatOptions)8+ | Instantiates a **PhoneNumberFormat** object. | | ohos.i18n | isValidNumber(number: string): boolean8+ | 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. ### How to Develop -1. Instantiate a **PhoneNumberFormat** object. +1. Instantiate a **PhoneNumberFormat** object.
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**. @@ -199,14 +199,14 @@ APIs are provided to access the system language and region information. ``` 2. Check whether the phone number format is correct. - Call the **isValidNumber** method to check whether the format of the input phone number is correct. + Call the **isValidNumber** method to check whether the format of the input phone number is correct. ``` var validNumber = phoneNumberFormat.isValidNumber("15812341234"); ``` 3. Format a phone number. - Call the **format** method of **PhoneNumberFormat** to format the input phone number. + Call the **format** method of **PhoneNumberFormat** to format the input phone number. ``` var formattedNumber = phoneNumberFormat.format("15812341234"); @@ -258,7 +258,7 @@ An API can be called to implement measurement conversion. ### How to Develop -1. Instantiate an **IndexUtil** object. +1. Instantiate an **IndexUtil** object.
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,22 +266,22 @@ An API can be called to implement measurement conversion. var indexUtil = getInstance("zh-CN"); ``` -2. Obtain the index list. - Call the **getIndexList** method to obtain the alphabet index list of the current locale. +2. Obtain the index list.
+ Call the **getIndexList** method to obtain the alphabet index list of the current locale. ``` var indexList = indexUtil.getIndexList(); ``` -3. Add an index. - Call the **addLocale** method to add the alphabet index of a new locale to the current index list. +3. Add an index.
+ Call the **addLocale** method to add the alphabet index of a new locale to the current index list. ``` indexUtil.addLocale("ar") ``` -4. Obtain the index of a string. - Call the **getIndex** method to obtain the alphabet index of a string. +4. Obtain the index of a string.
+ Call the **getIndex** method to obtain the alphabet index of a string. ``` var text = "access index"; @@ -312,7 +312,7 @@ When a text is displayed in more than one line, [BreakIterator](../reference/api ### How to Develop -1. Instantiate a **BreakIterator** object. +1. 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 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.
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 var breakText = breakIterator.getLineBreakText(); ``` -3. Obtain the current position of the **BreakIterator** object. +3. Obtain the current position of the **BreakIterator** object.
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 var pos = breakIterator.current(); ``` -4. Set the position of a **BreakIterator** object. +4. Set the position of a **BreakIterator** object.
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 var followingPos = breakIterator.following(10); ``` -5. Determine whether a position is a break point. +5. Determine whether a position is a break point.
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. -- GitLab