Leave NULL impl pointer in wxUILocale if locale is not supported

This finally seems better than always creating some kind of impl object,
even if the locale isn't supported at all and makes all ports behave
consistently, as previously CreateForLocale() only returned NULL in
wxOSX implementation if the locale was unrecognized, but now all ports
do this (at least when locale_t and related functions are available
under Unix).

Also stop returning bool from Use(), as this resulted in initializing
wxLocale with any non-default language to fail under Mac: just ignore
the error here, as we always did it until now, because there is nothing
we can do about it anyhow.
This commit is contained in:
Vadim Zeitlin
2021-08-30 20:55:51 +02:00
parent e3ff6dc056
commit aa4cce8f7d
6 changed files with 133 additions and 91 deletions

View File

@@ -13,6 +13,9 @@
#include "wx/localedefs.h"
#include "wx/string.h"
// Function returning hard-coded values for the "C" locale.
wxString wxGetStdCLocaleInfo(wxLocaleInfo index, wxLocaleCategory cat);
// ----------------------------------------------------------------------------
// wxUILocaleImpl provides the implementation of public wxUILocale functions
// ----------------------------------------------------------------------------
@@ -53,9 +56,9 @@ public:
// Use this locale in the UI.
//
// This is not implemented for all platforms, notably not for Mac where the
// UI locale is determined at application startup, and so this function
// always returns false there.
virtual bool Use() = 0;
// UI locale is determined at application startup, but we can't do anything
// about it anyhow, so we don't even bother returning an error code from it.
virtual void Use() = 0;
// Functions corresponding to wxUILocale ones.
virtual wxString GetName() const = 0;