Browse Source

Replace en_US code with en when searching for user preferred languages (#3859)

pull/3862/head
Andrew James 4 years ago committed by GitHub
parent
commit
e1d01aad7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      Source/options.cpp
  2. 5
      Source/utils/language.cpp

7
Source/options.cpp

@ -1030,7 +1030,12 @@ void OptionEntryLanguageCode::LoadFromIni(string_view category)
locales.emplace_back(std::locale("").name().substr(0, 5));
#endif
// Insert non-regional locale codes after the last regional variation so we fallback to neutral translations if no regional translation exists that meets user preferences.
// So that the correct language is shown in the settings menu for users with US english set as a preferred language
// we need to replace the "en_US" locale code with the neutral string "en" as expected by the available options
std::replace(locales.begin(), locales.end(), std::string { "en_US" }, std::string { "en" });
// Insert non-regional locale codes after the last regional variation so we fallback to neutral translations if no
// regional translation exists that meets user preferences.
for (auto localeIter = locales.rbegin(); localeIter != locales.rend(); localeIter++) {
auto regionSeparator = localeIter->find('_');
if (regionSeparator != std::string::npos) {

5
Source/utils/language.cpp

@ -270,8 +270,9 @@ const std::string &LanguageTranslate(const char *key)
bool HasTranslation(const std::string &locale)
{
if (locale == "en" || locale == "en_US") {
// the base translation is en_US. No translation file will be present for these codes but we want the check to succeed to prevent further searches.
if (locale == "en") {
// the base translation is en (really en_US). No translation file will be present for this code but we want
// the check to succeed to prevent further searches.
return true;
}

Loading…
Cancel
Save