mirror of
https://gitee.com/openharmony/global_i18n
synced 2024-11-23 07:00:13 +00:00
过滤不支持的language
Signed-off-by: LY <liuyong235@huawei.com>
This commit is contained in:
parent
76c9a0abb9
commit
a1d74e0da2
@ -270,6 +270,7 @@ private:
|
||||
static std::map<std::string, std::string> supportedDialectLocales;
|
||||
static std::unordered_map<std::string, std::string> dialectMap;
|
||||
static std::unordered_map<std::string, std::string> localDigitMap;
|
||||
static std::unordered_map<std::string, std::string> convertLanguage;
|
||||
static std::map<std::string, std::string> locale2DisplayName;
|
||||
static std::map<std::string, std::string> region2DisplayName;
|
||||
static std::string currentDialectLocale;
|
||||
|
@ -129,6 +129,14 @@ unordered_map<string, string> LocaleConfig::localDigitMap {
|
||||
{ "ur", "latn" }
|
||||
};
|
||||
|
||||
unordered_map<string, string> LocaleConfig::convertLanguage {
|
||||
{ "ug", "ug" },
|
||||
{ "bo", "bo" },
|
||||
{ "en", "en-Latn-US" },
|
||||
{ "zh-Hans", "zh-Hans" },
|
||||
{ "zh-Hant", "zh-Hant" }
|
||||
};
|
||||
|
||||
std::map<std::string, std::string> LocaleConfig::supportedDialectLocales;
|
||||
std::map<string, string> LocaleConfig::locale2DisplayName {};
|
||||
std::map<string, string> LocaleConfig::region2DisplayName {};
|
||||
@ -289,6 +297,13 @@ string LocaleConfig::GetSystemLanguage()
|
||||
if (systemLanguage.empty()) {
|
||||
systemLanguage = ReadSystemParameter(DEFAULT_LANGUAGE_KEY, CONFIG_LEN);
|
||||
}
|
||||
for (auto language : convertLanguage) {
|
||||
std::string prefix = language.first;
|
||||
if (prefix.length() <= systemLanguage.length() && systemLanguage.find(prefix, 0) == 0) {
|
||||
systemLanguage = language.second;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return systemLanguage;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user