From 6d6e5cde21969f91f9f4df85a72f0ae68e423cb1 Mon Sep 17 00:00:00 2001 From: utelle Date: Mon, 28 Mar 2022 01:11:40 +0200 Subject: [PATCH] Enhance wxUILocale and wxLocaleIdent Many improvements and fixes to wxUILocale: - Add wxUILocale method for retrieving wxLocaleIdent identifier, localized names, layout direction. - Add wxLocaleIdent attributes, getter, and setter for platform-dependent tags under Windows: extension, sort order. - Modify method wxLocaleIdent::FromTag to support not only BCP 47-like tags, but also platform-dependent syntax. - Modify method wxLocaleIdent::GetTag to allow specifying the tag type. - Update internat sample to better show using wxUILocale. - Update German and French message catalogs for internat sample (German fully translated, French msgIds only). - Introduced wxUILocaleImplStdC under Windows, because locale "en-US" is not equivalent to the C locale. - Adjust wxLocale class to restore previous wxUILocale in the destructor. - Implement wxLocale::GetInfo method through wxUILocale methods. - Removed LCID dependency in wxLocale. - Move the implementation of some static wxUILocale methods from intl.cpp to uilocale.cpp. Co-authored-by: Vadim Zeitlin Closes #2615. --- include/wx/intl.h | 1 + include/wx/localedefs.h | 46 +++ include/wx/private/uilocale.h | 8 + include/wx/uilocale.h | 37 ++- interface/wx/intl.h | 72 +++++ interface/wx/uilocale.h | 137 +++++++- samples/internat/de/internat.mo | Bin 5473 -> 5802 bytes samples/internat/de/internat.po | 117 ++++--- samples/internat/fr/internat.mo | Bin 1889 -> 1762 bytes samples/internat/fr/internat.po | 283 +++++++++++++--- samples/internat/internat.cpp | 41 ++- src/common/intl.cpp | 552 +++++--------------------------- src/common/uilocale.cpp | 539 ++++++++++++++++++++++++++++--- src/msw/uilocale.cpp | 443 +++++++++++++++++++++++-- src/osx/core/uilocale.mm | 82 +++++ src/unix/uilocale.cpp | 327 +++++++++++++++++-- tests/intl/intltest.cpp | 3 +- 17 files changed, 2015 insertions(+), 673 deletions(-) diff --git a/include/wx/intl.h b/include/wx/intl.h index 98377b7635..4b7614e7b1 100644 --- a/include/wx/intl.h +++ b/include/wx/intl.h @@ -270,6 +270,7 @@ private: m_strShort; // short name for the locale int m_language; // this locale wxLanguage value + wxString m_oldUILocale; // previous wxUILocale name const char *m_pszOldLocale; // previous locale from setlocale() wxLocale *m_pOldLocale; // previous wxLocale #ifdef __WIN32__ diff --git a/include/wx/localedefs.h b/include/wx/localedefs.h index ed3f8bfc74..1f09ee7576 100644 --- a/include/wx/localedefs.h +++ b/include/wx/localedefs.h @@ -32,6 +32,31 @@ enum wxLayoutDirection // wxLocaleCategory: the category of locale settings // ---------------------------------------------------------------------------- +enum wxLocaleTagType +{ + // Default (tag as given or else same as wxLOCALE_TAGTYPE_SYSTEM) + wxLOCALE_TAGTYPE_DEFAULT, + + // Default type of the system (platform-dependent) + wxLOCALE_TAGTYPE_SYSTEM, + + // BCP47-like type: [-