2022-03-21 09:34:56 +01:00
|
|
|
Index: glib-2.71.0/glib/gkeyfile.c
|
2009-02-06 17:03:35 +01:00
|
|
|
===================================================================
|
2022-03-21 09:34:56 +01:00
|
|
|
--- glib-2.71.0.orig/glib/gkeyfile.c
|
|
|
|
+++ glib-2.71.0/glib/gkeyfile.c
|
2021-11-05 09:44:42 +01:00
|
|
|
@@ -514,6 +514,7 @@ struct _GKeyFile
|
2022-03-21 09:34:56 +01:00
|
|
|
gboolean checked_locales; /* TRUE if @locales has been initialised */
|
|
|
|
gchar **locales; /* (nullable) */
|
2009-02-06 17:03:35 +01:00
|
|
|
gchar *gettext_domain;
|
|
|
|
+ gchar *file_basename;
|
|
|
|
|
2021-03-24 17:32:24 +01:00
|
|
|
gint ref_count; /* (atomic) */
|
2011-11-15 10:01:46 +01:00
|
|
|
};
|
2022-03-21 09:34:56 +01:00
|
|
|
@@ -641,6 +642,7 @@ g_key_file_init (GKeyFile *key_file)
|
2021-03-24 17:32:24 +01:00
|
|
|
key_file->list_separator = ';';
|
2009-02-06 17:03:35 +01:00
|
|
|
key_file->flags = 0;
|
|
|
|
key_file->gettext_domain = NULL;
|
|
|
|
+ key_file->file_basename = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-03-21 09:34:56 +01:00
|
|
|
@@ -667,6 +669,12 @@ g_key_file_clear (GKeyFile *key_file)
|
2009-02-06 17:03:35 +01:00
|
|
|
key_file->gettext_domain = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ if (key_file->file_basename)
|
|
|
|
+ {
|
|
|
|
+ g_free (key_file->file_basename);
|
|
|
|
+ key_file->file_basename = NULL;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
tmp = key_file->groups;
|
|
|
|
while (tmp != NULL)
|
|
|
|
{
|
2022-03-21 09:34:56 +01:00
|
|
|
@@ -811,6 +819,39 @@ find_file_in_data_dirs (const gchar *f
|
2009-02-06 17:03:35 +01:00
|
|
|
return fd;
|
|
|
|
}
|
|
|
|
|
|
|
|
+static int _g_key_file_default_textdomain_codeset_bound = 0;
|
|
|
|
+#define _G_KEY_FILE_DEFAULT_DOMAIN "desktop_translations"
|
|
|
|
+
|
|
|
|
+static char *
|
|
|
|
+_g_key_file_get_default_gettext_domain (void)
|
|
|
|
+{
|
|
|
|
+ if (!_g_key_file_default_textdomain_codeset_bound)
|
|
|
|
+ {
|
|
|
|
+ const char *codeset;
|
|
|
|
+
|
|
|
|
+ _g_key_file_default_textdomain_codeset_bound = 1;
|
|
|
|
+
|
|
|
|
+ codeset = bind_textdomain_codeset (_G_KEY_FILE_DEFAULT_DOMAIN, "UTF-8");
|
|
|
|
+
|
|
|
|
+ if (codeset)
|
|
|
|
+ _g_key_file_default_textdomain_codeset_bound |= 1 << 1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return g_strdup (_G_KEY_FILE_DEFAULT_DOMAIN);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static inline gboolean
|
|
|
|
+_g_key_file_is_default_gettext_domain (const char *domain)
|
|
|
|
+{
|
|
|
|
+ return (domain && strcmp (domain, _G_KEY_FILE_DEFAULT_DOMAIN) == 0);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static inline gboolean
|
|
|
|
+_g_key_file_default_gettext_domain_is_bound (void)
|
|
|
|
+{
|
|
|
|
+ return _g_key_file_default_textdomain_codeset_bound & (1 << 1);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
static gboolean
|
|
|
|
g_key_file_load_from_fd (GKeyFile *key_file,
|
|
|
|
gint fd,
|
2022-03-21 09:34:56 +01:00
|
|
|
@@ -892,6 +933,9 @@ g_key_file_load_from_fd (GKeyFile
|
2009-02-06 17:03:35 +01:00
|
|
|
G_KEY_FILE_DESKTOP_KEY_GETTEXT_DOMAIN,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
+ if (!key_file->gettext_domain)
|
|
|
|
+ key_file->gettext_domain = _g_key_file_get_default_gettext_domain ();
|
|
|
|
+
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2022-03-21 09:34:56 +01:00
|
|
|
@@ -948,6 +992,8 @@ g_key_file_load_from_file (GKeyFile
|
2009-02-06 17:03:35 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ key_file->file_basename = g_path_get_basename (file);
|
|
|
|
+
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2022-03-21 09:34:56 +01:00
|
|
|
@@ -1009,6 +1055,9 @@ g_key_file_load_from_data (GKeyFile
|
2009-02-06 17:03:35 +01:00
|
|
|
G_KEY_FILE_DESKTOP_KEY_GETTEXT_DOMAIN,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
+ if (!key_file->gettext_domain)
|
|
|
|
+ key_file->gettext_domain = _g_key_file_get_default_gettext_domain ();
|
|
|
|
+
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2022-03-21 09:34:56 +01:00
|
|
|
@@ -1113,6 +1162,9 @@ g_key_file_load_from_dirs (GKeyFile
|
2009-02-06 17:03:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ if (found_file)
|
|
|
|
+ key_file->file_basename = g_path_get_basename (output_path);
|
|
|
|
+
|
|
|
|
if (found_file && full_path)
|
|
|
|
*full_path = output_path;
|
|
|
|
else
|
2022-03-21 09:34:56 +01:00
|
|
|
@@ -2320,14 +2372,40 @@ g_key_file_get_locale_string (GKeyFile
|
2014-10-16 11:05:15 +02:00
|
|
|
{
|
|
|
|
gboolean codeset_set;
|
2009-02-06 17:03:35 +01:00
|
|
|
const gchar *translated;
|
2014-10-16 11:05:15 +02:00
|
|
|
- gboolean has_gettext;
|
|
|
|
+ gboolean has_gettext = FALSE;
|
2009-02-06 17:03:35 +01:00
|
|
|
|
|
|
|
- codeset_set = bind_textdomain_codeset (key_file->gettext_domain, "UTF-8") != NULL;
|
|
|
|
+ if (_g_key_file_is_default_gettext_domain (key_file->gettext_domain))
|
|
|
|
+ codeset_set = _g_key_file_default_gettext_domain_is_bound ();
|
|
|
|
+ else
|
|
|
|
+ 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;
|
|
|
|
+ /* first try to translate with the context */
|
|
|
|
+ if (key_file->file_basename)
|
|
|
|
+ {
|
|
|
|
+ gchar *context;
|
|
|
|
+ gchar *context_value;
|
|
|
|
+
|
|
|
|
+ context = g_strdup_printf ("%s(%s)", key,
|
|
|
|
+ key_file->file_basename);
|
|
|
|
+ context_value = g_strdup_printf ("%s%s%s",
|
|
|
|
+ context, ": ", orig_value);
|
|
|
|
+
|
|
|
|
+ translated = g_dgettext (key_file->gettext_domain,
|
|
|
|
+ context_value);
|
|
|
|
+ has_gettext = translated != context_value;
|
|
|
|
+
|
|
|
|
+ g_free (context_value);
|
|
|
|
+ g_free (context);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /* no translation with the context: try without context */
|
|
|
|
+ if (!has_gettext)
|
|
|
|
+ {
|
|
|
|
+ translated = g_dgettext (key_file->gettext_domain,
|
|
|
|
+ orig_value);
|
|
|
|
+ has_gettext = translated != orig_value;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
g_free (orig_value);
|
|
|
|
|
2022-03-21 09:34:56 +01:00
|
|
|
Index: glib-2.71.0/glib/gkeyfile.h
|
2009-02-06 17:03:35 +01:00
|
|
|
===================================================================
|
2022-03-21 09:34:56 +01:00
|
|
|
--- glib-2.71.0.orig/glib/gkeyfile.h
|
|
|
|
+++ glib-2.71.0/glib/gkeyfile.h
|
2018-04-13 08:43:32 +02:00
|
|
|
@@ -320,7 +320,7 @@ gboolean g_key_file_remove_group
|
2009-02-06 17:03:35 +01:00
|
|
|
#define G_KEY_FILE_DESKTOP_KEY_URL "URL"
|
2013-06-23 15:45:50 +02:00
|
|
|
#define G_KEY_FILE_DESKTOP_KEY_DBUS_ACTIVATABLE "DBusActivatable"
|
2013-07-31 20:54:03 +02:00
|
|
|
#define G_KEY_FILE_DESKTOP_KEY_ACTIONS "Actions"
|
2009-02-06 17:03:35 +01:00
|
|
|
-#define G_KEY_FILE_DESKTOP_KEY_GETTEXT_DOMAIN "X-GNOME-Gettext-Domain"
|
|
|
|
+#define G_KEY_FILE_DESKTOP_KEY_GETTEXT_DOMAIN "X-SUSE-Gettext-Domain"
|
|
|
|
|
|
|
|
#define G_KEY_FILE_DESKTOP_TYPE_APPLICATION "Application"
|
|
|
|
#define G_KEY_FILE_DESKTOP_TYPE_LINK "Link"
|