Add g_dc[p]gettext, and use it in gsettings
authorChristian Persch <chpe@gnome.org>
Wed, 19 May 2010 22:54:51 +0000 (00:54 +0200)
committerChristian Persch <chpe@gnome.org>
Thu, 20 May 2010 19:16:29 +0000 (21:16 +0200)
Avoid using LC_MESSAGES, and just call g_d[c]gettext directly.

Bug #617004.

docs/reference/glib/glib-sections.txt
gio/gsettings.c
glib/glib.symbols
glib/gstrfuncs.c
glib/gstrfuncs.h
po/Makefile.in.in

index 79b310d..cdd0a2e 100644 (file)
@@ -2576,6 +2576,7 @@ C_
 N_
 NC_
 g_dgettext
+g_dcgettext
 g_dngettext
 g_dpgettext
 g_dpgettext2
index 3f0f236..9509341 100644 (file)
@@ -794,16 +794,13 @@ g_settings_get_value (GSettings   *settings,
       const gchar *translated;
       GError *error = NULL;
       const gchar *domain;
-      gint lc_category;
 
       domain = g_settings_schema_get_gettext_domain (settings->priv->schema);
 
       if (lc_char == 't')
-        lc_category = LC_TIME;
+        translated = g_dcgettext (domain, unparsed, LC_TIME);
       else
-        lc_category = LC_MESSAGES;
-
-      translated = dcgettext (domain, unparsed, lc_category);
+        translated = g_dgettext (domain, unparsed);
 
       if (translated != unparsed)
         /* it was translated, so we need to re-parse it */
index 48b3748..62abfa8 100644 (file)
@@ -1208,6 +1208,7 @@ g_strdown
 g_strv_length
 g_strip_context G_GNUC_FORMAT(1)
 g_dgettext G_GNUC_FORMAT(2)
+g_dcgettext G_GNUC_FORMAT(2)
 g_dngettext G_GNUC_FORMAT(3)
 g_dpgettext G_GNUC_FORMAT(2)
 g_dpgettext2 G_GNUC_FORMAT(3)
index 8e4b226..db6a5fd 100644 (file)
@@ -3214,6 +3214,33 @@ g_dgettext (const gchar *domain,
 }
 
 /**
+ * g_dgettext:
+ * @domain: (allow-none): the translation domain to use, or %NULL to use
+ *   the domain set with textdomain()
+ * @msgid: message to translate
+ * @category: a locale category
+ *
+ * This is a variant of g_dgettext() that allows specifying a locale
+ * category instead of always using %LC_MESSAGES. See g_dgettext() for
+ * more information about how this functions differs from calling
+ * dcgettext() directly.
+ *
+ * Returns: the translated string for the given locale category
+ * 
+ * Since: 2.26
+ */
+G_CONST_RETURN gchar *
+g_dcgettext (const gchar *domain,
+             const gchar *msgid,
+             int          category)
+{
+  if (domain && G_UNLIKELY (!_g_dgettext_should_translate ()))
+    return msgid;
+
+  return dcgettext (domain, msgid, category);
+}
+
+/**
  * g_dngettext:
  * @domain: the translation domain to use, or %NULL to use
  *   the domain set with textdomain()
index 534f26e..5c7332a 100644 (file)
@@ -250,7 +250,9 @@ G_CONST_RETURN gchar *g_strip_context  (const gchar *msgid,
 
 G_CONST_RETURN gchar *g_dgettext       (const gchar *domain,
                                        const gchar *msgid) G_GNUC_FORMAT(2);
-
+G_CONST_RETURN gchar *g_dcgettext      (const gchar *domain,
+                                       const gchar *msgid,
+                                        int          category) G_GNUC_FORMAT(2);
 G_CONST_RETURN gchar *g_dngettext      (const gchar *domain,
                                        const gchar *msgid,
                                        const gchar *msgid_plural,
index d1c93ba..8361a9c 100644 (file)
@@ -97,7 +97,9 @@ $(srcdir)/$(GETTEXT_PACKAGE).pot: $(POTFILES)
          --add-comments --keyword=_ --keyword=N_ \
          --keyword=C_:1c,2 \
          --keyword=NC_:1c,2 \
+         --keyword=g_dcgettext:2 \
          --keyword=g_dngettext:2,3 \
+         --keyword=g_dpgettext2:2c,3 \
          --flag=N_:1:pass-c-format \
          --flag=C_:2:pass-c-format \
          --flag=NC_:2:pass-c-format \