X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7582edfbf9029a4f4a010329c1cd6bc7c1d084c4..fde8374482bc51ca0539b2db8f449c62a0d0d7e4:/src/common/intl.cpp diff --git a/src/common/intl.cpp b/src/common/intl.cpp index 29132e9ad6..ee790a5c07 100644 --- a/src/common/intl.cpp +++ b/src/common/intl.cpp @@ -570,6 +570,18 @@ bool wxLocale::Init(int language, int flags) #endif // !WX_NO_LOCALE_SUPPORT } +namespace +{ + +// Small helper function: get the value of the given environment variable and +// return true only if the variable was found and has non-empty value. +inline bool wxGetNonEmptyEnvVar(const wxString& name, wxString* value) +{ + return wxGetEnv(name, value) && !value->empty(); +} + +} // anonymous namespace + /*static*/ int wxLocale::GetSystemLanguage() { CreateLanguagesDB(); @@ -592,9 +604,9 @@ bool wxLocale::Init(int language, int flags) str.reset(wxCFRetain((CFStringRef)CFLocaleGetValue(userLocaleRef, kCFLocaleCountryCode))); langFull += str.AsString(); #else - if (!wxGetEnv(wxS("LC_ALL"), &langFull) && - !wxGetEnv(wxS("LC_MESSAGES"), &langFull) && - !wxGetEnv(wxS("LANG"), &langFull)) + if (!wxGetNonEmptyEnvVar(wxS("LC_ALL"), &langFull) && + !wxGetNonEmptyEnvVar(wxS("LC_MESSAGES"), &langFull) && + !wxGetNonEmptyEnvVar(wxS("LANG"), &langFull)) { // no language specified, treat it as English return wxLANGUAGE_ENGLISH_US; @@ -1432,10 +1444,10 @@ wxString wxLocale::GetInfo(wxLocaleInfo index, wxLocaleCategory cat) // this were not the case. wxASSERT_MSG( strcmp(setlocale(LC_ALL, NULL), "C") == 0, wxS("You probably called setlocale() directly instead ") - wxS("of calling wxSetLocale() and now there is a ") + wxS("of using wxLocale and now there is a ") wxS("mismatch between C/C++ and Windows locale.\n") - wxS("Things are going to break, use wxSetLocale() to ") - wxS("avoid this!") ); + wxS("Things are going to break, please only change ") + wxS("locale by creating wxLocale objects to avoid this!") ); // Return the hard coded values for C locale. This is really the right