Refactor wxLocale initialization code
Don't call wxSetlocale() in DoInit() any more, this was redundant when it was called from Init(wxLanguage) overload. Add new DoCommonPostInit() called from both Init() overloads after setting the locale in whichever way they do it to avoid code duplication. As a side effect of this change, the error message given if the locale can't be set is the same now independently of the ctor/Init() overload used (previously it differed depending on whether a wxLanguage or the name of the language as string was passed) and it's always logged using wxLogWarning() and not it in one case and wxLogError() in the other one.
This commit is contained in:
@@ -333,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
|
||||
@@ -344,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
|
||||
|
Reference in New Issue
Block a user