#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();
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;
// 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