[glib] Add g_dc[p]gettext, and use it in gsettings
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Add g_dc[p]gettext, and use it in gsettings
- Date: Thu, 20 May 2010 19:17:29 +0000 (UTC)
commit 41b3f6885d26908627c8a132f63aab4ba1d83582
Author: Christian Persch <chpe gnome org>
Date: Thu May 20 00:54:51 2010 +0200
Add g_dc[p]gettext, and use it in gsettings
Avoid using LC_MESSAGES, and just call g_d[c]gettext directly.
Bug #617004.
docs/reference/glib/glib-sections.txt | 1 +
gio/gsettings.c | 7 ++-----
glib/glib.symbols | 1 +
glib/gstrfuncs.c | 27 +++++++++++++++++++++++++++
glib/gstrfuncs.h | 4 +++-
po/Makefile.in.in | 2 ++
6 files changed, 36 insertions(+), 6 deletions(-)
---
diff --git a/docs/reference/glib/glib-sections.txt b/docs/reference/glib/glib-sections.txt
index 79b310d..cdd0a2e 100644
--- a/docs/reference/glib/glib-sections.txt
+++ b/docs/reference/glib/glib-sections.txt
@@ -2576,6 +2576,7 @@ C_
N_
NC_
g_dgettext
+g_dcgettext
g_dngettext
g_dpgettext
g_dpgettext2
diff --git a/gio/gsettings.c b/gio/gsettings.c
index 3f0f236..9509341 100644
--- a/gio/gsettings.c
+++ b/gio/gsettings.c
@@ -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 */
diff --git a/glib/glib.symbols b/glib/glib.symbols
index 48b3748..62abfa8 100644
--- a/glib/glib.symbols
+++ b/glib/glib.symbols
@@ -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)
diff --git a/glib/gstrfuncs.c b/glib/gstrfuncs.c
index 8e4b226..db6a5fd 100644
--- a/glib/gstrfuncs.c
+++ b/glib/gstrfuncs.c
@@ -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()
diff --git a/glib/gstrfuncs.h b/glib/gstrfuncs.h
index 534f26e..5c7332a 100644
--- a/glib/gstrfuncs.h
+++ b/glib/gstrfuncs.h
@@ -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,
diff --git a/po/Makefile.in.in b/po/Makefile.in.in
index d1c93ba..8361a9c 100644
--- a/po/Makefile.in.in
+++ b/po/Makefile.in.in
@@ -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 \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]