aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Kaufmann <phil.kaufmann@t-online.de>2012-05-01 17:54:07 +0200
committerPhilip Kaufmann <phil.kaufmann@t-online.de>2012-05-01 17:54:07 +0200
commitaab1f950aaa0f2123bdf2d18cd548709928f2ede (patch)
treef12137a1887368831b6a6d63bd8be5326dbefa23
parentbd51e8ef8a388bfd1a7c774fac8e68eefe12da32 (diff)
small translation-file handling / loading changes and re-work comments to be clearer
-rw-r--r--src/qt/bitcoin.cpp27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp
index 7c262e14cd..e752269ca1 100644
--- a/src/qt/bitcoin.cpp
+++ b/src/qt/bitcoin.cpp
@@ -187,30 +187,31 @@ int main(int argc, char *argv[])
// ... then GUI settings:
OptionsModel optionsModel;
- // Get desired locale ("en_US") from command line or system locale
+ // Get desired locale (e.g. "de_DE") from command line or use system locale
QString lang_territory = QString::fromStdString(GetArg("-lang", QLocale::system().name().toStdString()));
- // Load language files for configured locale:
- // - First load the translator for the base language, without territory
- // - Then load the more specific locale translator
QString lang = lang_territory;
+ // Convert to "de" only by truncating "_DE"
+ lang.truncate(lang_territory.lastIndexOf('_'));
- lang.truncate(lang_territory.lastIndexOf('_')); // "en"
QTranslator qtTranslatorBase, qtTranslator, translatorBase, translator;
+ // Load language files for configured locale:
+ // - First load the translator for the base language, without territory
+ // - Then load the more specific locale translator
- qtTranslatorBase.load(QLibraryInfo::location(QLibraryInfo::TranslationsPath) + "/qt_" + lang);
- if (!qtTranslatorBase.isEmpty())
+ // Load e.g. qt_de.qm
+ if (qtTranslatorBase.load("qt_" + lang, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
app.installTranslator(&qtTranslatorBase);
- qtTranslator.load(QLibraryInfo::location(QLibraryInfo::TranslationsPath) + "/qt_" + lang_territory);
- if (!qtTranslator.isEmpty())
+ // Load e.g. qt_de_DE.qm
+ if (qtTranslator.load("qt_" + lang_territory, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
app.installTranslator(&qtTranslator);
- translatorBase.load(":/translations/"+lang);
- if (!translatorBase.isEmpty())
+ // Load e.g. bitcoin_de.qm (shortcut "de" needs to be defined in bitcoin.qrc)
+ if (translatorBase.load(lang, ":/translations/"))
app.installTranslator(&translatorBase);
- translator.load(":/translations/"+lang_territory);
- if (!translator.isEmpty())
+ // Load e.g. bitcoin_de_DE.qm (shortcut "de_DE" needs to be defined in bitcoin.qrc)
+ if (translator.load(lang_territory, ":/translations/"))
app.installTranslator(&translator);
QSplashScreen splash(QPixmap(":/images/splash"), 0);