From fad820787b63627665071ae32babd2e873ac00b6 Mon Sep 17 00:00:00 2001 From: Simon Quigley Date: Mon, 6 Mar 2023 19:18:07 -0600 Subject: [PATCH] Add support for translations defined via X-Ubuntu-Gettext-Domain. --- debian/changelog | 6 +++ .../patches/ubuntu-gettext-translations.patch | 39 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 debian/patches/ubuntu-gettext-translations.patch diff --git a/debian/changelog b/debian/changelog index d91b186..234fb69 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +libqtxdg (3.10.0-0ubuntu6) UNRELEASED; urgency=medium + + * Add support for translations defined via X-Ubuntu-Gettext-Domain. + + -- Simon Quigley Mon, 06 Mar 2023 19:17:40 -0600 + libqtxdg (3.10.0-0ubuntu5) lunar; urgency=medium * Rebuild against lxqt-build-tools 0.12.0-0ubuntu3. diff --git a/debian/patches/ubuntu-gettext-translations.patch b/debian/patches/ubuntu-gettext-translations.patch new file mode 100644 index 0000000..6fe741b --- /dev/null +++ b/debian/patches/ubuntu-gettext-translations.patch @@ -0,0 +1,39 @@ +Description: Add support for translations defined via X-Ubuntu-Gettext-Domain +Author: Simon Quigley +Origin: vendor +Forwarded: https://github.com/lxqt/libqtxdg/pull/292 +Last-Update: 2023-03-06 +--- +This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +--- a/src/qtxdg/xdgdesktopfile.cpp ++++ b/src/qtxdg/xdgdesktopfile.cpp +@@ -38,6 +38,7 @@ + + #include + #include ++#include + + #include + #include +@@ -921,7 +922,22 @@ QString XdgDesktopFile::localizedKey(con + + QVariant XdgDesktopFile::localizedValue(const QString& key, const QVariant& defaultValue) const + { +- return value(localizedKey(key), defaultValue); ++ // If the file is translated via gettext, override locally-defined translations ++ if (contains(QLatin1String("X-Ubuntu-Gettext-Domain"))) ++ { ++ QString domain = value(QLatin1String("X-Ubuntu-Gettext-Domain")).toString(); ++ QString val = value(key, defaultValue).toString().trimmed(); ++ if (!val.isEmpty()) { ++ QByteArray _domain = domain.toUtf8(); ++ QByteArray _val = val.toUtf8(); ++ char *translated = dgettext(_domain.constData(), _val.constData()); ++ return QVariant(QString::fromUtf8(translated)); ++ } else { ++ return QVariant(); ++ } ++ } else { ++ return value(localizedKey(key), defaultValue); ++ } + }