Make TempDefaultLocaleSetter configurable

If `locale_t` support is not available, it is necessary to be able to temporarily set a specific locale, not only the default user locale.
This commit is contained in:
Ulrich Telle 2022-06-19 12:44:56 +02:00 committed by GitHub
parent e0319a9dfb
commit e0e34fcb1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -41,11 +41,11 @@ namespace
class TempDefautLocaleSetter class TempDefautLocaleSetter
{ {
public: public:
explicit TempDefautLocaleSetter(int localeCategory) explicit TempDefautLocaleSetter(int localeCategory, const wxString& localeId = "")
: m_localeCategory(localeCategory), : m_localeCategory(localeCategory), m_localeId(localeId),
m_localeOrig(strdup(setlocale(localeCategory, NULL))) m_localeOrig(strdup(setlocale(localeCategory, NULL)))
{ {
setlocale(localeCategory, ""); setlocale(localeCategory, m_localeId.mb_str());
} }
~TempDefautLocaleSetter() ~TempDefautLocaleSetter()
@ -56,6 +56,7 @@ public:
private: private:
const int m_localeCategory; const int m_localeCategory;
wxString m_localeId;
char* const m_localeOrig; char* const m_localeOrig;
wxDECLARE_NO_COPY_CLASS(TempDefautLocaleSetter); wxDECLARE_NO_COPY_CLASS(TempDefautLocaleSetter);