From 2b176576d53d3fac8c1440ab842c852e91d4cbdf8a775b12ae8be3d7c88e3524 Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Wed, 14 Jun 2017 07:42:13 +0000 Subject: [PATCH] Accepting request 503447 from home:lnussel:branches:Base:System - Use gettext as fallback to get potential distro translations for polkit actions. Similar mechnism as used for desktop file translations. That way it's possible to use weblate to add additional translations that are not provided by upstream (polkit-gettext.patch). OBS-URL: https://build.opensuse.org/request/show/503447 OBS-URL: https://build.opensuse.org/package/show/Base:System/polkit?expand=0&rev=113 --- polkit-gettext.patch | 57 ++++++++++++++++++++++++++++++++++++++++++++ polkit.changes | 9 +++++++ polkit.spec | 5 +++- 3 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 polkit-gettext.patch diff --git a/polkit-gettext.patch b/polkit-gettext.patch new file mode 100644 index 0000000..e9d00de --- /dev/null +++ b/polkit-gettext.patch @@ -0,0 +1,57 @@ +From fea7159b7cc50deb7298b2858e125fb623012549 Mon Sep 17 00:00:00 2001 +From: Ludwig Nussel +Date: Tue, 13 Jun 2017 18:28:28 +0200 +Subject: [PATCH] Use gettext as fallback for translations + +Upstream polkit action files do not necessarily contain translations for +all languages a distribution supports. And even if all translations are +contained in the head branch, distributions sometimes need to ship older +versions of packages. In order to allow retrofitting translations and +shipping language packs for polkit actions without having to patch and +rebuild packages gettext could be used as fallback. That way only +additional .mo files have to be installed. +So this patch makes polkit call into gettext with the domain +'polkit-action-distro-translations' if an xml doesn't contain +translations for the requested language. +--- + src/polkitbackend/polkitbackendactionpool.c | 17 +++++++++++++++-- + 1 file changed, 15 insertions(+), 2 deletions(-) + +diff --git a/src/polkitbackend/polkitbackendactionpool.c b/src/polkitbackend/polkitbackendactionpool.c +index 3894fe9..9252788 100644 +--- a/src/polkitbackend/polkitbackendactionpool.c ++++ b/src/polkitbackend/polkitbackendactionpool.c +@@ -24,6 +24,7 @@ + #include + #include + #include ++#include + + #include + #include +@@ -1132,8 +1133,20 @@ _localize (GHashTable *translations, + if (result != NULL) + goto out; + +- /* fall back to untranslated */ +- result = untranslated; ++ /* try distro provided language bundle via gettext */ ++ ++ /* Set LANG and locale so g_dgettext() + friends work below */ ++ if (setlocale (LC_ALL, lang) == NULL) ++ { ++ g_printerr ("Invalid locale '%s'\n", lang); ++ } ++ g_setenv ("LANG", lang, TRUE); ++ ++ result = g_dgettext ("polkit-action-distro-translations", untranslated); ++ ++ /* Back to C! */ ++ setlocale (LC_ALL, "C"); ++ g_setenv ("LANG", "C", TRUE); + + out: + return result; +-- +2.12.2 + diff --git a/polkit.changes b/polkit.changes index fd57194..4404611 100644 --- a/polkit.changes +++ b/polkit.changes @@ -1,3 +1,12 @@ +------------------------------------------------------------------- +Tue Jun 13 15:25:58 UTC 2017 - lnussel@suse.de + +- Use gettext as fallback to get potential distro translations for + polkit actions. Similar mechnism as used for desktop file + translations. That way it's possible to use weblate to add + additional translations that are not provided by upstream + (polkit-gettext.patch). + ------------------------------------------------------------------- Wed Jun 8 11:13:43 UTC 2016 - fbui@suse.com diff --git a/polkit.spec b/polkit.spec index 01f85b1..988169f 100644 --- a/polkit.spec +++ b/polkit.spec @@ -1,7 +1,7 @@ # # spec file for package polkit # -# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -36,6 +36,8 @@ Patch0: polkit-no-wheel-group.patch Patch1: polkit-no-systemd.patch # PATCH-REVERT-UPSTREAM polkit-revert-session-magic.patch various bugs meissner -- systemd session magic was not updating the user seats correctly Patch2: polkit-revert-session-magic.patch +# PATCH-FIX-OPENSUSE polkit-gettext.patch lnussel@suse.de -- allow fallback to gettext for polkit action translations +Patch3: polkit-gettext.patch # needed for patch1 BuildRequires: autoconf # needed for patch1 @@ -131,6 +133,7 @@ This package provides the GObject Introspection bindings for PolicyKit. %patch1 -p1 %endif %patch2 -p1 -R +%patch3 -p1 %build export V=1