COMMON: Return updated language from obsolete code
When an obsolete language code is encountered in a user's config file, we translate this to the updated language ID.
This commit is contained in:
parent
6e1135ee8a
commit
5ef7793578
2 changed files with 17 additions and 1 deletions
|
@ -92,6 +92,16 @@ const LanguageDescription g_languages[] = {
|
|||
{ nullptr, nullptr, nullptr, UNK_LANG }
|
||||
};
|
||||
|
||||
const LanguageDescription g_obsoleteLanguages[] = {
|
||||
{ "gr", "el_GR", "Greek", EL_GRC },
|
||||
{ "hb", "he_IL", "Hebrew", HE_ISR },
|
||||
{ "jp", "ja_JP", "Japanese", JA_JPN },
|
||||
{ "kr", "ko_KR", "Korean", KO_KOR },
|
||||
{ "nz", "zh", "Chinese", ZH_ANY },
|
||||
{ "zh-cn", "zh_CN", "Chinese (Simplified)", ZH_CHN },
|
||||
{ nullptr, nullptr, nullptr, UNK_LANG }
|
||||
};
|
||||
|
||||
Language parseLanguage(const String &str) {
|
||||
if (str.empty())
|
||||
return UNK_LANG;
|
||||
|
@ -102,6 +112,12 @@ Language parseLanguage(const String &str) {
|
|||
return l->id;
|
||||
}
|
||||
|
||||
const LanguageDescription *ol = g_obsoleteLanguages;
|
||||
for (; ol->code; ++ol) {
|
||||
if (str.equalsIgnoreCase(ol->code))
|
||||
return ol->id;
|
||||
}
|
||||
|
||||
return UNK_LANG;
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ struct LanguageDescription {
|
|||
};
|
||||
|
||||
extern const LanguageDescription g_languages[];
|
||||
|
||||
extern const LanguageDescription g_obsoleteLanguages[];
|
||||
|
||||
/** Convert a string containing a language name into a Language enum value. */
|
||||
extern Language parseLanguage(const String &str);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue