From e3ff6dc0567452c68ce4674b2f14854af857f8ed Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 30 Aug 2021 20:53:28 +0200 Subject: [PATCH] Create wxGetStdCLocaleInfo() function Extract it from existing MSW-only code and make it available in all ports so that we could use it as a fallback in wxUILocale if everything else fails. No real changes yet. --- src/common/intl.cpp | 53 +++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/src/common/intl.cpp b/src/common/intl.cpp index 57732f13eb..f31a231510 100644 --- a/src/common/intl.cpp +++ b/src/common/intl.cpp @@ -1454,6 +1454,35 @@ wxString wxTranslateFromUnicodeFormat(const wxString& fmt) #endif // __WINDOWS__ || __WXOSX__ +wxString wxGetStdCLocaleInfo(wxLocaleInfo index, wxLocaleCategory WXUNUSED(cat)) +{ + switch ( index ) + { + case wxLOCALE_THOUSANDS_SEP: + return wxString(); + + case wxLOCALE_DECIMAL_POINT: + return "."; + + case wxLOCALE_SHORT_DATE_FMT: + return "%m/%d/%y"; + + case wxLOCALE_LONG_DATE_FMT: + return "%A, %B %d, %Y"; + + case wxLOCALE_TIME_FMT: + return "%H:%M:%S"; + + case wxLOCALE_DATE_TIME_FMT: + return "%m/%d/%y %H:%M:%S"; + + default: + wxFAIL_MSG( "unknown wxLocaleInfo" ); + } + + return wxString(); +} + #if defined(__WINDOWS__) // These functions are also used by wxUILocaleImpl, so don't make them private. @@ -1600,29 +1629,7 @@ wxString wxLocale::GetInfo(wxLocaleInfo index, wxLocaleCategory cat) // case, even LOCALE_INVARIANT is not quite the same as C locale (the // only difference is that it uses %Y instead of %y in the date format // but this difference is significant enough). - switch ( index ) - { - case wxLOCALE_THOUSANDS_SEP: - return wxString(); - - case wxLOCALE_DECIMAL_POINT: - return "."; - - case wxLOCALE_SHORT_DATE_FMT: - return "%m/%d/%y"; - - case wxLOCALE_LONG_DATE_FMT: - return "%A, %B %d, %Y"; - - case wxLOCALE_TIME_FMT: - return "%H:%M:%S"; - - case wxLOCALE_DATE_TIME_FMT: - return "%m/%d/%y %H:%M:%S"; - - default: - wxFAIL_MSG( "unknown wxLocaleInfo" ); - } + return wxGetStdCLocaleInfo(index, cat); } // wxSetLocale() succeeded and so thread locale was set together with CRT one.