Page MenuHome GnuPG

0001-Install-qt-catalogs-in-override-lang-on-windows.patch

Authored By
aheinecke
Mar 21 2018, 9:47 AM
Size
2 KB
Subscribers
None

0001-Install-qt-catalogs-in-override-lang-on-windows.patch

From 04ad7e139181fefb4110a1340da8a2178ae397b5 Mon Sep 17 00:00:00 2001
From: Andre Heinecke <aheinecke@intevation.de>
Date: Wed, 21 Mar 2018 09:40:14 +0100
Subject: [PATCH] Install qt catalogs in override lang on windows
On Windows Qt does not use the LANGUAGE environment
variable so we need to install the translators
manually to avoid a language mismatch between qt
and Kleo.
GnuPG-Bug-Id: T3835
---
src/main.cpp | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/src/main.cpp b/src/main.cpp
index 80158e24..06ba8026 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -75,6 +75,8 @@
#include <kmessagebox.h>
#include <QTextDocument> // for Qt::escape
+#include <QTranslator>
+#include <QLibraryInfo>
#include <QMessageBox>
#include <QTimer>
#include <QTime>
@@ -111,6 +113,41 @@ static void fillKeyCache(Kleo::UiServer *server)
cmd->start();
}
+static void loadTranslation(const QString &localeName, const QString &prefix)
+{
+ QTranslator *translator = new QTranslator(QCoreApplication::instance());
+ if (!translator->load(prefix + localeName, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) {
+ delete translator;
+ return;
+ }
+ qCDebug(KLEOPATRA_LOG) << "Loaded" << prefix << "translation for" << localeName;
+ QCoreApplication::instance()->installTranslator(translator);
+}
+
+static void loadTranslationsForWindows()
+{
+#ifndef Q_OS_WIN
+ Q_UNUSED(loadTranslation);
+ return;
+#else
+ // On Windows Qt does not use the LANGUAGE environment
+ // variable that is set by kxmlgui / klanguageoverridesrc but
+ // GetLocaleInfo instead.
+ //
+ // We want to use the kxmlgui language so that it is unified.
+
+ // This is set by kxmlgui if the language was overridden.
+ const QString lang = qgetenv("LANGUAGE");
+ if (lang.isEmpty()) {
+ return;
+ }
+ for (const auto &l: lang.split(QLatin1Char(':'))) {
+ loadTranslation(l, QLatin1String("qt_"));
+ loadTranslation(l, QLatin1String("qtbase_"));
+ }
+#endif
+}
+
int main(int argc, char **argv)
{
KleopatraApplication app(argc, argv);
@@ -128,6 +165,9 @@ int main(int argc, char **argv)
&service, [&service](int i) {
service.setExitValue(i);
});
+
+ loadTranslationsForWindows();
+
// Delay init after KUniqueservice call as this might already
// have terminated us and so we can avoid overhead (e.g. keycache
// setup / systray icon).
--
2.11.0

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
144917

Event Timeline