国际化(I18n)
说明: 从 API Version 7 开始支持。
导入模块
import i18n from '@ohos.i18n';
权限
无
i18n.getDisplayLanguage
getDisplayLanguage(language: string, locale: string, sentenceCase?: boolean): string
获取指定语言的本地化显示文本。
-
参数:
-
返回值:
-
示例:
i18n.getDisplayLanguage("zh", "en-GB", true); i18n.getDisplayLanguage("zh", "en-GB");
i18n.getDisplayCountry
getDisplayCountry(country: string, locale: string, sentenceCase?: boolean): string
获取指定国家的本地化显示文本。
-
参数:
-
返回值:
-
示例:
i18n.getDisplayCountry("zh-CN", "en-GB", true); i18n.getDisplayCountry("zh-CN", "en-GB");
i18n.getSystemLanugage
getSystemLanguage(): string
获取系统语言。
i18n.getSystemRegion
getSystemRegion(): string
获取系统地区。
i18n.getSystemLocale
getSystemLocale(): string
获取系统区域。