bool PGM_BASE::SetLanguage( bool first_time ) { bool retv = true; // dictionary file name without extend (full name is kicad.mo) wxString dictionaryName( wxT( "kicad" ) ); delete m_locale; m_locale = new wxLocale; #if wxCHECK_VERSION( 2, 9, 0 ) if( !m_locale->Init( m_language_id ) ) #else if( !m_locale->Init( m_language_id, wxLOCALE_CONV_ENCODING ) ) #endif { wxLogDebug( wxT( "This language is not supported by the system." ) ); setLanguageId( wxLANGUAGE_DEFAULT ); delete m_locale; m_locale = new wxLocale; m_locale->Init(); retv = false; } else if( !first_time ) { wxLogDebug( wxT( "Search for dictionary %s.mo in %s" ), GetChars( dictionaryName ), GetChars( m_locale->GetName() ) ); } // how about a meaningful comment here. if( !first_time ) { wxString languageSel; // Search for the current selection for( unsigned ii = 0; ii < DIM( s_Languages ); ii++ ) { if( s_Languages[ii].m_WX_Lang_Identifier == m_language_id ) { languageSel = s_Languages[ii].m_Lang_Label; break; } } m_common_settings->Write( languageCfgKey, languageSel ); } // Test if floating point notation is working (bug in cross compilation, using wine) // Make a conversion double <=> string double dtst = 0.5; wxString msg; extern bool g_DisableFloatingPointLocalNotation; // See common.cpp g_DisableFloatingPointLocalNotation = false; msg << dtst; double result; msg.ToDouble( &result ); if( result != dtst ) // string to double encode/decode does not work! Bug detected { // Disable floating point localization: g_DisableFloatingPointLocalNotation = true; SetLocaleTo_C_standard( ); } if( !m_locale->IsLoaded( dictionaryName ) ) m_locale->AddCatalog( dictionaryName ); if( !retv ) return retv; return m_locale->IsOk(); }
bool PGM_BASE::SetLanguage( bool first_time ) { bool retv = true; if( first_time ) { setLanguageId( wxLANGUAGE_DEFAULT ); // First time SetLanguage is called, the user selected language id is set // from commun user config settings wxString languageSel; m_common_settings->Read( languageCfgKey, &languageSel ); // Search for the current selection for( unsigned ii = 0; ii < DIM( s_Languages ); ii++ ) { if( s_Languages[ii].m_Lang_Label == languageSel ) { setLanguageId( s_Languages[ii].m_WX_Lang_Identifier ); break; } } } // dictionary file name without extend (full name is kicad.mo) wxString dictionaryName( wxT( "kicad" ) ); delete m_locale; m_locale = new wxLocale; if( !m_locale->Init( m_language_id ) ) { wxLogDebug( wxT( "This language is not supported by the system." ) ); setLanguageId( wxLANGUAGE_DEFAULT ); delete m_locale; m_locale = new wxLocale; m_locale->Init(); retv = false; } else if( !first_time ) { wxLogDebug( wxT( "Search for dictionary %s.mo in %s" ), GetChars( dictionaryName ), GetChars( m_locale->GetName() ) ); } if( !first_time ) { // If we are here, the user has selected an other language. // Therefore the new prefered language name is stored in common config. // Do NOT store the wxWidgets language Id, it can change between wxWidgets // versions, for a given language wxString languageSel; // Search for the current selection for( unsigned ii = 0; ii < DIM( s_Languages ); ii++ ) { if( s_Languages[ii].m_WX_Lang_Identifier == m_language_id ) { languageSel = s_Languages[ii].m_Lang_Label; break; } } m_common_settings->Write( languageCfgKey, languageSel ); } // Test if floating point notation is working (bug in cross compilation, using wine) // Make a conversion double <=> string double dtst = 0.5; wxString msg; extern bool g_DisableFloatingPointLocalNotation; // See common.cpp g_DisableFloatingPointLocalNotation = false; msg << dtst; double result; msg.ToDouble( &result ); if( result != dtst ) // string to double encode/decode does not work! Bug detected { // Disable floating point localization: g_DisableFloatingPointLocalNotation = true; SetLocaleTo_C_standard( ); } if( !m_locale->IsLoaded( dictionaryName ) ) m_locale->AddCatalog( dictionaryName ); if( !retv ) return retv; return m_locale->IsOk(); }