]> git.saurik.com Git - wxWidgets.git/commitdiff
continue with loading the message catalog even if setting the locale failed
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 26 Sep 2007 23:10:14 +0000 (23:10 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 26 Sep 2007 23:10:14 +0000 (23:10 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48960 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/intl.cpp

index 71a7b950834952c340c89d75e2a819462d535869..e563a8733f7f0a8c981646369e1a932b219d345e 100644 (file)
@@ -1642,6 +1642,8 @@ static const char *wxSetlocaleTryUTF8(int c, const wxString& lc)
 
 bool wxLocale::Init(int language, int flags)
 {
+    bool ret = true;
+
     int lang = language;
     if (lang == wxLANGUAGE_DEFAULT)
     {
@@ -1729,10 +1731,7 @@ bool wxLocale::Init(int language, int flags)
     }
 
     if ( !retloc )
-    {
-        wxLogError(wxT("Cannot set locale to '%s'."), locale.c_str());
-        return false;
-    }
+        ret = false;
 
 #ifdef __AIX__
     // at least in AIX 5.2 libc is buggy and the string returned from
@@ -1798,8 +1797,7 @@ bool wxLocale::Init(int language, int flags)
             if (locale.empty())
             {
                 wxLogLastError(wxT("SetThreadLocale"));
-                wxLogError(wxT("Cannot set locale to language %s."), name.c_str());
-                return false;
+                ret = false;
             }
             else
             {
@@ -1839,10 +1837,7 @@ bool wxLocale::Init(int language, int flags)
     }
 
     if ( !retloc )
-    {
-        wxLogError(wxT("Cannot set locale to language %s."), name.c_str());
-        return false;
-    }
+        ret = false;
 #elif defined(__WXMAC__)
     if (lang == wxLANGUAGE_DEFAULT)
         locale = wxEmptyString;
@@ -1856,11 +1851,6 @@ bool wxLocale::Init(int language, int flags)
         // Some C libraries don't like xx_YY form and require xx only
         retloc = wxSetlocale(LC_ALL, locale.Mid(0,2));
     }
-    if ( !retloc )
-    {
-        wxLogError(wxT("Cannot set locale to '%s'."), locale.c_str());
-        return false;
-    }
 #else
     wxUnusedVar(flags);
     return false;
@@ -1868,9 +1858,20 @@ bool wxLocale::Init(int language, int flags)
 #endif
 
 #ifndef WX_NO_LOCALE_SUPPORT
-    bool ret = Init(name, canonical, retloc,
-                    (flags & wxLOCALE_LOAD_DEFAULT) != 0,
-                    (flags & wxLOCALE_CONV_ENCODING) != 0);
+    if ( !ret )
+    {
+        wxLogWarning(_("Cannot set locale to language \"%s\"."), name.c_str());
+
+        // continue nevertheless and try to load at least the translations for
+        // this language
+    }
+
+    if ( !Init(name, canonical, retloc,
+               (flags & wxLOCALE_LOAD_DEFAULT) != 0,
+               (flags & wxLOCALE_CONV_ENCODING) != 0) )
+    {
+        ret = false;
+    }
 
     if (IsOk()) // setlocale() succeeded
         m_language = lang;