Skip to content

Commit

Permalink
Mgr: compare best translations for selected languages
Browse files Browse the repository at this point in the history
  • Loading branch information
Charlie Fenton committed Aug 13, 2023
1 parent b2a5bbc commit 39c7594
Showing 1 changed file with 26 additions and 16 deletions.
42 changes: 26 additions & 16 deletions clientgui/BOINCGUIApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 39c7594

Please sign in to comment.