mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 00:14:06 +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
|
#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.
|
/// /usr/share/apps/goldendict, under Windows C:/Program Files/GoldenDict.
|
||||||
QString getProgramDataDir() throw();
|
QString getProgramDataDir() throw();
|
||||||
|
|
||||||
|
/// Returns the directory storing program localizized files (.qm).
|
||||||
|
QString getLocDir() throw();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -193,20 +193,17 @@ win32 {
|
||||||
}
|
}
|
||||||
RESOURCES += resources.qrc \
|
RESOURCES += resources.qrc \
|
||||||
flags.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
|
# This makes qmake generate translations
|
||||||
isEmpty(QMAKE_LRELEASE):QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease
|
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 = $$TRANSLATIONS
|
||||||
TS_OUT ~= s/.ts/.qm
|
TS_OUT ~= s/.ts/.qm/g
|
||||||
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
|
|
||||||
PRE_TARGETDEPS += $$TS_OUT
|
PRE_TARGETDEPS += $$TS_OUT
|
||||||
|
|
||||||
# LibZip
|
# 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;
|
QTranslator translator;
|
||||||
|
|
||||||
if ( !translator.load( QString( Config::getProgramDataDir() ) + "/locale/" + localeName ) )
|
translator.load( Config::getLocDir() + "/" + localeName );
|
||||||
translator.load( QCoreApplication::applicationDirPath() + "/locale/" + localeName );
|
|
||||||
|
|
||||||
app.installTranslator( &translator );
|
app.installTranslator( &translator );
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include "preferences.hh"
|
#include "preferences.hh"
|
||||||
#include "keyboardstate.hh"
|
#include "keyboardstate.hh"
|
||||||
|
#include "language.hh"
|
||||||
|
#include "langcoder.hh"
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
Preferences::Preferences( QWidget * parent, Config::Preferences const & p ):
|
Preferences::Preferences( QWidget * parent, Config::Preferences const & p ):
|
||||||
|
@ -36,8 +38,28 @@ Preferences::Preferences( QWidget * parent, Config::Preferences const & p ):
|
||||||
// Load values into form
|
// Load values into form
|
||||||
|
|
||||||
ui.interfaceLanguage->addItem( tr( "System default" ), QString() );
|
ui.interfaceLanguage->addItem( tr( "System default" ), QString() );
|
||||||
ui.interfaceLanguage->addItem( QIcon( ":/flags/us.png" ), tr( "English" ), QString( "en_US" ) );
|
ui.interfaceLanguage->addItem( QIcon( ":/flags/us.png" ), Language::localizedNameForId( LangCoder::code2toInt( "en" ) ), QString( "en_US" ) );
|
||||||
ui.interfaceLanguage->addItem( QIcon( ":/flags/ru.png" ), tr( "Russian" ), QString( "ru_RU" ) );
|
|
||||||
|
// 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 )
|
for( int x = 0; x < ui.interfaceLanguage->count(); ++x )
|
||||||
if ( ui.interfaceLanguage->itemData( x ).toString() == p.interfaceLanguage )
|
if ( ui.interfaceLanguage->itemData( x ).toString() == p.interfaceLanguage )
|
||||||
|
|
Loading…
Reference in a new issue