bool EffectsPrefs::Apply() { ShuttleGui S(this, eIsSavingToPrefs); PopulateOrExchange(S); // 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); return true; }
//--------------------------------------------------------------------------------------- DlgChooseLanguage::DlgChooseLanguage(wxWindow* parent, wxWindowID id, const wxString& title) : wxDialog(parent, id, title) { GetLanguages(m_cLangCodes, m_cLangNames); m_nNumLangs = m_cLangNames.GetCount(); wxString sysLang = GetSystemLanguageCode(); wxBoxSizer *mainSizer = LENMUS_NEW wxBoxSizer(wxVERTICAL); wxBoxSizer *hSizer; hSizer = LENMUS_NEW wxBoxSizer(wxHORIZONTAL); hSizer->Add(LENMUS_NEW wxStaticText(this, -1, _("Choose language to use:")), 0, wxALIGN_CENTRE | wxALIGN_CENTER_VERTICAL | wxALL, 8); wxString *langArray = LENMUS_NEW wxString[m_nNumLangs]; for(int i=0; i < m_nNumLangs; i++) langArray[i] = m_cLangNames[i]; m_pChoice = LENMUS_NEW wxChoice(this, -1, wxDefaultPosition, wxDefaultSize, m_nNumLangs, langArray); m_pChoice->SetSelection(0); // in case nothing else matches delete[] langArray; for(int i=0; i < m_nNumLangs; i++) { if (m_cLangCodes[i] == sysLang) m_pChoice->SetSelection(i); } hSizer->Add(m_pChoice, 0, wxALIGN_CENTRE | wxALIGN_CENTER_VERTICAL | wxALL, 8); mainSizer->Add(hSizer, 0, wxALL, 8); wxButton *ok = LENMUS_NEW wxButton(this, wxID_OK, _("OK")); ok->SetDefault(); mainSizer->Add(ok, 0, wxALIGN_CENTRE | wxALL, 8); SetAutoLayout(true); SetSizer(mainSizer); mainSizer->Fit(this); mainSizer->SetSizeHints(this); // set default language, just in case user closes the dialog by clicking on // the dialog title [X] button m_sLang = m_cLangCodes[m_pChoice->GetSelection()]; }