]> sigrok.org Git - pulseview.git/commitdiff
Translations: Use Qt translations
authorSoeren Apel <redacted>
Sun, 12 Jan 2020 13:02:10 +0000 (14:02 +0100)
committerSoeren Apel <redacted>
Mon, 13 Jan 2020 21:51:02 +0000 (22:51 +0100)
INSTALL
pv/application.cpp
pv/application.hpp

diff --git a/INSTALL b/INSTALL
index dce8eb64142f1d19bc6b024311cd8afafb18c2ea..0f551168529bc23c09642d43e9003383947d4b29 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -18,6 +18,7 @@ Requirements
  - gstreamermm-1.0 (>= 1.8.0)
  - Qt5 (>= 5.3), including the following components:
     - Qt5Core, Qt5Gui, Qt5Widgets, Qt5Svg
+    - Qt translation package (at runtime, not build time)
  - libboost >= 1.55 (including the following libs):
     - libboost-system
     - libboost-filesystem
index 67e0444f435b53fa8c67ae3f51a6058db0ba7e37..3e4691d0776434398467cd0cd0b3230bc37317ec 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <QDebug>
 #include <QDir>
+#include <QLibraryInfo>
 #include <QMessageBox>
 #include <QWidget>
 
@@ -84,6 +85,7 @@ void Application::switch_language(const QString& language)
 {
        removeTranslator(&app_translator_);
        removeTranslator(&qt_translator_);
+       removeTranslator(&qtbase_translator_);
 
        if ((language != "C") && (language != "en")) {
                // Application translations
@@ -94,11 +96,20 @@ void Application::switch_language(const QString& language)
                        qWarning() << "Translation resource" << resource << "not found";
 
                // Qt translations
-               resource = ":/l10n/qtbase_" + language +".qm";
-               if (qt_translator_.load(resource))
+               QString tr_path(QLibraryInfo::location(QLibraryInfo::TranslationsPath));
+
+               if (qt_translator_.load("qt_" + language, tr_path))
                        installTranslator(&qt_translator_);
                else
-                       qWarning() << "Translation resource" << resource << "not found";
+                       qWarning() << "QT translations for" << language << "not found at" <<
+                               tr_path << ", Qt translations package is probably missing";
+
+               // Qt base translations
+               if (qtbase_translator_.load("qtbase_" + language, tr_path))
+                       installTranslator(&qtbase_translator_);
+               else
+                       qWarning() << "QT base translations for" << language << "not found at" <<
+                               tr_path << ", Qt translations package is probably missing";
        }
 
        if (!topLevelWidgets().empty()) {
index 78b2f9ec50571dc0b28e65793314c374f15d0d66..61fe46e2480dc855210e586230c2e6960e070101 100644 (file)
@@ -67,7 +67,7 @@ private:
        vector< pair<QString, QString> > output_format_list_;
        vector< pair<QString, QString> > pd_list_;
 
-       QTranslator app_translator_, qt_translator_;
+       QTranslator app_translator_, qt_translator_, qtbase_translator_;
 };
 
 #endif // PULSEVIEW_PV_APPLICATION_HPP