You need to sign in or sign up before continuing.
js-apis-system-configuration.md 1.9 KB
Newer Older
Z
zengyawen 已提交
1 2
# Application Configuration

S
shawn_he 已提交
3
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
Z
zengyawen 已提交
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
> - The APIs of this module are no longer maintained since API version 7. It is recommended that you use [`@ohos.i18n`](js-apis-i18n.md) and [`@ohos.intl`](js-apis-intl.md) instead.
>
> 
> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.


## Modules to Import


```
import configuration from '@system.configuration';
```


## configuration.getLocale

S
shawn_he 已提交
20
getLocale(): LocaleResponse
Z
zengyawen 已提交
21 22 23 24 25 26 27

Obtains the current locale of the application, which is the same as the system locale.

**System capability**: SystemCapability.ArkUI.ArkUI.Lite

**Return values**

S
shawn_he 已提交
28 29 30
| Type | Description |
| -------- | -------- |
| LocaleResponse | Information about the current locale. |
Z
zengyawen 已提交
31 32 33

**Example**

S
shawn_he 已提交
34 35 36 37 38 39
  ```
  export default {    
    getLocale() {        
      const localeInfo = configuration.getLocale();        
      console.info(localeInfo.language);    
    }
Z
zengyawen 已提交
40
  }
S
shawn_he 已提交
41 42 43 44 45 46 47 48 49 50 51 52 53 54
```

## LocaleResponse

Defines attributes of the current locale.

**System capability**: SystemCapability.ArkUI.ArkUI.Lite

| Name  | Type  | Readable  | Writable  | Description                                      |
| ---- | ------ | ---- | ---- | ---------------------------------------- |
| language | string | Yes   | No   | Language, for example, **zh**.|
| countryOrRegion | string | Yes   | No   | Country or region, for example, **CN** or **US**.|
| dir | string | Yes   | No   | Text layout direction. The value can be:<br>- **ltr**: from left to right<br>- **rtl**: from right to left|
| unicodeSetting<sup>5+</sup> | string | Yes   | No   | Unicode language key set determined by the locale. If current locale does not have a specific key set, an empty set is returned.<br>For example, **{"nu":"arab"}** indicates that current locale uses Arabic numerals.|