void wxLocale::DoCommonInit()
{
m_pszOldLocale = NULL;
+
+ m_pOldLocale = wxSetLocale(this);
+
m_pMsgCat = NULL;
m_language = wxLANGUAGE_UNKNOWN;
m_initialized = false;
}
}
- // save the old locale to be able to restore it later
- m_pOldLocale = wxSetLocale(this);
-
// load the default catalog with wxWidgets standard messages
m_pMsgCat = NULL;
bool bOk = true;
wxLogError(wxT("Cannot set locale to language %s."), name.c_str());
return false;
}
-#elif defined(__WXMAC__) || defined(__WXPM__)
+#elif defined(__WXMAC__)
+ if (lang == wxLANGUAGE_DEFAULT)
+ locale = wxEmptyString;
+ else
+ locale = info->CanonicalName;
+
+ wxMB2WXbuf retloc = wxSetlocale(LC_ALL, locale);
+
+ if ( !retloc )
+ {
+ // 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;
+ }
+#elif defined(__WXPM__)
wxMB2WXbuf retloc = wxSetlocale(LC_ALL , wxEmptyString);
#else
return false;
// FIXME: what is the error return value for GetACP()?
UINT codepage = ::GetACP();
encname.Printf(_T("windows-%u"), codepage);
+#elif defined(__WXMAC__)
+ // default is just empty string, this resolves to the default system
+ // encoding later
#elif defined(__UNIX_LIKE__)
#if defined(HAVE_LANGINFO_H) && defined(CODESET)
delete pTmpCat;
}
- // restore old locale
+ // restore old locale pointer
wxSetLocale(m_pOldLocale);
+
// FIXME
#ifndef __WXWINCE__
wxSetlocale(LC_ALL, m_pszOldLocale);