Hello community,

here is the log from the commit of package libxfce4util for openSUSE:Factory 
checked in at 2014-10-23 14:19:43
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/libxfce4util (Old)
 and      /work/SRC/openSUSE:Factory/.libxfce4util.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "libxfce4util"

Changes:
--------
--- /work/SRC/openSUSE:Factory/libxfce4util/libxfce4util.changes        
2013-05-06 10:14:42.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.libxfce4util.new/libxfce4util.changes   
2014-10-23 14:19:46.000000000 +0200
@@ -1,0 +2,9 @@
+Wed Oct 15 20:36:05 UTC 2014 - g...@opensuse.org
+
+- add libxfce4util-xfce-rc-i18n.patch which translates Name,
+  GenericName, and Comment entries of desktop files via gettext
+  when read via the xfce_rc_* API, this is necessary since inline
+  translations in openSUSE are removed in favor of gettext-based
+  translations (bnc#829113)
+
+-------------------------------------------------------------------

New:
----
  libxfce4util-xfce-rc-i18n.patch

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ libxfce4util.spec ++++++
--- /var/tmp/diff_new_pack.pTvsTP/_old  2014-10-23 14:19:47.000000000 +0200
+++ /var/tmp/diff_new_pack.pTvsTP/_new  2014-10-23 14:19:47.000000000 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package libxfce4util
 #
-# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -27,6 +27,8 @@
 Url:            http://www.xfce.org/
 Source:         
http://archive.xfce.org/src/xfce/libxfce4util/4.10/%{name}-%{version}.tar.bz2
 Source100:      %{name}-rpmlintrc
+# PATCH-FEATURE-OPENSUSE libxfce4util-xfce-rc-i18n.patch bnc#829113 
g...@opensuse.org -- Translate Name, GenericName, and Comment entries of 
desktop files via gettext when read via the xfce_rc_* API
+Patch0:         libxfce4util-xfce-rc-i18n.patch
 BuildRequires:  gtk-doc
 BuildRequires:  intltool
 BuildRequires:  perl
@@ -80,6 +82,7 @@
 
 %prep
 %setup -q
+%patch0 -p1
 
 %build
 %configure \

++++++ libxfce4util-xfce-rc-i18n.patch ++++++
Index: libxfce4util-4.10.1/libxfce4util/xfce-rc-simple.c
===================================================================
--- libxfce4util-4.10.1.orig/libxfce4util/xfce-rc-simple.c
+++ libxfce4util-4.10.1/libxfce4util/xfce-rc-simple.c
@@ -54,6 +54,8 @@
 /* name of the NULL group */
 #define NULL_GROUP "[NULL]"
 
+/* default gettext domain for desktop file translations */
+#define _XFCE_RC_DESKTOP_FILE_DEFAULT_DOMAIN "desktop_translations"
 
 typedef struct _Entry  Entry;
 typedef struct _LEntry LEntry;
@@ -103,6 +105,7 @@ struct _Entry
 {
   gchar  *key;
   gchar  *value;
+  gchar  *glvalue;
   Entry  *next;
   Entry  *prev;
   LEntry *lfirst;
@@ -209,6 +212,7 @@ simple_add_entry (XfceRcSimple *simple,
       entry         = g_slice_new (Entry);
       entry->key    = g_string_chunk_insert (simple->string_chunk, key);
       entry->value  = g_string_chunk_insert (simple->string_chunk, value);
+      entry->glvalue = NULL;
       entry->lfirst = NULL;
       entry->llast  = NULL;
 
@@ -554,6 +558,9 @@ simple_write (XfceRcSimple *simple, cons
 static void
 simple_entry_free (Entry *entry)
 {
+  /* free any desktop file gettext translations */
+  g_free (entry->glvalue);
+
   /* release all lentries */
   g_slice_free_chain (LEntry, entry->lfirst, next);
 
@@ -639,9 +646,11 @@ _xfce_rc_simple_new (XfceRcSimple *share
 
 
 
+static gboolean default_domain_encoding_is_set = FALSE;
 gboolean
 _xfce_rc_simple_parse (XfceRcSimple *simple)
 {
+  XfceRc  *rc = XFCE_RC (simple);
   gboolean readonly;
   gchar    line[LINE_MAX];
   gchar   *section;
@@ -653,7 +662,7 @@ _xfce_rc_simple_parse (XfceRcSimple *sim
   _xfce_return_val_if_fail (simple != NULL, FALSE);
   _xfce_return_val_if_fail (simple->filename != NULL, FALSE);
 
-  readonly = xfce_rc_is_readonly (XFCE_RC (simple));
+  readonly = xfce_rc_is_readonly (rc);
 
   fp = fopen (simple->filename, "r");
   if (fp == NULL)
@@ -679,7 +688,7 @@ _xfce_rc_simple_parse (XfceRcSimple *sim
       if (XFCE_RC (simple)->locale == NULL)
         continue;
 
-      if (xfce_locale_match (XFCE_RC (simple)->locale, locale) > 
XFCE_LOCALE_NO_MATCH
+      if (xfce_locale_match (rc->locale, locale) > XFCE_LOCALE_NO_MATCH
           || !readonly)
         {
           simple_add_entry (simple, key, value, locale);
@@ -688,6 +697,106 @@ _xfce_rc_simple_parse (XfceRcSimple *sim
 
   fclose (fp);
 
+  /* if a locale is set and this is a desktop file, try to obtain translations
+   * for the Name, GenericName, and Comment entries via gettext
+   */
+  if (rc->locale)
+    {
+      Group *group;
+      Group *desktop_group = NULL;
+
+      /* check if this is a desktop file */
+      for (group = simple->gfirst; group != NULL; group = group->next)
+        {
+          if (str_is_equal (group->name, G_KEY_FILE_DESKTOP_GROUP))
+            {
+              desktop_group = group;
+              break;
+            }
+        }
+      if (desktop_group)
+        {
+          Entry    *entry;
+          gchar    *gettext_domain = NULL;
+          gchar    *file_basename;
+          gboolean  codeset_is_set = FALSE;
+
+          if (G_UNLIKELY(!default_domain_encoding_is_set))
+            {
+              default_domain_encoding_is_set =
+                 (bind_textdomain_codeset 
(_XFCE_RC_DESKTOP_FILE_DEFAULT_DOMAIN,
+                                           "UTF-8") != NULL);
+            }
+
+          /* try to find a translation domain entry */
+          for (entry = desktop_group->efirst; entry != NULL;
+               entry = entry->next)
+            {
+              if (str_is_equal (entry->key,
+                  G_KEY_FILE_DESKTOP_KEY_GETTEXT_DOMAIN))
+                {
+                  gettext_domain = g_strdup (entry->value);
+                  break;
+                }
+            }
+          /* fall back to to the default gettext domain for desktop entries */
+          if (!gettext_domain)
+            gettext_domain = g_strdup (_XFCE_RC_DESKTOP_FILE_DEFAULT_DOMAIN);
+
+          if (str_is_equal (gettext_domain, 
_XFCE_RC_DESKTOP_FILE_DEFAULT_DOMAIN))
+            codeset_is_set = default_domain_encoding_is_set;
+          else
+            codeset_is_set = (bind_textdomain_codeset (gettext_domain, 
"UTF-8") != NULL);
+
+          /* determine the basename of the desktop file needed for the gettext
+           * context
+           */
+          file_basename = g_strrstr (simple->filename, G_DIR_SEPARATOR_S);
+          if (G_LIKELY (file_basename != NULL))
+            file_basename++;
+          else
+            file_basename = simple->filename;
+
+          for (entry = desktop_group->efirst; entry != NULL;
+               entry = entry->next)
+            {
+              const gchar *context_translated_value = NULL;
+              const gchar *translated_value = NULL;
+              gchar       *context_value;
+
+              /* only translate Name, GenericName, and Comment entries */
+              if (!str_is_equal (entry->key, G_KEY_FILE_DESKTOP_KEY_NAME) &&
+                  !str_is_equal (entry->key, 
G_KEY_FILE_DESKTOP_KEY_GENERIC_NAME) &&
+                  !str_is_equal (entry->key, G_KEY_FILE_DESKTOP_KEY_COMMENT))
+                continue;
+
+              /* try to get a translation with context */
+              context_value = g_strdup_printf ("%s(%s): %s", entry->key,
+                                               file_basename, entry->value);
+              context_translated_value = g_dgettext (gettext_domain, 
context_value);
+
+              /* if no translation was found, retry without context */
+              if (context_translated_value == context_value)
+                translated_value = g_dgettext (gettext_domain, entry->value);
+              else
+                translated_value = context_translated_value;
+
+              if (translated_value != entry->value)
+                {
+                  if (codeset_is_set)
+                    entry->glvalue = g_strdup (translated_value);
+                  else
+                    entry->glvalue = g_locale_to_utf8 (translated_value, -1,
+                                                       NULL, NULL, NULL);
+                }
+
+              g_free (context_value);
+            }
+
+          g_free (gettext_domain);
+        }
+    }
+
   return TRUE;
 }
 
@@ -1047,6 +1156,10 @@ _xfce_rc_simple_read_entry (const XfceRc
           if (best_value != NULL)
             return best_value;
 
+          /* fall back to gettext translated value */
+          if (entry->glvalue != NULL)
+            return entry->glvalue;
+
           /* FALL-THROUGH */
         }
 
-- 
To unsubscribe, e-mail: opensuse-commit+unsubscr...@opensuse.org
For additional commands, e-mail: opensuse-commit+h...@opensuse.org

Reply via email to