Merge pull request #591 from laanwj/translation_lookup_logic
Translation look-up logic improvements for Qt UI
This commit is contained in:
commit
cf908574cf
3 changed files with 27 additions and 13 deletions
|
@ -175,10 +175,8 @@ FORMS += \
|
||||||
CODECFORTR = UTF-8
|
CODECFORTR = UTF-8
|
||||||
|
|
||||||
# for lrelease/lupdate
|
# for lrelease/lupdate
|
||||||
TRANSLATIONS = src/qt/locale/bitcoin_de.ts \
|
# also add new translations to src/qt/bitcoin.qrc under translations/
|
||||||
src/qt/locale/bitcoin_es.ts \
|
TRANSLATIONS = $$files(src/qt/locale/bitcoin_*.ts)
|
||||||
src/qt/locale/bitcoin_nl.ts \
|
|
||||||
src/qt/locale/bitcoin_ru.ts
|
|
||||||
|
|
||||||
isEmpty(QMAKE_LRELEASE) {
|
isEmpty(QMAKE_LRELEASE) {
|
||||||
win32:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]\lrelease.exe
|
win32:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]\lrelease.exe
|
||||||
|
|
|
@ -118,14 +118,27 @@ int main(int argc, char *argv[])
|
||||||
Q_INIT_RESOURCE(bitcoin);
|
Q_INIT_RESOURCE(bitcoin);
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
|
|
||||||
// Load language file for system locale
|
// Load language files for system locale:
|
||||||
QString locale = QLocale::system().name();
|
// - First load the translator for the base language, without territory
|
||||||
QTranslator qtTranslator;
|
// - Then load the more specific locale translator
|
||||||
qtTranslator.load(QLibraryInfo::location(QLibraryInfo::TranslationsPath) + "/qt_" + locale);
|
QString lang_territory = QLocale::system().name(); // "en_US"
|
||||||
|
QString lang = lang_territory;
|
||||||
|
lang.truncate(lang_territory.lastIndexOf('_')); // "en"
|
||||||
|
QTranslator qtTranslatorBase, qtTranslator, translatorBase, translator;
|
||||||
|
|
||||||
|
qtTranslatorBase.load(QLibraryInfo::location(QLibraryInfo::TranslationsPath) + "/qt_" + lang);
|
||||||
|
if (!qtTranslatorBase.isEmpty())
|
||||||
|
app.installTranslator(&qtTranslatorBase);
|
||||||
|
|
||||||
|
qtTranslator.load(QLibraryInfo::location(QLibraryInfo::TranslationsPath) + "/qt_" + lang_territory);
|
||||||
if (!qtTranslator.isEmpty())
|
if (!qtTranslator.isEmpty())
|
||||||
app.installTranslator(&qtTranslator);
|
app.installTranslator(&qtTranslator);
|
||||||
QTranslator translator;
|
|
||||||
translator.load(":/translations/"+locale);
|
translatorBase.load(":/translations/"+lang);
|
||||||
|
if (!translatorBase.isEmpty())
|
||||||
|
app.installTranslator(&translatorBase);
|
||||||
|
|
||||||
|
translator.load(":/translations/"+lang_territory);
|
||||||
if (!translator.isEmpty())
|
if (!translator.isEmpty())
|
||||||
app.installTranslator(&translator);
|
app.installTranslator(&translator);
|
||||||
|
|
||||||
|
|
|
@ -46,8 +46,11 @@
|
||||||
<file alias="update_spinner">res/movies/update_spinner.mng</file>
|
<file alias="update_spinner">res/movies/update_spinner.mng</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
<qresource prefix="/translations">
|
<qresource prefix="/translations">
|
||||||
<file alias="de_DE">locale/bitcoin_de.qm</file>
|
<file alias="de">locale/bitcoin_de.qm</file>
|
||||||
<file alias="nl_NL">locale/bitcoin_nl.qm</file>
|
<file alias="es">locale/bitcoin_es.qm</file>
|
||||||
<file alias="ru_RU">locale/bitcoin_ru.qm</file>
|
<file alias="es_CL">locale/bitcoin_es_CL.qm</file>
|
||||||
|
<file alias="nb">locale/bitcoin_nb.qm</file>
|
||||||
|
<file alias="nl">locale/bitcoin_nl.qm</file>
|
||||||
|
<file alias="ru">locale/bitcoin_ru.qm</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
Loading…
Reference in a new issue