From 77ad8427d2c6a6d00846bce512edcea281c8a0c0 Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Wed, 18 Jun 2014 11:14:29 -0400 Subject: [PATCH] MGR: Reset everybody's language selection back to the default OS UI locale, in the future use the ISO language code to determine which locale to use for the manager. --- clientgui/BOINCBaseFrame.cpp | 5 ----- clientgui/BOINCBaseFrame.h | 3 --- clientgui/BOINCGUIApp.cpp | 15 ++++++++++----- clientgui/BOINCGUIApp.h | 2 ++ clientgui/DlgOptions.cpp | 6 +++--- 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/clientgui/BOINCBaseFrame.cpp b/clientgui/BOINCBaseFrame.cpp index 01c7fd7a1d..ae2b9ae556 100644 --- a/clientgui/BOINCBaseFrame.cpp +++ b/clientgui/BOINCBaseFrame.cpp @@ -75,7 +75,6 @@ CBOINCBaseFrame::CBOINCBaseFrame(wxWindow* parent, const wxWindowID id, const wx wxLogTrace(wxT("Function Start/End"), wxT("CBOINCBaseFrame::CBOINCBaseFrame - Function Begin")); // Configuration Settings - m_iSelectedLanguage = 0; m_iReminderFrequency = 0; m_strNetworkDialupConnectionName = wxEmptyString; m_aSelectedComputerMRU.Clear(); @@ -771,9 +770,7 @@ bool CBOINCBaseFrame::SaveState() { // pConfig->SetPath(strBaseConfigLocation); - pConfig->Write(wxT("Language"), m_iSelectedLanguage); pConfig->Write(wxT("ReminderFrequencyV3"), m_iReminderFrequency); - pConfig->Write(wxT("NetworkDialupConnectionName"), m_strNetworkDialupConnectionName); @@ -828,9 +825,7 @@ bool CBOINCBaseFrame::RestoreState() { // pConfig->SetPath(strBaseConfigLocation); - pConfig->Read(wxT("Language"), &m_iSelectedLanguage, 0L); pConfig->Read(wxT("ReminderFrequencyV3"), &m_iReminderFrequency, 360L); - pConfig->Read(wxT("NetworkDialupConnectionName"), &m_strNetworkDialupConnectionName, wxEmptyString); diff --git a/clientgui/BOINCBaseFrame.h b/clientgui/BOINCBaseFrame.h index 37d4fcf27d..abc3694f2a 100644 --- a/clientgui/BOINCBaseFrame.h +++ b/clientgui/BOINCBaseFrame.h @@ -69,8 +69,6 @@ public: CBOINCDialUpManager* GetDialupManager() { return m_pDialupManager; } int GetReminderFrequency() { return m_iReminderFrequency; } void SetReminderFrequency(int val) { m_iReminderFrequency = val; } - int GetSelectedLanguage() { return m_iSelectedLanguage; } - void SetSelectedLanguage(int val) { m_iSelectedLanguage = val; } void FireInitialize(); void FireRefreshView(); @@ -111,7 +109,6 @@ protected: wxTimer* m_pAlertPollTimer; wxTimer* m_pPeriodicRPCTimer; - int m_iSelectedLanguage; int m_iReminderFrequency; int m_iFrameRefreshRate; diff --git a/clientgui/BOINCGUIApp.cpp b/clientgui/BOINCGUIApp.cpp index e2d578f21d..7fb3e48c32 100644 --- a/clientgui/BOINCGUIApp.cpp +++ b/clientgui/BOINCGUIApp.cpp @@ -154,7 +154,6 @@ bool CBOINCGUIApp::OnInit() { // Initialize local variables int iErrorCode = 0; - int iSelectedLanguage = 0; bool bOpenEventLog = false; wxString strDesiredSkinName = wxEmptyString; wxString strDialogMessage = wxEmptyString; @@ -212,7 +211,7 @@ bool CBOINCGUIApp::OnInit() { m_pConfig->Read(wxT("AutomaticallyShutdownClient"), &m_iShutdownCoreClient, 0L); m_pConfig->Read(wxT("DisplayShutdownClientDialog"), &m_iDisplayExitDialog, 1L); m_pConfig->Read(wxT("DisableAutoStart"), &m_iBOINCMGRDisableAutoStart, 0L); - m_pConfig->Read(wxT("Language"), &iSelectedLanguage, 0L); + m_pConfig->Read(wxT("LanguageISO"), &m_strISOLanguageCode, wxT("")); m_pConfig->Read(wxT("GUISelection"), &m_iGUISelected, BOINC_SIMPLEGUI); m_pConfig->Read(wxT("EventLogOpen"), &bOpenEventLog); @@ -276,9 +275,16 @@ bool CBOINCGUIApp::OnInit() { m_pLocale = new wxLocale(); wxASSERT(m_pLocale); + // + if (m_strISOLanguageCode.IsEmpty()) { + m_pLocale->Init(wxLANGUAGE_DEFAULT); + m_strISOLanguageCode = m_pLocale->GetCanonicalName(); + } else { + m_pLocale->Init(wxLocale::FindLanguageInfo(m_strISOLanguageCode)->Language); + } + // Look for the localization files by absolute and relative locations. // preference given to the absolute location. - m_pLocale->Init(iSelectedLanguage); if (!m_strBOINCMGRRootDirectory.IsEmpty()) { m_pLocale->AddCatalogLookupPathPrefix( wxString(m_strBOINCMGRRootDirectory + wxT("locale")) @@ -291,8 +297,6 @@ bool CBOINCGUIApp::OnInit() { InitSupportedLanguages(); - m_strISOLanguageCode = m_pLocale->GetCanonicalName(); - // Note: JAWS for Windows will only speak the context-sensitive // help if you use this help provider: wxHelpProvider::Set(new wxHelpControllerHelpProvider()); @@ -604,6 +608,7 @@ void CBOINCGUIApp::SaveState() { if (m_pSkinManager) { m_pConfig->Write(wxT("Skin"), m_pSkinManager->GetSelectedSkin()); } + m_pConfig->Write(wxT("LanguageISO"), m_strISOLanguageCode); m_pConfig->Write(wxT("AutomaticallyShutdownClient"), m_iShutdownCoreClient); m_pConfig->Write(wxT("DisplayShutdownClientDialog"), m_iDisplayExitDialog); m_pConfig->Write(wxT("DisableAutoStart"), m_iBOINCMGRDisableAutoStart); diff --git a/clientgui/BOINCGUIApp.h b/clientgui/BOINCGUIApp.h index 6a0c46f13e..6990d9d7a3 100644 --- a/clientgui/BOINCGUIApp.h +++ b/clientgui/BOINCGUIApp.h @@ -158,6 +158,8 @@ public: wxArrayString& GetSupportedLanguages() { return m_astrLanguages; } wxString GetISOLanguageCode() { return m_strISOLanguageCode; } + void SetISOLanguageCode(wxString strISOLanguageCode) + { m_strISOLanguageCode = strISOLanguageCode; } void DisplayEventLog(bool bShowWindow = true); void OnEventLogClose(); diff --git a/clientgui/DlgOptions.cpp b/clientgui/DlgOptions.cpp index 8847b8e635..8f881def2a 100755 --- a/clientgui/DlgOptions.cpp +++ b/clientgui/DlgOptions.cpp @@ -584,7 +584,7 @@ bool CDlgOptions::ReadSettings() { // General Tab m_LanguageSelectionCtrl->Append(wxGetApp().GetSupportedLanguages()); - m_LanguageSelectionCtrl->SetSelection(pFrame->GetSelectedLanguage()); + m_LanguageSelectionCtrl->SetSelection(wxLocale::FindLanguageInfo(wxGetApp().GetISOLanguageCode())->Language); m_ReminderFrequencyCtrl->Append(_("always")); m_ReminderFrequencyCtrl->Append(_("1 hour")); @@ -681,7 +681,7 @@ bool CDlgOptions::SaveSettings() { // General Tab - if (pFrame->GetSelectedLanguage() != m_LanguageSelectionCtrl->GetSelection()) { + if (wxLocale::FindLanguageInfo(wxGetApp().GetISOLanguageCode())->Language != m_LanguageSelectionCtrl->GetSelection()) { wxString strDialogTitle; wxString strDialogMessage; @@ -707,7 +707,7 @@ bool CDlgOptions::SaveSettings() { ); } - pFrame->SetSelectedLanguage(m_LanguageSelectionCtrl->GetSelection()); + wxGetApp().SetISOLanguageCode(wxLocale::GetLanguageInfo(m_LanguageSelectionCtrl->GetSelection())->CanonicalName); switch(m_ReminderFrequencyCtrl->GetSelection()) { case 0: