From 91ec90003430ad0f2ea93619a33990c6df5370fb Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 28 Feb 2021 20:04:33 +0100 Subject: [PATCH] Explicitly disallow wxLANGUAGE_UNKNOWN in wxLocale::Init() This value doesn't make here, so be upfront about it. --- interface/wx/intl.h | 8 +++++--- src/common/intl.cpp | 4 ++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/interface/wx/intl.h b/interface/wx/intl.h index 7d7b7b26f9..92902c1b7d 100644 --- a/interface/wx/intl.h +++ b/interface/wx/intl.h @@ -459,9 +459,11 @@ public: try to translate the messages using the message catalogs for this locale. @param language - ::wxLanguage identifier of the locale. - @c wxLANGUAGE_DEFAULT has special meaning -- wxLocale will use system's - default language (see GetSystemLanguage()). + ::wxLanguage identifier of the locale. It can be either some + concrete language, e.g. @c wxLANGUAGE_ESPERANTO, or a special value + @c wxLANGUAGE_DEFAULT which means that wxLocale should use system's + default language (see GetSystemLanguage()). Notice that the value + @c wxLANGUAGE_UNKNOWN is not allowed here. @param flags Combination of the following: - wxLOCALE_LOAD_DEFAULT: Load the message catalog for the given locale diff --git a/src/common/intl.cpp b/src/common/intl.cpp index cb76d6fedf..a9a6835f08 100644 --- a/src/common/intl.cpp +++ b/src/common/intl.cpp @@ -434,6 +434,10 @@ bool wxLocale::Init(int lang, int flags) wxS("wxLOCALE_CONV_ENCODING is no longer supported, add charset to your catalogs") ); #endif + wxCHECK_MSG( lang != wxLANGUAGE_UNKNOWN, false, + wxS("Initializing unknown locale doesn't make sense, did you ") + wxS("mean to use wxLANGUAGE_DEFAULT perhaps?") ); + wxString name, shortName; const wxLanguageInfo *info = GetLanguageInfo(lang);