@@ -6,7 +6,7 @@ The [intl](intl-guidelines.md) module provides basic i18n capabilities through t
## Obtaining and Setting i18n Information
The system provides APIs to configure information such as the system language, preferred language, country or region, 24-hour clock, and local digit switch.
The following table lists the APIs used to configure information such as the system language, preferred language, country or region, 24-hour clock, and use of local digits.
### Available APIs
...
...
@@ -30,15 +30,15 @@ The system provides APIs to configure information such as the system language, p
| System | getPreferredLanguageList()<sup>9+</sup> | Obtains the preferred language list. |
| System | getFirstPreferredLanguage()<sup>9+</sup> | Obtains the first language in the preferred language list. |
| System | getAppPreferredLanguage()<sup>9+</sup> | Obtains the preferred language of an application. |
| System | setUsingLocalDigit(flag: boolean)<sup>9+</sup> | Sets whether to enable the local digit switch. |
| System | getUsingLocalDigit()<sup>9+</sup> | Checks whether the local digit switch is turned on. |
| System | setUsingLocalDigit(flag: boolean)<sup>9+</sup> | Specifies whether to enable use of local digits. |
| System | getUsingLocalDigit()<sup>9+</sup> | Checks whether use of local digits is enabled. |
| | isRTL(locale:string):boolean<sup>9+</sup> | Checks whether the locale uses a right-to-left (RTL) language.|
### How to Develop
1. Import the **i18n** module.
```js
importI18nfrom'@ohos.i18n'
importI18nfrom'@ohos.i18n';
```
2. Obtain and set the system language.
...
...
@@ -51,7 +51,7 @@ The system provides APIs to configure information such as the system language, p
I18n.System.setSystemLanguage("en");// Set the system language to en.
letlanguage=I18n.System.getSystemLanguage();// language = "en"
letappPreferredLanguage=I18n.System.getAppPreferredLanguage();// Set the preferred language of the application to en-GB if the application contains en-GB resources.
@@ -190,14 +190,14 @@ The system provides APIs to configure information such as the system language, p
Call **setUsingLocalDigit** to enable the local digit switch. (This is a system API and can be called only by system applications with the UPDATE_CONFIGURATION permission.)
Call **getUsingLocalDigit** to check whether the local digit switch is enabled.
Currently, the local digit switch applies only to the following languages: "ar", "as", "bn", "fa", "mr", "my", "ne", and "ur".
Currently, use of local digits is supported only for the following languages: **ar**, **as**, **bn**, **fa**, **mr**, **my**, **ne**, **ur**.
```js
try{
I18n.System.setUsingLocalDigit(true);// Enable the local digit switch.
letstatus=I18n.System.getUsingLocalDigit();// status = true
The **i18n** module provides system-related or enhanced i18n capabilities, such as locale management, phone number formatting, and calendar, through supplementary i18n APIs that are not defined in ECMA 402.
The **i18n** module provides system-related or enhanced i18n capabilities, such as locale management, phone number formatting, and calendar, through supplementary i18n APIs that are not defined in ECMA 402.
The [intl](js-apis-intl.md) module provides basic i18n capabilities through the standard i18n APIs defined in ECMA 402. It works with the i18n module to provide a complete suite of i18n capabilities.
> **NOTE**
...
...
@@ -53,7 +53,7 @@ For details about the error codes, see [i18n Error Codes](../errorcodes/errorcod
@@ -100,7 +100,7 @@ For details about the error codes, see [i18n Error Codes](../errorcodes/errorcod
static getSystemLanguages(): Array<string>
Obtains the list of system languages.
Obtains the list of system languages. For details about languages, see [Instantiating the Locale Object](../../internationalization/intl-guidelines.md#how-to-develop).
Obtains the list of countries and regions supported for the specified language.
Obtains the list of countries and regions supported for the specified language. For details about countries or regions, see [Instantiating the Locale Object](../../internationalization/intl-guidelines.md#how-to-develop).
@@ -160,7 +160,7 @@ For details about the error codes, see [i18n Error Codes](../errorcodes/errorcod
try{
letsystemCountries=I18n.System.getSystemCountries('zh');// systemCountries = [ "ZW", "YT", "YE", ..., "ER", "CN", "DE" ], 240 countries or regions in total
@@ -206,7 +206,7 @@ For details about the error codes, see [i18n Error Codes](../errorcodes/errorcod
static getSystemLanguage(): string
Obtains the system language.
Obtains the system language. For details about languages, see [Instantiating the Locale Object](../../internationalization/intl-guidelines.md#how-to-develop).
@@ -272,7 +272,7 @@ For details about the error codes, see [i18n Error Codes](../errorcodes/errorcod
static getSystemRegion(): string
Obtains the system region.
Obtains the system region. For details about system regions, see [Instantiating the Locale Object](../../internationalization/intl-guidelines.md#how-to-develop).
@@ -338,7 +338,7 @@ For details about the error codes, see [i18n Error Codes](../errorcodes/errorcod
static getSystemLocale(): string
Obtains the system locale.
Obtains the system locale. For details about system locales, see [Instantiating the Locale Object](../../internationalization/intl-guidelines.md#how-to-develop).
| 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.|
| date | Date | No | Specified date in this **Calendar** object. If the **date** parameter is not specified, the system checks whether the current date is a weekend.|
The **intl** module provides basic i18n capabilities, such as time and date formatting, number formatting, and string sorting, through the standard i18n APIs defined in ECMA 402.
The **intl** module provides basic i18n capabilities, such as time and date formatting, number formatting, and string sorting, through the standard i18n APIs defined in ECMA 402.
The [i18n](js-apis-i18n.md) module provides enhanced i18n capabilities through supplementary interfaces that are not defined in ECMA 402. It works with the intl module to provide a complete suite of i18n capabilities.
> **NOTE**
...
...
@@ -48,9 +48,9 @@ Creates a **Locale** object.
**Example**
```js
// The default constructor uses the current system locale to create a Locale object.
@@ -15,8 +15,8 @@ import resourceManager from '@ohos.resourceManager';
## Instruction
Since API version 9, the stage model allows an application to obtain a **ResourceManager** object based on **context** and call its resource management APIs without first importing the required bundle. This approach, however, is not applicable to the FA model.
For details about how to reference **context** in the stage model, see [Context in the Stage Model](../../application-models/application-context-stage.md).
Since API version 9, the stage model allows an application to obtain a **ResourceManager** object based on **context** and call its resource management APIs without first importing the required bundle. This approach, however, is not applicable to the FA model. For the FA model, you need to import the required bundle and then call the [getResourceManager](#resourcemanagergetresourcemanager) API to obtain a **ResourceManager** object.
For details about how to reference context in the stage model, see [Context in the Stage Model](../..//application-models/application-context-stage.md).
```ts
importAbilityfrom'@ohos.application.Ability';
...
...
@@ -60,6 +60,7 @@ Obtains the **ResourceManager** object of this application. This API uses an asy
});
});
```
> **NOTE**<br>In the sample code, **0x1000000** indicates the resource ID, which can be found in the compiled **ResourceTable.txt** file.
## resourceManager.getResourceManager
...
...
@@ -116,6 +117,7 @@ Obtains the **ResourceManager** object of this application. This API uses a prom
console.log("error is "+error);
});
```
> **NOTE**<br>In the sample code, **0x1000000** indicates the resource ID, which can be found in the compiled **ResourceTable.txt** file.
## resourceManager.getResourceManager
...
...
@@ -1767,7 +1769,7 @@ For details about the error codes, see [Resource Manager Error Codes](../errorco
@@ -30,18 +30,18 @@ Understanding the following concepts would be helpful for you in configuring HiS
| Field| Description|
| ----- | ----- |
| type | Indicates the type of the event. This field is mandatory.<br><br>Value:<ul><li>**FAULT**: fault </li><li>**STATISTIC**: statistics </li><li>**SECURITY**: security </li><li>**BEHAVIOR**: user behavior</li></ul> |
| level | Indicates the level of the event. This field is mandatory.<br><br>Value: <ul><li>**CRITICAL**: critical </li><li>**MINOR**: minor</li></ul> |
| tag | Indicates the tag of the event. This field is mandatory.<br><br>Rule:<ul><li>You can define a maximum of five tags separated with a space. </li><li>A single tag can contain a maximum of 16 characters, including a to z, A to Z, and 0 to 9.</li></ul>|
| desc | Describes the event name. This field is mandatory.<br><br>Rule:<ul><li>The description contains 3 to 128 characters, including a to z, A to Z, 0 to 9, and underscores (_).</li></ul>|
| type | Indicates the type of the event. This field is mandatory.<br/>Value:<br/>- **FAULT**: fault<br/>- **STATISTIC**: statistics<br/>- **SECURITY**: security<br/>- **BEHAVIOR**: user behavior |
| level | Indicates the level of the event. This field is mandatory.<br/>Value:<br/>- **CRITICAL**: critical<br/>- **MINOR**: minor |
| tag | Indicates the tag of the event. This field is mandatory.<br/>Rule:<br/>- You can define a maximum of five tags separated with a space.<br/>- A single tag can contain a maximum of 16 characters, including a to z, A to Z, and 0 to 9. |
| desc | Describes the event name. This field is mandatory.<br/>Rule:<br/>The description contains 3 to 128 characters, including a to z, A to Z, 0 to 9, and underscores (_).|
**Table 2** Description of custom parameters
| Field| Description|
| ----- | ----- |
| type | Indicates the type of a parameter. This field is mandatory.<br><br>Value: <ul><li>BOOL</li><li>UINT8</li><li>UINT16</li><li>INT32</li><li>UINT32</li><li>UINT64</li><li>FLOAT</li><li>DOUBLE</li><li>STRING</li></ul>|
| arrsize | Specifies the length of the parameter of the array type. This field is optional.<br><br>Value range: <ul><li>1-100</li></ul>|
| desc | Describes the parameter. This field is mandatory.<br><br>Rule:<ul><li>The description contains 3 to 128 characters, including a to z, A to Z, 0 to 9, and underscores (_).</li></ul>|
| type | Indicates the type of a parameter. This field is mandatory.<br/>Value:<br/>- BOOL<br/>- INT8<br/>- UINT8<br/>- INT16<br/>- UINT16<br/>- INT32<br/>- UINT32<br/>- INT64<br/>- UINT64<br/>- FLOAT<br/>- DOUBLE<br/>- STRING |
| arrsize | Specifies the length of the parameter of the array type. This field is optional.<br/>Value range:<br/>1-100 |
| desc | Describes the parameter. This field is mandatory.<br/>Rule:<br/>The description contains 3 to 128 characters, including a to z, A to Z, 0 to 9, and underscores (_). |
## Writing a YAML File<a name="section123181432175113"></a>