this is ugly as hell, but what
else can I do to make following cases different: a) wxSetlocale returns b) wxSetlocale returns NULL ? git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@17919 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -666,7 +666,6 @@ bool wxLocale::Init(int language, int flags)
|
|||||||
wxString name = info->Description;
|
wxString name = info->Description;
|
||||||
wxString canonical = info->CanonicalName;
|
wxString canonical = info->CanonicalName;
|
||||||
wxString locale;
|
wxString locale;
|
||||||
wxString retloc;
|
|
||||||
|
|
||||||
// Set the locale:
|
// Set the locale:
|
||||||
#if defined(__UNIX__) && !defined(__WXMAC__)
|
#if defined(__UNIX__) && !defined(__WXMAC__)
|
||||||
@@ -675,14 +674,15 @@ bool wxLocale::Init(int language, int flags)
|
|||||||
else
|
else
|
||||||
locale = info->CanonicalName;
|
locale = info->CanonicalName;
|
||||||
|
|
||||||
retloc = wxSetlocale(LC_ALL, locale);
|
wxMB2WXbuf retloc = wxSetlocale(LC_ALL, locale);
|
||||||
|
|
||||||
if (retloc.empty())
|
if ((const wxChar*)retloc == NULL)
|
||||||
{
|
{
|
||||||
// Some C libraries don't like xx_YY form and require xx only
|
// Some C libraries don't like xx_YY form and require xx only
|
||||||
retloc = wxSetlocale(LC_ALL, locale.Mid(0,2));
|
wxMB2WXbuf tmp = wxSetlocale(LC_ALL, locale.Mid(0,2));
|
||||||
|
retloc = tmp;
|
||||||
}
|
}
|
||||||
if (retloc.empty())
|
if ((const wxChar*)retloc == NULL)
|
||||||
{
|
{
|
||||||
// Some C libraries (namely glibc) still use old ISO 639,
|
// Some C libraries (namely glibc) still use old ISO 639,
|
||||||
// so will translate the abbrev for them
|
// so will translate the abbrev for them
|
||||||
@@ -690,33 +690,39 @@ bool wxLocale::Init(int language, int flags)
|
|||||||
if (mid == wxT("he")) locale = wxT("iw") + locale.Mid(3);
|
if (mid == wxT("he")) locale = wxT("iw") + locale.Mid(3);
|
||||||
else if (mid == wxT("id")) locale = wxT("in") + locale.Mid(3);
|
else if (mid == wxT("id")) locale = wxT("in") + locale.Mid(3);
|
||||||
else if (mid == wxT("yi")) locale = wxT("ji") + locale.Mid(3);
|
else if (mid == wxT("yi")) locale = wxT("ji") + locale.Mid(3);
|
||||||
retloc = wxSetlocale(LC_ALL, locale);
|
wxMB2WXbuf tmp = wxSetlocale(LC_ALL, locale);
|
||||||
|
retloc = tmp;
|
||||||
}
|
}
|
||||||
if (retloc.empty())
|
if ((const wxChar*)retloc == NULL)
|
||||||
{
|
{
|
||||||
// (This time, we changed locale in previous if-branch, so try again.)
|
// (This time, we changed locale in previous if-branch, so try again.)
|
||||||
// Some C libraries don't like xx_YY form and require xx only
|
// Some C libraries don't like xx_YY form and require xx only
|
||||||
retloc = wxSetlocale(LC_ALL, locale.Mid(0,2));
|
wxMB2WXbuf tmp = wxSetlocale(LC_ALL, locale.Mid(0,2));
|
||||||
|
retloc = tmp;
|
||||||
}
|
}
|
||||||
if (retloc.empty())
|
if ((const wxChar*)retloc == NULL)
|
||||||
{
|
{
|
||||||
wxLogError(wxT("Cannot set locale to '%s'."), locale.c_str());
|
wxLogError(wxT("Cannot set locale to '%s'."), locale.c_str());
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
#elif defined(__WIN32__)
|
#elif defined(__WIN32__)
|
||||||
|
wxMB2WXbuf retloc(wxT("C"));
|
||||||
if (language != wxLANGUAGE_DEFAULT)
|
if (language != wxLANGUAGE_DEFAULT)
|
||||||
{
|
{
|
||||||
if (info->WinLang == 0)
|
if (info->WinLang == 0)
|
||||||
{
|
{
|
||||||
wxLogWarning(wxT("Locale '%s' not supported by OS."), name.c_str());
|
wxLogWarning(wxT("Locale '%s' not supported by OS."), name.c_str());
|
||||||
retloc = wxT("C");
|
// retloc already set to "C"
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxUint32 lcid = MAKELCID(MAKELANGID(info->WinLang, info->WinSublang),
|
wxUint32 lcid = MAKELCID(MAKELANGID(info->WinLang, info->WinSublang),
|
||||||
SORT_DEFAULT);
|
SORT_DEFAULT);
|
||||||
if (SetThreadLocale(lcid))
|
if (SetThreadLocale(lcid))
|
||||||
retloc = wxSetlocale(LC_ALL, wxEmptyString);
|
{
|
||||||
|
wxMB2WXbuf tmp = wxSetlocale(LC_ALL, wxEmptyString);
|
||||||
|
retloc = tmp;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Windows9X doesn't support SetThreadLocale, so we must
|
// Windows9X doesn't support SetThreadLocale, so we must
|
||||||
@@ -738,20 +744,26 @@ bool wxLocale::Init(int language, int flags)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
retloc = wxSetlocale(LC_ALL, locale);
|
{
|
||||||
|
wxMB2WXbuf tmp = wxSetlocale(LC_ALL, locale);
|
||||||
|
retloc = tmp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
retloc = wxSetlocale(LC_ALL, wxEmptyString);
|
{
|
||||||
|
wxMB2WXbuf tmp = wxSetlocale(LC_ALL, wxEmptyString);
|
||||||
|
retloc = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
if (retloc.empty())
|
if ((const wxChar*)retloc == NULL)
|
||||||
{
|
{
|
||||||
wxLogError(wxT("Cannot set locale to language %s."), name.c_str());
|
wxLogError(wxT("Cannot set locale to language %s."), name.c_str());
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
#elif defined(__WXMAC__)
|
#elif defined(__WXMAC__)
|
||||||
retloc = wxSetlocale(LC_ALL , wxEmptyString);
|
wxMB2WXbuf retloc = wxSetlocale(LC_ALL , wxEmptyString);
|
||||||
#else
|
#else
|
||||||
return FALSE;
|
return FALSE;
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user