1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-03 17:19:43 +02:00

Bug1288: Don't crash when changing language to "Simplified"...

... but give a warning message about the unknown language.
This commit is contained in:
Paul Licameli 2016-01-26 20:09:54 -05:00
parent 2550a59c0e
commit 907c950a0e
4 changed files with 25 additions and 9 deletions

View File

@ -985,8 +985,10 @@ wxLanguageInfo userLangs[] =
};
#endif
void AudacityApp::InitLang( const wxString & lang )
wxString AudacityApp::InitLang( const wxString & lang )
{
wxString result = lang;
if (mLocale)
delete mLocale;
@ -1001,10 +1003,18 @@ void AudacityApp::InitLang( const wxString & lang )
wxSetEnv(wxT("LANG"), wxT("en_US.UTF-8"));
#endif
const wxLanguageInfo *info = wxLocale::FindLanguageInfo(lang);
if (!lang)
const wxLanguageInfo *info = NULL;
if (!lang.empty()) {
info = wxLocale::FindLanguageInfo(lang);
if (!info)
::wxMessageBox(wxString::Format(_("Language \"%s\" is unknown"), lang));
}
if (!info)
{
return;
result = GetSystemLanguageCode();
info = wxLocale::FindLanguageInfo(result);
if (!info)
return result;
}
mLocale = new wxLocale(info->Language);
@ -1035,6 +1045,8 @@ void AudacityApp::InitLang( const wxString & lang )
wxCommandEvent evt(EVT_LANGUAGE_CHANGE);
ProcessEvent(evt);
}
return result;
}
void AudacityApp::OnFatalException()

View File

@ -105,7 +105,8 @@ class AudacityApp:public wxApp {
int FilterEvent(wxEvent & event);
void InitLang( const wxString & lang );
// Returns the language actually used which is not lang if lang cannot be found.
wxString InitLang( const wxString & lang );
// These are currently only used on Mac OS, where it's
// possible to have a menu bar but no windows open. It doesn't

View File

@ -182,7 +182,7 @@ void InitPreferences()
}
// Initialize the language
wxGetApp().InitLang(langCode);
langCode = wxGetApp().InitLang(langCode);
// User requested that the preferences be completely reset
if (resetPrefs)

View File

@ -166,9 +166,12 @@ bool GUIPrefs::Apply()
// If language has changed, we want to change it now, not on the next reboot.
wxString lang = gPrefs->Read(wxT("/Locale/Language"), wxT(""));
if (lang == wxT(""))
lang = GetSystemLanguageCode();
wxGetApp().InitLang(lang);
wxString usedLang = wxGetApp().InitLang(lang);
if (lang != usedLang) {
// lang was not usable. We got overridden.
gPrefs->Write(wxT("/Locale/Language"), usedLang);
gPrefs->Flush();
}
return true;
}