Add g_dc[p]gettext, and use it in gsettings

Avoid using LC_MESSAGES, and just call g_d[c]gettext directly.

Bug #617004.
This commit is contained in:
Christian Persch 2010-05-20 00:54:51 +02:00
parent e8f723245a
commit 41b3f6885d
6 changed files with 36 additions and 6 deletions

View File

@ -2576,6 +2576,7 @@ C_
N_
NC_
g_dgettext
g_dcgettext
g_dngettext
g_dpgettext
g_dpgettext2

View 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 */

View 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)

View File

@ -3213,6 +3213,33 @@ g_dgettext (const gchar *domain,
return dgettext (domain, msgid);
}
/**
* 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

View 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,

View 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 \