Skip to content

Commit

Permalink
[i18n] Fix Linux UTF8 switch, and log in case the ::setlocale() indic…
Browse files Browse the repository at this point in the history
…ates failure with a NULL return.
  • Loading branch information
christofmuc committed Mar 10, 2022
1 parent a514862 commit acfd527
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions I18NHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ void globalSetupLocale()
SimpleLogger::instance()->postMessage("Bindtext domain gave us " + String(result));
#if defined(WIN32) || defined(__APPLE__)
std::string displayLocale = juce::SystemStats::getDisplayLanguage().toStdString();
bind_textdomain_codeset(USE_GETTEXT_TEXT_DOMAIN, "utf-8");
#else
std::string displayLocale = ::setlocale (LC_MESSAGES, "");
#endif
bind_textdomain_codeset(USE_GETTEXT_TEXT_DOMAIN, "utf-8");
switchDisplayLanguage(displayLocale.c_str());
}

Expand All @@ -90,7 +90,10 @@ void switchDisplayLanguage(const char* languageID)
setenv("LANG", localeToSet, 1);
#endif
#else
::setlocale(LC_MESSAGES, languageID);
auto returnValue = ::setlocale(LC_MESSAGES, languageID);
if (returnValue == nullptr) {
SimpleLogger::instance()->postMessage("User locale " + String(languageID) + " requested but error returned");
}
localeToSet = languageID;
#endif

Expand Down

0 comments on commit acfd527

Please sign in to comment.