From 20e3697f0013b3a5833ee867d1ca98fc7722ec21 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 29 Aug 2021 18:53:29 +0200 Subject: [PATCH] Change wxLocaleIdent ctor to take char* rather than wxString This is convenient, as it allows using a simple string such as "en" as an argument to the functions taking wxLocaleIdent and rely on implicit conversion, whereas previously explicitly writing either wxString("en") or wxLocaleIdent("en") would be necessary. --- include/wx/localedefs.h | 9 +++++++-- interface/wx/uilocale.h | 5 ++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/wx/localedefs.h b/include/wx/localedefs.h index 686cb2ae98..e948830c52 100644 --- a/include/wx/localedefs.h +++ b/include/wx/localedefs.h @@ -118,8 +118,13 @@ public: // Leave language empty wxLocaleIdent() { } - // Construct name from language - wxLocaleIdent(const wxString& language) : m_language(language) { } + // Construct from language, i.e. a two-letter ISO 639-1 code (or a + // three-letter ISO 639-2 code if there is no ISO 639-1 code for this + // language). + wxLocaleIdent(const char* language) + : m_language(wxString::FromAscii(language)) + { + } // Set language wxLocaleIdent& Language(const wxString& language) diff --git a/interface/wx/uilocale.h b/interface/wx/uilocale.h index 9d37b19be3..065ca0180f 100644 --- a/interface/wx/uilocale.h +++ b/interface/wx/uilocale.h @@ -184,11 +184,14 @@ public: /** Constructor with language. + Note that this constructor is non-explicit, allowing to pass just a + simple string, such as "en", to functions taking wxLocaleIdent. + @param language ISO 639 language code. See Language() for more detailed info. */ - wxLocaleIdent(const wxString& language); + wxLocaleIdent(const char* language); /** Set language.