don't report setlocale failure if trying to set Unicode-only language
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20146 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -119,9 +119,12 @@ bool MyApp::OnInit()
|
|||||||
wxLANGUAGE_FRENCH,
|
wxLANGUAGE_FRENCH,
|
||||||
wxLANGUAGE_GERMAN,
|
wxLANGUAGE_GERMAN,
|
||||||
wxLANGUAGE_RUSSIAN,
|
wxLANGUAGE_RUSSIAN,
|
||||||
|
#if wxUSE_UNICODE
|
||||||
wxLANGUAGE_JAPANESE,
|
wxLANGUAGE_JAPANESE,
|
||||||
|
wxLANGUAGE_GEORGIAN,
|
||||||
|
#endif
|
||||||
wxLANGUAGE_ENGLISH,
|
wxLANGUAGE_ENGLISH,
|
||||||
wxLANGUAGE_ENGLISH_US,
|
wxLANGUAGE_ENGLISH_US
|
||||||
};
|
};
|
||||||
|
|
||||||
if ( lng == -1 )
|
if ( lng == -1 )
|
||||||
@@ -134,7 +137,10 @@ bool MyApp::OnInit()
|
|||||||
_T("French"),
|
_T("French"),
|
||||||
_T("German"),
|
_T("German"),
|
||||||
_T("Russian"),
|
_T("Russian"),
|
||||||
_T("Japanese"), // this will only work in Unicode build
|
#if wxUSE_UNICODE
|
||||||
|
_T("Japanese"),
|
||||||
|
_T("Georgian (no translation)"),
|
||||||
|
#endif
|
||||||
_T("English"),
|
_T("English"),
|
||||||
_T("English (U.S.)")
|
_T("English (U.S.)")
|
||||||
};
|
};
|
||||||
|
@@ -711,6 +711,17 @@ bool wxLocale::Init(int language, int flags)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
#elif defined(__WIN32__)
|
#elif defined(__WIN32__)
|
||||||
|
|
||||||
|
#if wxUSE_UNICODE && (defined(__VISUALC__) || defined(__MINGW32__))
|
||||||
|
// NB: setlocale() from msvcrt.dll (used by VC++ and Mingw)
|
||||||
|
// can't set locale to language that can only be written using
|
||||||
|
// Unicode. Therefore wxSetlocale call failed, but we don't want
|
||||||
|
// to report it as an error -- so that at least message catalogs
|
||||||
|
// can be used. Watch for code marked with
|
||||||
|
// #ifdef SETLOCALE_FAILS_ON_UNICODE_LANGS bellow.
|
||||||
|
#define SETLOCALE_FAILS_ON_UNICODE_LANGS
|
||||||
|
#endif
|
||||||
|
|
||||||
wxMB2WXbuf retloc = wxT("C");
|
wxMB2WXbuf retloc = wxT("C");
|
||||||
if (language != wxLANGUAGE_DEFAULT)
|
if (language != wxLANGUAGE_DEFAULT)
|
||||||
{
|
{
|
||||||
@@ -721,25 +732,24 @@ bool wxLocale::Init(int language, int flags)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
int codepage = -1;
|
||||||
wxUint32 lcid = MAKELCID(MAKELANGID(info->WinLang, info->WinSublang),
|
wxUint32 lcid = MAKELCID(MAKELANGID(info->WinLang, info->WinSublang),
|
||||||
SORT_DEFAULT);
|
SORT_DEFAULT);
|
||||||
if (SetThreadLocale(lcid))
|
SetThreadLocale(lcid);
|
||||||
{
|
// NB: we must translate LCID to CRT's setlocale string ourselves,
|
||||||
retloc = wxSetlocale(LC_ALL, wxEmptyString);
|
// because SetThreadLocale does not modify change the
|
||||||
}
|
// interpretation of setlocale(LC_ALL, "") call:
|
||||||
else
|
|
||||||
{
|
|
||||||
// Windows9X doesn't support SetThreadLocale, so we must
|
|
||||||
// translate LCID to CRT's setlocale string ourselves
|
|
||||||
locale.Empty();
|
|
||||||
if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
|
|
||||||
{
|
|
||||||
wxChar buffer[256];
|
wxChar buffer[256];
|
||||||
buffer[0] = wxT('\0');
|
buffer[0] = wxT('\0');
|
||||||
GetLocaleInfo(lcid, LOCALE_SENGLANGUAGE, buffer, 256);
|
GetLocaleInfo(lcid, LOCALE_SENGLANGUAGE, buffer, 256);
|
||||||
locale << buffer;
|
locale << buffer;
|
||||||
if (GetLocaleInfo(lcid, LOCALE_SENGCOUNTRY, buffer, 256) > 0)
|
if (GetLocaleInfo(lcid, LOCALE_SENGCOUNTRY, buffer, 256) > 0)
|
||||||
locale << wxT("_") << buffer;
|
locale << wxT("_") << buffer;
|
||||||
|
if (GetLocaleInfo(lcid, LOCALE_IDEFAULTANSICODEPAGE, buffer, 256) > 0)
|
||||||
|
{
|
||||||
|
codepage = wxAtoi(buffer);
|
||||||
|
if (codepage != 0)
|
||||||
|
locale << wxT(".") << buffer;
|
||||||
}
|
}
|
||||||
if (locale.IsEmpty())
|
if (locale.IsEmpty())
|
||||||
{
|
{
|
||||||
@@ -750,13 +760,30 @@ bool wxLocale::Init(int language, int flags)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
retloc = wxSetlocale(LC_ALL, locale);
|
retloc = wxSetlocale(LC_ALL, locale);
|
||||||
|
#ifdef SETLOCALE_FAILS_ON_UNICODE_LANGS
|
||||||
|
if (codepage == 0 && (const wxChar*)retloc == NULL)
|
||||||
|
{
|
||||||
|
retloc = wxT("C");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
retloc = wxSetlocale(LC_ALL, wxEmptyString);
|
retloc = wxSetlocale(LC_ALL, wxEmptyString);
|
||||||
|
#ifdef SETLOCALE_FAILS_ON_UNICODE_LANGS
|
||||||
|
if ((const wxChar*)retloc == NULL)
|
||||||
|
{
|
||||||
|
wxChar buffer[16];
|
||||||
|
if (GetLocaleInfo(LOCALE_USER_DEFAULT,
|
||||||
|
LOCALE_IDEFAULTANSICODEPAGE, buffer, 16) > 0 &&
|
||||||
|
wxStrcmp(buffer, wxT("0")) == 0)
|
||||||
|
{
|
||||||
|
retloc = wxT("C");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !retloc )
|
if ( !retloc )
|
||||||
|
Reference in New Issue
Block a user