Skip to content
Snippets Groups Projects
Commit f205cfa7 authored by Sebastian Dröge's avatar Sebastian Dröge
Browse files

* debian/patches/01_gettext-desktopfiles.patch,

  debian/patches/02_gettext-desktopfiles-ubuntu.patch:
  + Updated from the Ubuntu package, thanks to Martin Pitt for the changes:
    - 01_gettext-desktopfiles.patch: Merge OpenSUSE's and our patch:
      - Now prefers inline translations over gettext translations, which
        fixes a few corner cases (like renaming .desktop files on the
        user's desktop), is more in line with the recent gconf patch,
        and more palatable for upstream inclusion.
      - Use X-GNOME-Gettext-Domain, for preparing upstream inclusion.
      - Forwarded upstream now.
    - Add 02_gettext-desktopfiles-ubuntu.patch: Provide backwards
      compatibility for 01_gettext-desktopfiles.patch for
      X-{Debian,Ubuntu}-Gettext-Domain. The latter was changed to use
      X-GNOME-, so this is necessary until all our .desktop files are
      converted.
parent fcfeb80e
No related branches found
Tags debian/2.19.8-2
No related merge requests found
glib2.0 (2.19.8-2) experimental; urgency=low
* debian/patches/01_gettext-desktopfiles.patch,
debian/patches/02_gettext-desktopfiles-ubuntu.patch:
+ Updated from the Ubuntu package, thanks to Martin Pitt for the changes:
- 01_gettext-desktopfiles.patch: Merge OpenSUSE's and our patch:
- Now prefers inline translations over gettext translations, which
fixes a few corner cases (like renaming .desktop files on the
user's desktop), is more in line with the recent gconf patch,
and more palatable for upstream inclusion.
- Use X-GNOME-Gettext-Domain, for preparing upstream inclusion.
- Forwarded upstream now.
- Add 02_gettext-desktopfiles-ubuntu.patch: Provide backwards
compatibility for 01_gettext-desktopfiles.patch for
X-{Debian,Ubuntu}-Gettext-Domain. The latter was changed to use
X-GNOME-, so this is necessary until all our .desktop files are
converted.
-- Sebastian Dröge <slomo@debian.org> Tue, 24 Feb 2009 16:08:05 +0100
glib2.0 (2.19.8-1) experimental; urgency=low
* New upstream development release.
......
--- glib2.0-2.18.0.orig/glib/gkeyfile.c 2008-09-02 17:09:41.000000000 +0200
+++ glib2.0-2.18.0/glib/gkeyfile.c 2008-09-03 00:53:13.000000000 +0200
@@ -21,6 +21,10 @@
* Boston, MA 02111-1307, USA.
*/
+#define X_DEBIAN_GETTEXT_DOMAIN "X-Debian-Gettext-Domain"
+#define X_UBUNTU_GETTEXT_DOMAIN "X-Ubuntu-Gettext-Domain"
+#define X_DESKTOP_ENTRY "Desktop Entry"
+
#include "config.h"
#include "gkeyfile.h"
@@ -83,6 +87,7 @@
# Description: If a .desktop file does not have inline translations, fall back to calling gettext.
# Ubuntu: https://launchpad.net/bugs/3935
# Upstream: http://bugzilla.gnome.org/show_bug.cgi?id=569829
Index: glib2.0-2.19.5/glib/gkeyfile.c
===================================================================
--- glib2.0-2.19.5.orig/glib/gkeyfile.c 2009-01-30 15:34:03.000000000 +0100
+++ glib2.0-2.19.5/glib/gkeyfile.c 2009-01-30 15:34:32.000000000 +0100
@@ -83,6 +83,7 @@
GKeyFileFlags flags;
gchar **locales;
+ char *gettext_domain;
+ gchar *gettext_domain;
};
typedef struct _GKeyFileKeyValuePair GKeyFileKeyValuePair;
@@ -209,6 +214,7 @@
@@ -209,6 +210,7 @@
key_file->list_separator = ';';
key_file->flags = 0;
key_file->locales = g_strdupv ((gchar **)g_get_language_names ());
......@@ -27,75 +21,125 @@
}
static void
@@ -227,6 +233,7 @@
g_string_free (key_file->parse_buffer, TRUE);
@@ -228,6 +230,12 @@
key_file->parse_buffer = NULL;
}
+ g_free(key_file->gettext_domain);
+ if (key_file->gettext_domain)
+ {
+ g_free (key_file->gettext_domain);
+ key_file->gettext_domain = NULL;
+ }
+
tmp = key_file->groups;
while (tmp != NULL)
@@ -448,6 +455,10 @@
{
@@ -448,6 +456,11 @@
return FALSE;
}
+ key_file->gettext_domain = g_key_file_get_string (key_file, X_DESKTOP_ENTRY, X_UBUNTU_GETTEXT_DOMAIN, NULL);
+ if (!key_file->gettext_domain)
+ key_file->gettext_domain = g_key_file_get_string (key_file, X_DESKTOP_ENTRY, X_DEBIAN_GETTEXT_DOMAIN, NULL);
+ key_file->gettext_domain = g_key_file_get_string (key_file,
+ G_KEY_FILE_DESKTOP_GROUP,
+ G_KEY_FILE_DESKTOP_KEY_GETTEXT_DOMAIN,
+ NULL);
+
return TRUE;
}
@@ -553,6 +564,10 @@
g_propagate_error (error, key_file_error);
@@ -554,6 +567,11 @@
return FALSE;
}
+
+ key_file->gettext_domain = g_key_file_get_string (key_file, X_DESKTOP_ENTRY, X_UBUNTU_GETTEXT_DOMAIN, NULL);
+ if (!key_file->gettext_domain)
+ key_file->gettext_domain = g_key_file_get_string (key_file, X_DESKTOP_ENTRY, X_DEBIAN_GETTEXT_DOMAIN, NULL);
+ key_file->gettext_domain = g_key_file_get_string (key_file,
+ G_KEY_FILE_DESKTOP_GROUP,
+ G_KEY_FILE_DESKTOP_KEY_GETTEXT_DOMAIN,
+ NULL);
+
return TRUE;
}
@@ -1682,6 +1697,32 @@
languages = (gchar **) g_get_language_names ();
@@ -1662,6 +1680,8 @@
GError *key_file_error;
gchar **languages;
gboolean free_languages = FALSE;
+ gboolean try_gettext = FALSE;
+ const gchar *msg_locale;
gint i;
g_return_val_if_fail (key_file != NULL, NULL);
@@ -1692,6 +1712,23 @@
free_languages = FALSE;
}
+ /* we're only interested in gettext translation if we don't have a
+ * translation in the .desktop file itself and if the key is one of the keys
+ * we know we want to translate: Name, GenericName, Comment. Blindly doing
+ * this for all keys can give strange result for the icons, since the Icon is
+ * a locale string in the spec, eg. We also only get translation in the mo
+ * file if the requested locale is the LC_MESSAGES one. Ideally, we should do
+ * more and change LC_MESSAGES to use the requested locale, but there's no
+ * guarantee it's installed on the system and it might have some
+ * side-effects. Since this is a corner case, let's ignore it. */
+
+ msg_locale = setlocale (LC_MESSAGES, NULL);
+ try_gettext = msg_locale && key_file->gettext_domain &&
+ strcmp (group_name, G_KEY_FILE_DESKTOP_GROUP) == 0 &&
+ (strcmp (key, G_KEY_FILE_DESKTOP_KEY_NAME) == 0 ||
+ strcmp (key, G_KEY_FILE_DESKTOP_KEY_GENERIC_NAME) == 0 ||
+ strcmp (key, G_KEY_FILE_DESKTOP_KEY_COMMENT) == 0);
+
+ if (key_file->gettext_domain)
for (i = 0; languages[i]; i++)
{
candidate_key = g_strdup_printf ("%s[%s]", key, languages[i]);
@@ -1708,6 +1745,39 @@
translated_value = NULL;
}
+ /* Fallback to gettext */
+ if (try_gettext && !translated_value)
+ {
+ char *orig_value = g_key_file_get_string (key_file, group_name, key, NULL);
+ gchar *orig_value = g_key_file_get_string (key_file, group_name, key, NULL);
+
+ if (orig_value)
+ {
+ gboolean has_gettext;
+ gboolean codeset_set;
+ const gchar *translated;
+ gboolean has_gettext;
+
+ codeset_set = bind_textdomain_codeset (key_file->gettext_domain, "UTF-8") != NULL;
+ translated = NULL;
+
+ translated = g_dgettext (key_file->gettext_domain,
+ orig_value);
+ has_gettext = translated != orig_value;
+
+ /* fprintf (stderr, "Resolved: '%s'='%s'\n", key, orig_value); */
+ translated_value = dgettext (key_file->gettext_domain, orig_value);
+ has_gettext = translated_value != orig_value;
+ g_free (orig_value);
+ g_free (orig_value);
+
+ if (has_gettext)
+ {
+ if (bind_textdomain_codeset (key_file->gettext_domain, NULL))
+ translated_value = g_strdup (translated_value);
+ else
+ translated_value = g_locale_to_utf8 (translated_value, -1, NULL, NULL, NULL);
+ /* fprintf (stderr, "Translated: '%s' -(via %s)- '%s'\n", orig_value, key_file->gettext_domain, translated_value); */
+ goto done;
+ }
+ else
+ translated_value = NULL;
+ }
+ if (has_gettext)
+ {
+ if (codeset_set)
+ translated_value = g_strdup (translated);
+ else
+ translated_value = g_locale_to_utf8 (translated,
+ -1, NULL, NULL, NULL);
+ }
+ else
+ translated_value = NULL;
+ }
+ }
for (i = 0; languages[i]; i++)
{
@@ -1710,6 +1751,8 @@
g_propagate_error (error, key_file_error);
}
+done:
+
if (free_languages)
g_strfreev (languages);
/* Fallback to untranslated key
*/
if (!translated_value)
Index: glib2.0-2.19.5/glib/gkeyfile.h
===================================================================
--- glib2.0-2.19.5.orig/glib/gkeyfile.h 2009-01-30 15:34:03.000000000 +0100
+++ glib2.0-2.19.5/glib/gkeyfile.h 2009-01-30 15:34:32.000000000 +0100
@@ -240,6 +240,7 @@
#define G_KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY "StartupNotify"
#define G_KEY_FILE_DESKTOP_KEY_STARTUP_WM_CLASS "StartupWMClass"
#define G_KEY_FILE_DESKTOP_KEY_URL "URL"
+#define G_KEY_FILE_DESKTOP_KEY_GETTEXT_DOMAIN "X-GNOME-Gettext-Domain"
#define G_KEY_FILE_DESKTOP_TYPE_APPLICATION "Application"
#define G_KEY_FILE_DESKTOP_TYPE_LINK "Link"
# Description: Provide backwards compatibility for 01_gettext-desktopfiles.patch for X-{Debian,Ubuntu}-Gettext-Domain
# UbuntuSpecific: 01_gettext-desktopfiles.patch was changed to use X-GNOME-, so this is necessary until all our .desktop files are converted
Index: glib2.0-2.19.5/glib/gkeyfile.c
===================================================================
--- glib2.0-2.19.5.orig/glib/gkeyfile.c 2009-01-30 15:53:09.000000000 +0100
+++ glib2.0-2.19.5/glib/gkeyfile.c 2009-01-30 15:55:46.000000000 +0100
@@ -460,6 +460,16 @@
G_KEY_FILE_DESKTOP_GROUP,
G_KEY_FILE_DESKTOP_KEY_GETTEXT_DOMAIN,
NULL);
+ if (!key_file->gettext_domain)
+ key_file->gettext_domain = g_key_file_get_string (key_file,
+ G_KEY_FILE_DESKTOP_GROUP,
+ "X-Ubuntu-Gettext-Domain",
+ NULL);
+ if (!key_file->gettext_domain)
+ key_file->gettext_domain = g_key_file_get_string (key_file,
+ G_KEY_FILE_DESKTOP_GROUP,
+ "X-Debian-Gettext-Domain",
+ NULL);
return TRUE;
}
@@ -571,6 +581,16 @@
G_KEY_FILE_DESKTOP_GROUP,
G_KEY_FILE_DESKTOP_KEY_GETTEXT_DOMAIN,
NULL);
+ if (!key_file->gettext_domain)
+ key_file->gettext_domain = g_key_file_get_string (key_file,
+ G_KEY_FILE_DESKTOP_GROUP,
+ "X-Ubuntu-Gettext-Domain",
+ NULL);
+ if (!key_file->gettext_domain)
+ key_file->gettext_domain = g_key_file_get_string (key_file,
+ G_KEY_FILE_DESKTOP_GROUP,
+ "X-Debian-Gettext-Domain",
+ NULL);
return TRUE;
}
01_gettext-desktopfiles.patch
02_gettext-desktopfiles-ubuntu.patch
02_usr_share_gnome_applications.patch
03_blacklist-directories.patch
04_homedir_env.patch
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment