diff --git a/src/AudacityApp.cpp b/src/AudacityApp.cpp index 8e25bd7f0..7d09ab369 100644 --- a/src/AudacityApp.cpp +++ b/src/AudacityApp.cpp @@ -195,7 +195,7 @@ void PopulatePreferences() auto &ini = *pIni; wxString lang; - if (ini.Read(wxT("/FromInno/Language"), &lang)) + if (ini.Read(wxT("/FromInno/Language"), &lang) && !lang.empty()) { // Only change "langCode" if the language was actually specified in the ini file. langCode = lang; @@ -217,7 +217,12 @@ void PopulatePreferences() } } - langCode = GUIPrefs::InitLang( langCode ); + // Use the system default language if one wasn't specified or if the user selected System. + if (langCode.empty()) + langCode = + Languages::GetSystemLanguageCode(FileNames::AudacityPathList()); + + langCode = GUIPrefs::SetLang( langCode ); // User requested that the preferences be completely reset if (resetPrefs) diff --git a/src/CrashReport.cpp b/src/CrashReport.cpp index 1a8f60e76..18f79e16f 100644 --- a/src/CrashReport.cpp +++ b/src/CrashReport.cpp @@ -60,8 +60,8 @@ void Generate(wxDebugReport::Context ctx) if (ctx == wxDebugReport::Context_Current) { auto saveLang = GUIPrefs::GetLangShort(); - GUIPrefs::InitLang( wxT("en") ); - auto cleanup = finally( [&]{ GUIPrefs::InitLang( saveLang ); } ); + GUIPrefs::SetLang( wxT("en") ); + auto cleanup = finally( [&]{ GUIPrefs::SetLang( saveLang ); } ); auto gAudioIO = AudioIOBase::Get(); rpt.AddText(wxT("audiodev.txt"), gAudioIO->GetDeviceInfo(), wxT("Audio Device Info")); diff --git a/src/effects/nyquist/Nyquist.cpp b/src/effects/nyquist/Nyquist.cpp index dfefef716..58dad2286 100644 --- a/src/effects/nyquist/Nyquist.cpp +++ b/src/effects/nyquist/Nyquist.cpp @@ -54,6 +54,7 @@ effects from this one class. #include "../EffectManager.h" #include "../../FileNames.h" #include "../../LabelTrack.h" +#include "../../Languages.h" #include "../../NoteTrack.h" #include "../../TimeTrack.h" #include "../../prefs/SpectrogramSettings.h" @@ -700,7 +701,9 @@ 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())? GUIPrefs::SetLang(lang) : lang; + lang = (lang.empty()) + ? Languages::GetSystemLanguageCode(FileNames::AudacityPathList()) + : lang; mProps += wxString::Format(wxT("(putprop '*AUDACITY* \"%s\" 'LANGUAGE)\n"), lang); mProps += wxString::Format(wxT("(setf *DECIMAL-SEPARATOR* #\\%c)\n"), wxNumberFormatter::GetDecimalSeparator()); diff --git a/src/prefs/GUIPrefs.cpp b/src/prefs/GUIPrefs.cpp index 9ed6c1ecf..e2790dc7c 100644 --- a/src/prefs/GUIPrefs.cpp +++ b/src/prefs/GUIPrefs.cpp @@ -254,22 +254,6 @@ bool GUIPrefs::Commit() return true; } -wxString GUIPrefs::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 = - Languages::GetSystemLanguageCode(FileNames::AudacityPathList()); - } - - // Initialize the language - return SetLang(langCode); -} - static std::unique_ptr sLocale; static wxString sLocaleName; diff --git a/src/prefs/GUIPrefs.h b/src/prefs/GUIPrefs.h index d4fa23b8f..b440b2d4d 100644 --- a/src/prefs/GUIPrefs.h +++ b/src/prefs/GUIPrefs.h @@ -40,11 +40,6 @@ class AUDACITY_DLL_API GUIPrefs final : public PrefsPanel int *pDefaultRangeIndex = nullptr ); - // 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. - static 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. static wxString SetLang( const wxString & lang );