<div dir="ltr"><div>Not sure if you saw but here is a similar patch:<br><a href="https://bugs.freedesktop.org/show_bug.cgi?id=29639">https://bugs.freedesktop.org/show_bug.cgi?id=29639</a><br><br></div>We've been shipping this in Ubuntu for years.<br><div><div><br><div class="gmail_quote"><div dir="ltr">On Wed, 14 Jun 2017 at 04:36 Ludwig Nussel <<a href="mailto:ludwig.nussel@suse.de">ludwig.nussel@suse.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Upstream polkit action files do not necessarily contain translations for<br>
all languages a distribution supports. And even if all translations are<br>
contained in the head branch, distributions sometimes need to ship older<br>
versions of packages. In order to allow retrofitting translations and<br>
shipping language packs for polkit actions without having to patch and<br>
rebuild packages gettext could be used as fallback. That way only<br>
additional .mo files have to be installed.<br>
So this patch makes polkit call into gettext with the domain<br>
'polkit-action-distro-translations' if an xml doesn't contain<br>
translations for the requested language.<br>
---<br>
 src/polkitbackend/polkitbackendactionpool.c | 17 +++++++++++++++--<br>
 1 file changed, 15 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/src/polkitbackend/polkitbackendactionpool.c b/src/polkitbackend/polkitbackendactionpool.c<br>
index 3894fe9..9252788 100644<br>
--- a/src/polkitbackend/polkitbackendactionpool.c<br>
+++ b/src/polkitbackend/polkitbackendactionpool.c<br>
@@ -24,6 +24,7 @@<br>
 #include <pwd.h><br>
 #include <string.h><br>
 #include <expat.h><br>
+#include <locale.h><br>
<br>
 #include <polkit/polkit.h><br>
 #include <polkit/polkitprivate.h><br>
@@ -1132,8 +1133,20 @@ _localize (GHashTable *translations,<br>
   if (result != NULL)<br>
     goto out;<br>
<br>
-  /* fall back to untranslated */<br>
-  result = untranslated;<br>
+  /* try distro provided language bundle via gettext */<br>
+<br>
+  /* Set LANG and locale so g_dgettext() + friends work below */<br>
+  if (setlocale (LC_ALL, lang) == NULL)<br>
+    {<br>
+      g_printerr ("Invalid locale '%s'\n", lang);<br>
+    }<br>
+  g_setenv ("LANG", lang, TRUE);<br>
+<br>
+  result = g_dgettext ("polkit-action-distro-translations", untranslated);<br>
+<br>
+  /* Back to C! */<br>
+  setlocale (LC_ALL, "C");<br>
+  g_setenv ("LANG", "C", TRUE);<br>
<br>
 out:<br>
   return result;<br>
--<br>
2.12.2<br>
<br>
_______________________________________________<br>
polkit-devel mailing list<br>
<a href="mailto:polkit-devel@lists.freedesktop.org" target="_blank">polkit-devel@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/polkit-devel" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/polkit-devel</a><br>
</blockquote></div></div></div></div>