diff options
author | Gavin Andresen <gavinandresen@gmail.com> | 2011-10-24 11:28:23 -0700 |
---|---|---|
committer | Gavin Andresen <gavinandresen@gmail.com> | 2011-10-24 11:28:23 -0700 |
commit | cf908574cf4c24fd1d7ba7f5e1d9ff577f0b0ad2 (patch) | |
tree | 749a36bc1eeb817c5428d2fde85319ba7166667b /src/qt | |
parent | 3a30f34f1adcd152fbc40e51c8e6ad0ff74a199f (diff) | |
parent | 5c92622ad631d3fea5f173e5c0267b9bd1b15b2d (diff) | |
download | bitcoin-cf908574cf4c24fd1d7ba7f5e1d9ff577f0b0ad2.tar.xz |
Merge pull request #591 from laanwj/translation_lookup_logic
Translation look-up logic improvements for Qt UI
Diffstat (limited to 'src/qt')
-rw-r--r-- | src/qt/bitcoin.cpp | 25 | ||||
-rw-r--r-- | src/qt/bitcoin.qrc | 9 |
2 files changed, 25 insertions, 9 deletions
diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index c8e332419c..86ac8a0271 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -118,14 +118,27 @@ int main(int argc, char *argv[]) Q_INIT_RESOURCE(bitcoin); QApplication app(argc, argv); - // Load language file for system locale - QString locale = QLocale::system().name(); - QTranslator qtTranslator; - qtTranslator.load(QLibraryInfo::location(QLibraryInfo::TranslationsPath) + "/qt_" + locale); + // Load language files for system locale: + // - First load the translator for the base language, without territory + // - Then load the more specific locale translator + 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()) 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()) app.installTranslator(&translator); diff --git a/src/qt/bitcoin.qrc b/src/qt/bitcoin.qrc index 2985bb60ef..145574df55 100644 --- a/src/qt/bitcoin.qrc +++ b/src/qt/bitcoin.qrc @@ -46,8 +46,11 @@ <file alias="update_spinner">res/movies/update_spinner.mng</file> </qresource> <qresource prefix="/translations"> - <file alias="de_DE">locale/bitcoin_de.qm</file> - <file alias="nl_NL">locale/bitcoin_nl.qm</file> - <file alias="ru_RU">locale/bitcoin_ru.qm</file> + <file alias="de">locale/bitcoin_de.qm</file> + <file alias="es">locale/bitcoin_es.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> </RCC> |