mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 15:24:05 +00:00
optimize:translator refactor
This commit is contained in:
parent
2a08b6290e
commit
c8284297dd
|
@ -460,6 +460,6 @@ QString localizedStringForId( Id langId )
|
|||
if( iconId.isEmpty() )
|
||||
return name;
|
||||
else
|
||||
return QString( "<img src=\":/flags/%1.png\"> %2" ).arg( iconId ).arg( name );
|
||||
return QString( "<img src=\":/flags/%1.png\"> %2" ).arg( iconId , name );
|
||||
}
|
||||
}
|
||||
|
|
45
main.cc
45
main.cc
|
@ -328,23 +328,8 @@ int main( int argc, char ** argv )
|
|||
#endif
|
||||
|
||||
// Load translations for system locale
|
||||
|
||||
QTranslator qtTranslator;
|
||||
|
||||
QString localeName = QLocale::system().name();
|
||||
|
||||
if ( !qtTranslator.load( "qt_" + localeName, Config::getLocDir() ) )
|
||||
qtTranslator.load( "qt_" + localeName,
|
||||
QLibraryInfo::location( QLibraryInfo::TranslationsPath ) );
|
||||
|
||||
app.installTranslator( &qtTranslator );
|
||||
|
||||
QTranslator translator;
|
||||
|
||||
translator.load( Config::getLocDir() + "/" + localeName );
|
||||
|
||||
app.installTranslator( &translator );
|
||||
|
||||
Config::Class cfg;
|
||||
for( ; ; )
|
||||
{
|
||||
|
@ -395,16 +380,36 @@ int main( int argc, char ** argv )
|
|||
}
|
||||
|
||||
// Reload translations for user selected locale is nesessary
|
||||
|
||||
QTranslator qtTranslator;
|
||||
QTranslator translator;
|
||||
if( !cfg.preferences.interfaceLanguage.isEmpty() && localeName != cfg.preferences.interfaceLanguage )
|
||||
{
|
||||
localeName = cfg.preferences.interfaceLanguage;
|
||||
|
||||
if ( !qtTranslator.load( "qt_" + localeName, Config::getLocDir() ) )
|
||||
qtTranslator.load( "qt_" + localeName,
|
||||
QLibraryInfo::location( QLibraryInfo::TranslationsPath ) );
|
||||
QLocale locale( localeName );
|
||||
QLocale::setDefault( locale );
|
||||
if( !qtTranslator.load( "qt_" + localeName, Config::getLocDir() ) )
|
||||
{
|
||||
qtTranslator.load( "qt_" + localeName, QLibraryInfo::location( QLibraryInfo::TranslationsPath ) );
|
||||
app.installTranslator( &qtTranslator );
|
||||
}
|
||||
|
||||
translator.load( Config::getLocDir() + "/" + localeName );
|
||||
app.installTranslator( &translator );
|
||||
}
|
||||
else
|
||||
{
|
||||
QString localeName = QLocale::system().name();
|
||||
|
||||
|
||||
if( !qtTranslator.load( "qt_" + localeName, Config::getLocDir() ) )
|
||||
{
|
||||
qtTranslator.load( "qt_" + localeName, QLibraryInfo::location( QLibraryInfo::TranslationsPath ) );
|
||||
|
||||
app.installTranslator( &qtTranslator );
|
||||
}
|
||||
|
||||
translator.load( Config::getLocDir() + "/" + localeName );
|
||||
app.installTranslator( &translator );
|
||||
}
|
||||
|
||||
// Prevent app from quitting spontaneously when it works with scan popup
|
||||
|
|
Loading…
Reference in a new issue