mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 15:24:05 +00:00
+ Localizations are not hardcoded anymore -- all translation files that exist
in the current installation get into the list now. + Chinese translation added (thanks to Satoshi Joh) + Czech translation added (thanks to Vit Pelcak)
This commit is contained in:
parent
ba1292607f
commit
f7d47163d3
|
@ -973,4 +973,12 @@ QString getProgramDataDir() throw()
|
|||
#endif
|
||||
}
|
||||
|
||||
QString getLocDir() throw()
|
||||
{
|
||||
if ( QDir( getProgramDataDir() ).cd( "locale" ) )
|
||||
return getProgramDataDir() + "/locale";
|
||||
else
|
||||
return QCoreApplication::applicationDirPath() + "/locale";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -332,6 +332,8 @@ QString getUserQtCssFileName() throw( exError );
|
|||
/// /usr/share/apps/goldendict, under Windows C:/Program Files/GoldenDict.
|
||||
QString getProgramDataDir() throw();
|
||||
|
||||
/// Returns the directory storing program localizized files (.qm).
|
||||
QString getLocDir() throw();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -193,20 +193,17 @@ win32 {
|
|||
}
|
||||
RESOURCES += resources.qrc \
|
||||
flags.qrc
|
||||
TRANSLATIONS += locale/ru.ts
|
||||
TRANSLATIONS += locale/ru_RU.ts locale/zh_CN.ts locale/cs_CZ.ts
|
||||
|
||||
# This makes qmake generate translations
|
||||
isEmpty(QMAKE_LRELEASE):QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease
|
||||
updateqm.input = TRANSLATIONS
|
||||
updateqm.output = ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}.qm
|
||||
updateqm.commands = $$QMAKE_LRELEASE ${QMAKE_FILE_IN} -qm ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}.qm
|
||||
updateqm.CONFIG += no_link
|
||||
QMAKE_EXTRA_COMPILERS += updateqm
|
||||
TS_OUT = $$TRANSLATIONS
|
||||
TS_OUT ~= s/.ts/.qm
|
||||
TSQM.name = lrelease \
|
||||
${QMAKE_FILE_IN}
|
||||
TSQM.input = TRANSLATIONS
|
||||
TSQM.output = $$TS_OUT
|
||||
TSQM.commands = $$QMAKE_LRELEASE \
|
||||
${QMAKE_FILE_IN}
|
||||
TSQM.CONFIG = no_link
|
||||
QMAKE_EXTRA_COMPILERS += TSQM
|
||||
TS_OUT ~= s/.ts/.qm/g
|
||||
PRE_TARGETDEPS += $$TS_OUT
|
||||
|
||||
# LibZip
|
||||
|
|
2865
src/locale/cs_CZ.ts
Normal file
2865
src/locale/cs_CZ.ts
Normal file
File diff suppressed because it is too large
Load diff
2050
src/locale/zh_CN.ts
Normal file
2050
src/locale/zh_CN.ts
Normal file
File diff suppressed because it is too large
Load diff
|
@ -106,8 +106,7 @@ int main( int argc, char ** argv )
|
|||
|
||||
QTranslator translator;
|
||||
|
||||
if ( !translator.load( QString( Config::getProgramDataDir() ) + "/locale/" + localeName ) )
|
||||
translator.load( QCoreApplication::applicationDirPath() + "/locale/" + localeName );
|
||||
translator.load( Config::getLocDir() + "/" + localeName );
|
||||
|
||||
app.installTranslator( &translator );
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "preferences.hh"
|
||||
#include "keyboardstate.hh"
|
||||
#include "language.hh"
|
||||
#include "langcoder.hh"
|
||||
#include <QMessageBox>
|
||||
|
||||
Preferences::Preferences( QWidget * parent, Config::Preferences const & p ):
|
||||
|
@ -36,8 +38,28 @@ Preferences::Preferences( QWidget * parent, Config::Preferences const & p ):
|
|||
// Load values into form
|
||||
|
||||
ui.interfaceLanguage->addItem( tr( "System default" ), QString() );
|
||||
ui.interfaceLanguage->addItem( QIcon( ":/flags/us.png" ), tr( "English" ), QString( "en_US" ) );
|
||||
ui.interfaceLanguage->addItem( QIcon( ":/flags/ru.png" ), tr( "Russian" ), QString( "ru_RU" ) );
|
||||
ui.interfaceLanguage->addItem( QIcon( ":/flags/us.png" ), Language::localizedNameForId( LangCoder::code2toInt( "en" ) ), QString( "en_US" ) );
|
||||
|
||||
// See which other translations do we have
|
||||
|
||||
QStringList availLocs = QDir( Config::getLocDir() ).entryList( QStringList( "*.qm" ),
|
||||
QDir::Files );
|
||||
|
||||
// We need to sort by language name -- otherwise list looks really weird
|
||||
QMap< QString, QPair< QIcon, QString > > sortedLocs;
|
||||
|
||||
for( QStringList::iterator i = availLocs.begin(); i != availLocs.end(); ++i )
|
||||
{
|
||||
// Here we assume the xx_YY naming, where xx is language and YY is region.
|
||||
QString lang = i->mid( 0, 2 );
|
||||
sortedLocs[ Language::localizedNameForId( LangCoder::code2toInt( lang.toAscii().data() ) ) ]
|
||||
= QPair< QIcon, QString >( QIcon( QString( ":/flags/%1.png" ).arg( i->mid( 3, 2 ).toLower() ) ),
|
||||
i->mid( 0, i->size() - 3 ) );
|
||||
}
|
||||
|
||||
for( QMap< QString, QPair< QIcon, QString > >::iterator i = sortedLocs.begin();
|
||||
i != sortedLocs.end(); ++i )
|
||||
ui.interfaceLanguage->addItem( i.value().first, i.key(), i.value().second );
|
||||
|
||||
for( int x = 0; x < ui.interfaceLanguage->count(); ++x )
|
||||
if ( ui.interfaceLanguage->itemData( x ).toString() == p.interfaceLanguage )
|
||||
|
|
Loading…
Reference in a new issue