Utilities to get current app language & reset it to default...
... Renaming "InitLang" to "SetLang", then reusing the name "InitLang"
This commit is contained in:
parent
b18f825ee8
commit
6ce24d3cd8
|
@ -991,7 +991,22 @@ wxLanguageInfo userLangs[] =
|
|||
};
|
||||
#endif
|
||||
|
||||
wxString AudacityApp::InitLang( const wxString & lang )
|
||||
wxString AudacityApp::InitLang( wxString langCode )
|
||||
{
|
||||
if ( langCode.empty() )
|
||||
langCode = gPrefs->Read(wxT("/Locale/Language"), wxEmptyString);
|
||||
|
||||
// Use the system default language if one wasn't specified or if the user selected System.
|
||||
if (langCode.empty())
|
||||
{
|
||||
langCode = GetSystemLanguageCode();
|
||||
}
|
||||
|
||||
// Initialize the language
|
||||
return SetLang(langCode);
|
||||
}
|
||||
|
||||
wxString AudacityApp::SetLang( const wxString & lang )
|
||||
{
|
||||
wxString result = lang;
|
||||
|
||||
|
@ -1059,6 +1074,14 @@ wxString AudacityApp::InitLang( const wxString & lang )
|
|||
return result;
|
||||
}
|
||||
|
||||
wxString AudacityApp::GetLang() const
|
||||
{
|
||||
if (mLocale)
|
||||
return mLocale->GetSysName();
|
||||
else
|
||||
return {};
|
||||
}
|
||||
|
||||
void AudacityApp::OnFatalException()
|
||||
{
|
||||
#if defined(EXPERIMENTAL_CRASH_REPORT)
|
||||
|
|
|
@ -73,8 +73,17 @@ class AudacityApp final : public wxApp {
|
|||
|
||||
int FilterEvent(wxEvent & event) override;
|
||||
|
||||
// If no input language given, defaults first to choice in preferences, then
|
||||
// to system language.
|
||||
// Returns the language actually used which is not lang if lang cannot be found.
|
||||
wxString InitLang( const wxString & lang );
|
||||
wxString InitLang( wxString lang = {} );
|
||||
|
||||
// If no input language given, defaults to system language.
|
||||
// Returns the language actually used which is not lang if lang cannot be found.
|
||||
wxString SetLang( const wxString & lang );
|
||||
|
||||
// Returns the last language code that was set
|
||||
wxString GetLang() const;
|
||||
|
||||
// These are currently only used on Mac OS, where it's
|
||||
// possible to have a menu bar but no windows open. It doesn't
|
||||
|
|
|
@ -218,14 +218,7 @@ void InitPreferences()
|
|||
}
|
||||
}
|
||||
|
||||
// Use the system default language if one wasn't specified or if the user selected System.
|
||||
if (langCode.empty())
|
||||
{
|
||||
langCode = GetSystemLanguageCode();
|
||||
}
|
||||
|
||||
// Initialize the language
|
||||
langCode = wxGetApp().InitLang(langCode);
|
||||
langCode = wxGetApp().InitLang( langCode );
|
||||
|
||||
// User requested that the preferences be completely reset
|
||||
if (resetPrefs)
|
||||
|
|
|
@ -650,7 +650,7 @@ bool NyquistEffect::Process()
|
|||
|
||||
mProps += wxString::Format(wxT("(putprop '*AUDACITY* (list %d %d %d) 'VERSION)\n"), AUDACITY_VERSION, AUDACITY_RELEASE, AUDACITY_REVISION);
|
||||
wxString lang = gPrefs->Read(wxT("/Locale/Language"), wxT(""));
|
||||
lang = (lang.empty())? wxGetApp().InitLang(lang) : lang;
|
||||
lang = (lang.empty())? wxGetApp().SetLang(lang) : lang;
|
||||
mProps += wxString::Format(wxT("(putprop '*AUDACITY* \"%s\" 'LANGUAGE)\n"), lang);
|
||||
|
||||
mProps += wxString::Format(wxT("(setf *DECIMAL-SEPARATOR* #\\%c)\n"), wxNumberFormatter::GetDecimalSeparator());
|
||||
|
|
|
@ -242,7 +242,7 @@ bool GUIPrefs::Commit()
|
|||
|
||||
// If language has changed, we want to change it now, not on the next reboot.
|
||||
wxString lang = gPrefs->Read(wxT("/Locale/Language"), wxT(""));
|
||||
wxString usedLang = wxGetApp().InitLang(lang);
|
||||
wxString usedLang = wxGetApp().SetLang(lang);
|
||||
// Bug 1523: Previously didn't check no-language (=System Language)
|
||||
if (!(lang.empty()) && (lang != usedLang)) {
|
||||
// lang was not usable and is not system language. We got overridden.
|
||||
|
|
Loading…
Reference in New Issue