Merge branch 'msw-locale'

Fixes for setting locale under MSW when using older compilers and minor
simplifications and optimizations in wxLocale code.

See https://github.com/wxWidgets/wxWidgets/pull/517
This commit is contained in:
Vadim Zeitlin
2017-07-16 15:03:48 +02:00
3 changed files with 166 additions and 143 deletions

View File

@@ -72,17 +72,18 @@ struct WXDLLIMPEXP_BASE wxLanguageInfo
#endif // __WINDOWS__
// return the locale name corresponding to this language usable with
// setlocale() on the current system
// setlocale() on the current system or empty string if this locale is not
// supported
wxString GetLocaleName() const;
// Call setlocale() and return non-null value if it works for this language.
//
// This function is mostly for internal use, as changing locale involves
// more than just calling setlocale() on some platforms, use wxLocale to
// do everything that needs to be done instead of calling this method.
const char* TrySetLocale() const;
};
// for Unix systems GetLocaleName() is trivial so implement it inline here, for
// MSW it's implemented in intl.cpp
#ifndef __WINDOWS__
inline wxString wxLanguageInfo::GetLocaleName() const { return CanonicalName; }
#endif // !__WINDOWS__
// ----------------------------------------------------------------------------
// wxLocaleCategory: the category of locale settings
// ----------------------------------------------------------------------------
@@ -332,9 +333,11 @@ public:
static void DestroyLanguagesDB();
private:
bool DoInit(const wxString& name,
// This method is trivial and just updates the corresponding member
// variables without doing anything else.
void DoInit(const wxString& name,
const wxString& shortName,
const wxString& locale);
int language);
// copy default table of languages from global static array to
// m_langugagesInfo, called by InitLanguagesDB
@@ -343,6 +346,17 @@ private:
// initialize the member fields to default values
void DoCommonInit();
// After trying to set locale, call this method to give the appropriate
// error if it couldn't be set (success == false) and to load the
// translations for the given language, if necessary.
//
// The return value is the same as "success" parameter.
bool DoCommonPostInit(bool success,
const wxString& name,
const wxString& shortName,
bool bLoadDefault);
wxString m_strLocale, // this locale name
m_strShort; // short name for the locale
int m_language; // this locale wxLanguage value