1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-04-30 07:39:42 +02:00

Remove GUIPrefs::InitLang...

... Expand it in AudacityApp where initializing i18n services.

Just call SetLang directly in CrashReport, because the argument was not null.

Also eliminate call to SetLang in Nyquist, where really only the system language
was needed.
This commit is contained in:
Paul Licameli 2021-05-22 00:20:24 -04:00
parent ad5f895f65
commit 91e4eeadb8
5 changed files with 13 additions and 26 deletions

View File

@ -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)

View File

@ -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"));

View File

@ -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());

View File

@ -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<wxLocale> sLocale;
static wxString sLocaleName;

View File

@ -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 );