Merge pull request #1175 from Diapolo/translators
small translation-file handling / loading changes and re-work comments to be clearer
This commit is contained in:
commit
6672400206
1 changed files with 14 additions and 13 deletions
|
@ -187,30 +187,31 @@ int main(int argc, char *argv[])
|
||||||
// ... then GUI settings:
|
// ... then GUI settings:
|
||||||
OptionsModel optionsModel;
|
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()));
|
QString lang_territory = QString::fromStdString(GetArg("-lang", QLocale::system().name().toStdString()));
|
||||||
|
QString lang = lang_territory;
|
||||||
|
// Convert to "de" only by truncating "_DE"
|
||||||
|
lang.truncate(lang_territory.lastIndexOf('_'));
|
||||||
|
|
||||||
|
QTranslator qtTranslatorBase, qtTranslator, translatorBase, translator;
|
||||||
// Load language files for configured locale:
|
// Load language files for configured locale:
|
||||||
// - First load the translator for the base language, without territory
|
// - First load the translator for the base language, without territory
|
||||||
// - Then load the more specific locale translator
|
// - Then load the more specific locale translator
|
||||||
QString lang = lang_territory;
|
|
||||||
|
|
||||||
lang.truncate(lang_territory.lastIndexOf('_')); // "en"
|
// Load e.g. qt_de.qm
|
||||||
QTranslator qtTranslatorBase, qtTranslator, translatorBase, translator;
|
if (qtTranslatorBase.load("qt_" + lang, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
|
||||||
|
|
||||||
qtTranslatorBase.load(QLibraryInfo::location(QLibraryInfo::TranslationsPath) + "/qt_" + lang);
|
|
||||||
if (!qtTranslatorBase.isEmpty())
|
|
||||||
app.installTranslator(&qtTranslatorBase);
|
app.installTranslator(&qtTranslatorBase);
|
||||||
|
|
||||||
qtTranslator.load(QLibraryInfo::location(QLibraryInfo::TranslationsPath) + "/qt_" + lang_territory);
|
// Load e.g. qt_de_DE.qm
|
||||||
if (!qtTranslator.isEmpty())
|
if (qtTranslator.load("qt_" + lang_territory, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
|
||||||
app.installTranslator(&qtTranslator);
|
app.installTranslator(&qtTranslator);
|
||||||
|
|
||||||
translatorBase.load(":/translations/"+lang);
|
// Load e.g. bitcoin_de.qm (shortcut "de" needs to be defined in bitcoin.qrc)
|
||||||
if (!translatorBase.isEmpty())
|
if (translatorBase.load(lang, ":/translations/"))
|
||||||
app.installTranslator(&translatorBase);
|
app.installTranslator(&translatorBase);
|
||||||
|
|
||||||
translator.load(":/translations/"+lang_territory);
|
// Load e.g. bitcoin_de_DE.qm (shortcut "de_DE" needs to be defined in bitcoin.qrc)
|
||||||
if (!translator.isEmpty())
|
if (translator.load(lang_territory, ":/translations/"))
|
||||||
app.installTranslator(&translator);
|
app.installTranslator(&translator);
|
||||||
|
|
||||||
QSplashScreen splash(QPixmap(":/images/splash"), 0);
|
QSplashScreen splash(QPixmap(":/images/splash"), 0);
|
||||||
|
|
Loading…
Reference in a new issue