From 39c75948655f1bf0dfe8094d46f26e229c88f84f Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Sat, 12 Aug 2023 23:36:27 -0700 Subject: [PATCH 1/2] Mgr: compare best translations for selected languages --- clientgui/BOINCGUIApp.cpp | 42 ++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/clientgui/BOINCGUIApp.cpp b/clientgui/BOINCGUIApp.cpp index df9aa21bade..0cc2ff40a44 100644 --- a/clientgui/BOINCGUIApp.cpp +++ b/clientgui/BOINCGUIApp.cpp @@ -188,13 +188,11 @@ bool CBOINCGUIApp::OnInit() { SetAppDisplayName(wxString(displayName)); // {ass the display name to wxWidgets #endif - // Initialize the configuration storage module m_pConfig = new wxConfig(GetAppName()); wxConfigBase::Set(m_pConfig); wxASSERT(m_pConfig); - // Restore Application State m_pConfig->SetPath(wxT("/")); m_pConfig->Read(wxT("AutomaticallyShutdownClient"), &m_iShutdownCoreClient, 0L); @@ -204,23 +202,35 @@ bool CBOINCGUIApp::OnInit() { m_pConfig->Read(wxT("HideMenuBarIcon"), &m_iHideMenuBarIcon, 0L); #endif m_pConfig->Read(wxT("DisableAutoStart"), &m_iBOINCMGRDisableAutoStart, 0L); - m_pConfig->Read(wxT("LanguageISO"), &m_strISOLanguageCode, wxT("")); + m_pConfig->Read(wxT("LanguageISO"), &m_strISOLanguageCode, wxEmptyString); m_bUseDefaultLocale = false; bool bUseDefaultLocaleDefault = false; -#ifdef __WXMAC__ // wxLocale::GetLanguageInfo(wxLANGUAGE_DEFAULT) does not work on Mac - wxLocale *defaultLocale = new wxLocale; - defaultLocale->Init(wxLANGUAGE_DEFAULT); - wxString defaultLanguageCode = defaultLocale->GetCanonicalName(); - bUseDefaultLocaleDefault = m_strISOLanguageCode == defaultLanguageCode; - delete defaultLocale; -#else - const wxLanguageInfo *defaultLanguageInfo = wxLocale::GetLanguageInfo(wxLANGUAGE_DEFAULT); - if (defaultLanguageInfo != NULL) { - // Migration: assume a selected language code that matches the system default means "auto select" - bUseDefaultLocaleDefault = m_strISOLanguageCode == defaultLanguageInfo->CanonicalName;; + if (m_strISOLanguageCode.IsEmpty()) { + // If user has not selected a language, use automatic detection + m_bUseDefaultLocale = true; + } else { + wxLocale *defaultLocale = new wxLocale; + defaultLocale->Init(wxLANGUAGE_DEFAULT); + defaultLocale->AddCatalogLookupPathPrefix(wxT("locale")); + defaultLocale->AddCatalog(wxT("BOINC-Manager")); + wxTranslations* pTranslations = wxTranslations::Get(); + wxString defaultLanguageCode; + wxString selectedLanguageCode; + if (pTranslations) { + // Get best match from our available translations for automatic detection + defaultLanguageCode = pTranslations->GetBestTranslation(wxT("BOINC-Manager"), wxLANGUAGE_DEFAULT); +// selectedLanguageCode = pTranslations->GetBestTranslation(wxT("BOINC-Manager"), wxLANGUAGE_FRENCH_CHAD); + // Get best match from our available translations for the + // language the user selected from the Other Options dialog + selectedLanguageCode = pTranslations->GetBestTranslation(wxT("BOINC-Manager"), m_strISOLanguageCode); + } + bUseDefaultLocaleDefault = selectedLanguageCode == defaultLanguageCode; + delete defaultLocale; + // If upgrading from an older version of BOINC without the specific "Automatic Detection" + // as the first option in the language menu, use the value we just determined + m_pConfig->Read(wxT("UseDefaultLocale"), &m_bUseDefaultLocale, bUseDefaultLocaleDefault); } -#endif - m_pConfig->Read(wxT("UseDefaultLocale"), &m_bUseDefaultLocale, bUseDefaultLocaleDefault); + m_pConfig->Read(wxT("GUISelection"), &m_iGUISelected, BOINC_SIMPLEGUI); m_pConfig->Read(wxT("EventLogOpen"), &bOpenEventLog); m_pConfig->Read(wxT("RunDaemon"), &m_bRunDaemon, 1L); From eebeb832183a3899e4cf55ed92259975ea51b7a9 Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Sat, 12 Aug 2023 23:49:34 -0700 Subject: [PATCH 2/2] Remove test code --- clientgui/BOINCGUIApp.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/clientgui/BOINCGUIApp.cpp b/clientgui/BOINCGUIApp.cpp index 0cc2ff40a44..fcf935c050f 100644 --- a/clientgui/BOINCGUIApp.cpp +++ b/clientgui/BOINCGUIApp.cpp @@ -219,7 +219,6 @@ bool CBOINCGUIApp::OnInit() { if (pTranslations) { // Get best match from our available translations for automatic detection defaultLanguageCode = pTranslations->GetBestTranslation(wxT("BOINC-Manager"), wxLANGUAGE_DEFAULT); -// selectedLanguageCode = pTranslations->GetBestTranslation(wxT("BOINC-Manager"), wxLANGUAGE_FRENCH_CHAD); // Get best match from our available translations for the // language the user selected from the Other Options dialog selectedLanguageCode = pTranslations->GetBestTranslation(wxT("BOINC-Manager"), m_strISOLanguageCode);