Provide name-based wxUILocale implementation for post-XP MSW

Use the recommended name-based NLS API rather than legacy functions
taking LCID.

Preserve compatibility with Windows XP by keeping the old code for now,
but it will be removed after 3.2.0.
This commit is contained in:
Vadim Zeitlin
2021-08-29 18:58:30 +01:00
parent 608718dd9c
commit 07e79b7736
3 changed files with 174 additions and 15 deletions

View File

@@ -1102,7 +1102,7 @@ bool IsAtTwoSingleQuotes(const wxString& fmt, wxString::const_iterator p)
// our best.
// The function is only exported because it is used in the unit test, it is not
// part of the public API.
// part of the public API (but it is also used by wxUILocaleImpl).
WXDLLIMPEXP_BASE
wxString wxTranslateFromUnicodeFormat(const wxString& fmt)
{
@@ -1456,14 +1456,11 @@ wxString wxTranslateFromUnicodeFormat(const wxString& fmt)
#if defined(__WINDOWS__)
// This function is also used by wxUILocaleImpl, so don't make it private.
// These functions are also used by wxUILocaleImpl, so don't make them private.
extern wxString
wxGetInfoFromLCID(LCID lcid, wxLocaleInfo index, wxLocaleCategory cat);
namespace
{
LCTYPE GetLCTYPEFormatFromLocalInfo(wxLocaleInfo index)
LCTYPE wxGetLCTYPEFormatFromLocalInfo(wxLocaleInfo index)
{
switch ( index )
{
@@ -1483,6 +1480,9 @@ LCTYPE GetLCTYPEFormatFromLocalInfo(wxLocaleInfo index)
return 0;
}
namespace
{
// This private function additionally checks consistency of the decimal
// separator settings between MSW and CRT.
wxString
@@ -1543,7 +1543,7 @@ wxGetInfoFromLCID(LCID lcid, wxLocaleInfo index, wxLocaleCategory cat)
case wxLOCALE_SHORT_DATE_FMT:
case wxLOCALE_LONG_DATE_FMT:
case wxLOCALE_TIME_FMT:
if ( ::GetLocaleInfo(lcid, GetLCTYPEFormatFromLocalInfo(index),
if ( ::GetLocaleInfo(lcid, wxGetLCTYPEFormatFromLocalInfo(index),
buf, WXSIZEOF(buf)) )
{
return wxTranslateFromUnicodeFormat(buf);