From: Soeren Apel Date: Sun, 12 Jan 2020 13:02:10 +0000 (+0100) Subject: Translations: Use Qt translations X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=4353c902e15b08115d42ca18b0db84d4b31a7930;p=pulseview.git Translations: Use Qt translations --- diff --git a/INSTALL b/INSTALL index dce8eb64..0f551168 100644 --- 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 diff --git a/pv/application.cpp b/pv/application.cpp index 67e0444f..3e4691d0 100644 --- a/pv/application.cpp +++ b/pv/application.cpp @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -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()) { diff --git a/pv/application.hpp b/pv/application.hpp index 78b2f9ec..61fe46e2 100644 --- a/pv/application.hpp +++ b/pv/application.hpp @@ -67,7 +67,7 @@ private: vector< pair > output_format_list_; vector< pair > pd_list_; - QTranslator app_translator_, qt_translator_; + QTranslator app_translator_, qt_translator_, qtbase_translator_; }; #endif // PULSEVIEW_PV_APPLICATION_HPP