Load Qt library's translation
authorWuzzy <almikes@aol.com>
Sat, 21 Nov 2015 20:22:45 +0100
changeset 11488 637fb0558a73
parent 11414 6f119783a1ad
child 11489 84eb32d9e279
child 11490 fb7817a5c2b1
Load Qt library's translation
QTfrontend/main.cpp
--- a/QTfrontend/main.cpp	Thu Nov 19 13:30:34 2015 +0300
+++ b/QTfrontend/main.cpp	Sat Nov 21 20:22:45 2015 +0100
@@ -28,6 +28,7 @@
 #include <QDate>
 #include <QDesktopWidget>
 #include <QLabel>
+#include <QLibraryInfo>
 
 #include "hwform.h"
 #include "hwconsts.h"
@@ -318,7 +319,8 @@
     engine->setWriteDir(cfgdir->absolutePath());
     engine->mountPacks();
 
-    QTranslator Translator;
+    QTranslator TranslatorHedgewars;
+    QTranslator TranslatorQt;
     {
         QSettings settings(DataManager::instance().settingsFileName(), QSettings::IniFormat);
         settings.setIniCodec("UTF-8");
@@ -333,10 +335,13 @@
                 cc = HWApplication::keyboardInputLocale().name();
         }
 
-        // load locale file into translator
-        if (!Translator.load(QString("physfs://Locale/hedgewars_%1").arg(cc)))
-            qWarning("Failed to install translation (%s)", qPrintable(cc));
-        app.installTranslator(&Translator);
+        // Load locale files into translators
+        if (!TranslatorHedgewars.load(QString("physfs://Locale/hedgewars_%1").arg(cc)))
+            qWarning("Failed to install Hedgewars translation (%s)", qPrintable(cc));
+        if (!TranslatorQt.load(QString("%1/qt_%2").arg(QLibraryInfo::location(QLibraryInfo::TranslationsPath), cc)))
+            qWarning("Failed to install Qt translation (%s)", qPrintable(cc));
+        app.installTranslator(&TranslatorHedgewars);
+        app.installTranslator(&TranslatorQt);
         app.setLayoutDirection(QLocale(cc).textDirection());
     }