Remove fallback on locale using different region under Unix

Historically, we used to fall back on any locale using the same
language, if the exactly requested locale was unavailable. This doesn't
seem such a great idea, and results in unexpected behaviour, such as
returning true from wxUILocale::IsSupported() for locales such as
"en-FR" that are not really supported at all.

Remove this fallback and just return false if the locale with the
specified region is not supported.

Still choose any supported region if the region is omitted entirely,
however.
This commit is contained in:
Vadim Zeitlin 2023-02-07 00:23:31 +01:00
parent 3dfe253d3c
commit 1cf59d345b
2 changed files with 10 additions and 4 deletions

View file

@ -63,6 +63,12 @@ Changes in behaviour not resulting in compilation errors
mode under MSW, use the new AreAppsDark() or IsSystemDark() to check if the
other applications or the system are using dark mode.
- wxUILocale::IsSupported() now returns false for unavailable locales under
Unix systems without trying to fall back on another locale using the same
language in a different region, e.g. it doesn't use fr_FR if fr_BE is not
available. If any locale using the given language is acceptable, the region
must be left empty, e.g. just "fr" would use any available "fr_XX".
Changes in behaviour which may result in build errors
-----------------------------------------------------

View file

@ -272,11 +272,11 @@ locale_t TryCreateLocaleWithUTF8(wxLocaleIdent& locId)
locale_t TryCreateMatchingLocale(wxLocaleIdent& locId)
{
locale_t loc = TryCreateLocaleWithUTF8(locId);
if ( !loc )
if ( !loc && locId.GetRegion().empty() )
{
// Try to find a variant of this locale available on this system: first
// of all, using just the language, without the territory, typically
// does _not_ work under Linux, so try adding one if we don't have it.
// Try to find a variant of this locale available on this system: as
// using just the language, without the territory, typically does _not_
// work under Linux, we try adding one if we don't have it.
const wxString lang = locId.GetLanguage();
const wxLanguageInfos& infos = wxGetLanguageInfos();