diff ui/main.cpp @ 423:3d1e9df24803

Add translation loading
author Andre Heinecke <aheinecke@intevation.de>
date Wed, 16 Apr 2014 17:11:18 +0000
parents 09bb19e5e369
children 0f4331ed4e83
line wrap: on
line diff
--- a/ui/main.cpp	Wed Apr 16 17:06:45 2014 +0000
+++ b/ui/main.cpp	Wed Apr 16 17:11:18 2014 +0000
@@ -12,6 +12,8 @@
 #include <QtPlugin>
 #include <QMessageBox>
 #include <QSettings>
+#include <QDebug>
+#include <QTranslator>
 
 #ifndef VERSION
 #define VERSION "0.0.1"
@@ -38,6 +40,17 @@
     QStringList arguments = QApplication::arguments();
     bool trayMode = arguments.contains("--tray");
 
+    QTranslator translator;
+    if (QLocale::system().name() == "C") {
+        /* Useful for testing / development as the primary target is german */
+        translator.load(":/l10n/trustbridge_de_DE");
+    } else {
+        translator.load(":/l10n/trustbridge_" + QLocale::system().name());
+        qDebug() << "Loading translations for: " << "trustbridge_" +
+            QLocale::system().name();
+    }
+    app.installTranslator(&translator);
+
     if (!QSystemTrayIcon::isSystemTrayAvailable() ||
             !QSystemTrayIcon::supportsMessages()) {
         QMessageBox::critical(0, QString::fromLatin1(APPNAME),

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