glib2/glib2-fate300461-gettext-gkeyfile-suse.patch
Dominique Leuenberger cb79a1ee9d Accepting request 1072740 from GNOME:Next
- Update to version 2.76.0:
  + Fix several regressions in handling `GFileInfo` attributes
  + Bugs fixed:
    - ETAG_VALUE not set in GFileInfo when requested
    - File attributes are not set when their value is FALSE/NULL
    - gfile: Fix file size detection when copying on btrfs
    - glocalfileinfo:
      . Mark the lost+found dir as hidden again
      . Ensure that is-backup is always set
  + Updated translations.
- Rebase patches with quilt.
- Update to version 2.75.4:
  + Emit a critical warning when acquiring the notification queue
    during GObject finalization. A type's `finalize()`
    implementation should not call public API that emits property
    notifications.
  + Updated translations.
- Rebase glib2-suppress-schema-deprecated-path-warning.patch with
  quilt.
- Fix license files in packages: COPYING in the source tree is
  a symlink to LICENSES/LGPL-2.1-or-later.txt, but rpm's %license
  macro copies the symlink, not the target. Explicitly package
  LICENSES/LGPL-2.1-or-later.txt in this case (boo#1208497).
- Update to version 2.75.3:
  + Drop the implementation of GSlice, and make the API use the
    system `malloc()` internally.
  + Use a thread-spawning thread to keep thread scheduler settings
    consistent; fixes GThreadPool critical warnings due to failing
    to set scheduler settings in some situations.
  + GIR annotation improvements for multiple APIs.
  + Optimise printing of nested maybes in `g_variant_print()`.
  + Use `tap` test protocol within GLib, and support TAP 13/14.
  + Fix a regression in glib-compile-schemas 2.75.2 causing schemas
    and override files to be sorted incorrectly.
  + Support per-desktop overrides in `GSettingsAction`.
  + Various optimisations to `GString`.
  + Reduce allocations in message printing functions if there’s
    nothing to format.
  + Add inline version of `g_strdup()`, allowing the compiler to do
    `NULL` folding and constant folding on `strlen()` calls.
  + Add a `GPathBuf` API for building and manipulating file paths.
  + Add `g_string_free_and_steal()` and use it to warn on unused
    results from`g_string_free (_, FALSE)`.
  + Add `g_free_sized()` and `g_aligned_free_sized()` to mirror the
    upcoming `free_sized()` function in C23; use these if porting
    away from `g_slice_free()`.
  + Fix underspecified dependencies on generated headers in
    `meson.build`, which should reduce spurious build failures.
  + Updated translations.
- Update to version 2.75.2:
  + Add `g_ptr_array_sort_values()` and
    `g_ptr_array_sort_values_with_data()` APIs.
  + Some fixes for activation of UWP apps on Windows.
  + Support Markdown output from `gdbus-codegen`.
- Changes from version 2.75.1:
  + Add new `GFileInfo` properties for large thumbnails.
  + Fix missing input validation in `GDBusMenuModel`.
  + Change default `g_desktop_app_info_search()` algorithm to
    include substring matches.
  + Various GVariant security fixes when handling untrusted data.
  + Add support for XDG Activation protocol in `GAppLaunchContext`.
  + Return `application/x-zerosize` rather than `text/plain` as
    content type for empty files.
  + Deprecate `-Druntime_libdir` configure option because it was
    unused.
  + Check for snap plugs when accessing portals.
  + Add `GArray` and `GPtrArray` constructors to take or copy C
    arrays.
  + Add `GHashTable` methods to get and steal hash table keys and
    values as `GPtrArray`s.
  + Change the default D-Bus system bus socket address from
    `/var/run/dbus/system_bus_socket` to
    `/run/dbus/system_bus_socket`, in line with changes in
    dbus.git.
- Drop glib2-dbus-socket-path.patch: fixed upstream.

OBS-URL: https://build.opensuse.org/request/show/1072740
OBS-URL: https://build.opensuse.org/package/show/GNOME:Factory/glib2?expand=0&rev=507
2023-03-20 12:47:33 +00:00

172 lines
5.4 KiB
Diff

Index: glib-2.75.4/glib/gkeyfile.c
===================================================================
--- glib-2.75.4.orig/glib/gkeyfile.c
+++ glib-2.75.4/glib/gkeyfile.c
@@ -520,6 +520,7 @@ struct _GKeyFile
gboolean checked_locales; /* TRUE if @locales has been initialised */
gchar **locales; /* (nullable) */
gchar *gettext_domain;
+ gchar *file_basename;
gint ref_count; /* (atomic) */
};
@@ -647,6 +648,7 @@ g_key_file_init (GKeyFile *key_file)
key_file->list_separator = ';';
key_file->flags = 0;
key_file->gettext_domain = NULL;
+ key_file->file_basename = NULL;
}
static void
@@ -673,6 +675,12 @@ g_key_file_clear (GKeyFile *key_file)
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)
{
@@ -817,6 +825,39 @@ find_file_in_data_dirs (const gchar *f
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,
@@ -898,6 +939,9 @@ g_key_file_load_from_fd (GKeyFile
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;
}
@@ -954,6 +998,8 @@ g_key_file_load_from_file (GKeyFile
return FALSE;
}
+ key_file->file_basename = g_path_get_basename (file);
+
return TRUE;
}
@@ -1015,6 +1061,9 @@ g_key_file_load_from_data (GKeyFile
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;
}
@@ -1119,6 +1168,9 @@ g_key_file_load_from_dirs (GKeyFile
}
}
+ if (found_file)
+ key_file->file_basename = g_path_get_basename (output_path);
+
if (found_file && full_path)
*full_path = output_path;
else
@@ -2326,14 +2378,40 @@ g_key_file_get_locale_string (GKeyFile
{
gboolean codeset_set;
const gchar *translated;
- gboolean has_gettext;
+ gboolean has_gettext = FALSE;
- 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);
Index: glib-2.75.4/glib/gkeyfile.h
===================================================================
--- glib-2.75.4.orig/glib/gkeyfile.h
+++ glib-2.75.4/glib/gkeyfile.h
@@ -322,7 +322,7 @@ gboolean g_key_file_remove_group
#define G_KEY_FILE_DESKTOP_KEY_URL "URL"
#define G_KEY_FILE_DESKTOP_KEY_DBUS_ACTIVATABLE "DBusActivatable"
#define G_KEY_FILE_DESKTOP_KEY_ACTIONS "Actions"
-#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"