From 1cf59d345ba79719f0c143f5ce1c7047e2b3dea7 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 7 Feb 2023 00:23:31 +0100 Subject: [PATCH] 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. --- docs/changes.txt | 6 ++++++ src/unix/uilocale.cpp | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index fab00ba096..fdbc5cb67f 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -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 ----------------------------------------------------- diff --git a/src/unix/uilocale.cpp b/src/unix/uilocale.cpp index b9ef63865f..d5583d902d 100644 --- a/src/unix/uilocale.cpp +++ b/src/unix/uilocale.cpp @@ -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();