过滤不支持的language

Signed-off-by: LY <liuyong235@huawei.com>
This commit is contained in:
LY 2024-09-25 19:04:55 +08:00
parent 76c9a0abb9
commit a1d74e0da2
2 changed files with 16 additions and 0 deletions

View File

@ -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;

View File

@ -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;
}