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 <vadim@wxwidgets.org>

Closes #2615.
This commit is contained in:
utelle
2022-03-28 01:11:40 +02:00
committed by Vadim Zeitlin
parent 891cbb1e0e
commit 6d6e5cde21
17 changed files with 2015 additions and 673 deletions

View File

@@ -364,6 +364,30 @@ MyFrame::MyFrame()
),
wxSizerFlags().Center().Border());
topSizer->Add(new wxStaticText
(
panel,
wxID_ANY,
wxString::Format
(
_("UI locale name in English: %s"),
wxUILocale::GetCurrent().GetLocalizedName(wxLOCALE_NAME_LOCALE, wxLOCALE_FORM_ENGLISH)
)
),
wxSizerFlags().Center().Border());
topSizer->Add(new wxStaticText
(
panel,
wxID_ANY,
wxString::Format
(
_("... and in the locale language: %s"),
wxUILocale::GetCurrent().GetLocalizedName(wxLOCALE_NAME_LOCALE, wxLOCALE_FORM_NATIVE)
)
),
wxSizerFlags().Center().Border());
// create some controls affected by the locale
// this demonstrates RTL layout mirroring for Arabic locales and using
@@ -528,16 +552,17 @@ void MyFrame::OnTestLocaleAvail(wxCommandEvent& WXUNUSED(event))
return;
s_locale = locale;
const wxLanguageInfo * const info = wxLocale::FindLanguageInfo(s_locale);
if ( !info )
{
wxLogError(_("Locale \"%s\" is unknown."), s_locale);
return;
}
if ( wxLocale::IsAvailable(info->Language) )
wxUILocale uiLocale = wxUILocale::FromTag(s_locale);
if (uiLocale.IsSupported())
{
wxLogMessage(_("Locale \"%s\" is available."), s_locale);
wxLayoutDirection layout = uiLocale.GetLayoutDirection();
wxString strLayout = (layout == wxLayout_RightToLeft) ? "RTL" : "LTR";
wxString strLocale = uiLocale.GetLocalizedName(wxLOCALE_NAME_LOCALE, wxLOCALE_FORM_NATIVE);
wxLogMessage(_("Locale \"%s\" is available.\nIdentifier: %s; Layout: %s\nEnglish name: %s\nLocalized name: %s"),
s_locale, uiLocale.GetName(), strLayout,
uiLocale.GetLocalizedName(wxLOCALE_NAME_LOCALE, wxLOCALE_FORM_ENGLISH),
uiLocale.GetLocalizedName(wxLOCALE_NAME_LOCALE, wxLOCALE_FORM_NATIVE));
}
else
{