diff ui/administrator.cpp @ 420:16b6d5686835

Switch to resource based loading of translations
author Andre Heinecke <aheinecke@intevation.de>
date Wed, 16 Apr 2014 17:00:59 +0000
parents 09bb19e5e369
children 280f2556a48b
line wrap: on
line diff
--- a/ui/administrator.cpp	Wed Apr 16 16:05:46 2014 +0000
+++ b/ui/administrator.cpp	Wed Apr 16 17:00:59 2014 +0000
@@ -11,6 +11,8 @@
 #include <QtPlugin>
 #include <QMessageBox>
 #include <QSettings>
+#include <QTranslator>
+#include <QDebug>
 
 #ifndef VERSION
 #define VERSION "0.0.1"
@@ -41,6 +43,17 @@
     QApplication::setApplicationVersion(QString::fromLatin1(VERSION));
     QSettings::setDefaultFormat(QSettings::IniFormat);
 
+    QTranslator translator;
+    if (QLocale::system().name() == "C") {
+        /* Useful for testing / development as the primary target is german */
+        translator.load(":/l10n/administrator_de_DE");
+    } else {
+        translator.load(":/l10n/administrator_" + QLocale::system().name());
+        qDebug() << "Loading translations for: " << "administrator_" +
+            QLocale::system().name();
+    }
+    app.installTranslator(&translator);
+
     AdministratorWindow adminWin;
     adminWin.show();
 

http://wald.intevation.org/projects/trustbridge/