harmony 鸿蒙Language and Locale Name Localization
Language and Locale Name Localization
Use Cases
Language and locale name localization means to localize language and locale names on the UI based on local language habits. For example, Simplified Chinese and English are used in an English environment while 简体中文 and 英文 are used in a Chinese environment.
How to Develop
For details about the APIs, see getDisplayCountry and getDisplayLanguage.
Import the i18n module.
import { i18n } from '@kit.LocalizationKit';
Localize language names. Language names can be localized into representations in different languages. The following uses German as an example:
let displayLanguage: string = i18n.System.getDisplayLanguage('de', 'zh-Hans-CN'); // displayLanguage = 'German' // language: two-letter language code, for example, zh, de, or fr. // locale: locale ID, for example, en-GB, en-US, or zh-Hans-CN. // sentenceCase: whether the first letter of the language name needs to be capitalized. The default value is true.
Localize country/region names. Country/region names can be localized into representations in different languages. The following uses Saudi Arabia as an example:
let displayCountry: string = i18n.System.getDisplayCountry('SA', 'en-GB'); // displayCountry = 'Saudi Arabia' // country: two-letter country/region code, for example, CN, DE, or SA. // locale: locale ID, for example, en-GB, en-US, or zh-Hans-CN. // sentenceCase: whether the first letter of the country/region name needs to be capitalized. The default value is true.
你可能感兴趣的鸿蒙文章
harmony 鸿蒙Character Processing
harmony 鸿蒙Overview of Internationalization and Localization
harmony 鸿蒙Locale ID and Cultural Habit Division
harmony 鸿蒙Number and Unit of Measurement Formatting
- 所属分类: 后端技术
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦