Cleanup some translation handling

Use g_*gettext functions in gdk-pixbuf instead direct gettext
calls to benefit from the maybe-dont-translate functionality
in GLib. Also, replace a hand-rolled version by g_dpgettext2
in gtkbuilderparser.c. Fixes bug 585791.
This commit is contained in:
Matthias Clasen 2009-06-15 18:04:49 -04:00
parent 362127c33c
commit de3cc27706
5 changed files with 12 additions and 43 deletions

View File

@ -2459,7 +2459,7 @@ gdk_pixbuf_format_get_description (GdkPixbufFormat *format)
domain = format->domain;
else
domain = GETTEXT_PACKAGE;
description = dgettext (domain, format->description);
description = g_dgettext (domain, format->description);
return g_strdup (description);
}

View File

@ -428,9 +428,10 @@ gdk_pixbuf_from_pixdata (const GdkPixdata *pixdata,
{
g_set_error (error, GDK_PIXBUF_ERROR,
GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
ngettext("failed to allocate image buffer of %u byte",
"failed to allocate image buffer of %u bytes",
pixdata->rowstride * pixdata->height),
g_dngettext(GETTEXT_PACKAGE,
"failed to allocate image buffer of %u byte",
"failed to allocate image buffer of %u bytes",
pixdata->rowstride * pixdata->height),
pixdata->rowstride * pixdata->height);
return NULL;
}

View File

@ -312,10 +312,10 @@ _gdk_windowing_get_startup_notify_id (GAppLaunchContext *context,
else if (files_count == 1)
description = g_strdup_printf (_("Opening %s"), get_display_name (files->data));
else
description = g_strdup_printf (dngettext (GETTEXT_PACKAGE,
"Opening %d Item",
"Opening %d Items",
files_count), files_count);
description = g_strdup_printf (g_dngettext (GETTEXT_PACKAGE,
"Opening %d Item",
"Opening %d Items",
files_count), files_count);
icon_name = NULL;
if (priv->icon_name)

View File

@ -893,40 +893,6 @@ start_element (GMarkupParseContext *context,
element_name);
}
/* This function is taken from gettext.h
* GNU gettext uses '\004' to separate context and msgid in .mo files.
*/
static const char *
_dpgettext (const char *domain,
const char *msgctxt,
const char *msgid)
{
size_t msgctxt_len = strlen (msgctxt) + 1;
size_t msgid_len = strlen (msgid) + 1;
const char *translation;
char* msg_ctxt_id;
msg_ctxt_id = g_alloca (msgctxt_len + msgid_len);
memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
msg_ctxt_id[msgctxt_len - 1] = '\004';
memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
translation = g_dgettext (domain, msg_ctxt_id);
if (translation == msg_ctxt_id)
{
/* try the old way of doing message contexts, too */
msg_ctxt_id[msgctxt_len - 1] = '|';
translation = g_dgettext (domain, msg_ctxt_id);
if (translation == msg_ctxt_id)
return msgid;
}
return translation;
}
gchar *
_gtk_builder_parser_translate (const gchar *domain,
const gchar *context,
@ -935,7 +901,7 @@ _gtk_builder_parser_translate (const gchar *domain,
const char *s;
if (context)
s = _dpgettext (domain, context, text);
s = g_dpgettext2 (domain, context, text);
else
s = g_dgettext (domain, text);

View File

@ -93,6 +93,8 @@ all-no:
$(srcdir)/$(GETTEXT_PACKAGE).pot: $(POTFILES)
$(XGETTEXT) --default-domain=$(GETTEXT_PACKAGE) --directory=$(top_srcdir) \
--add-comments --keyword=_ --keyword=N_ --keyword=C_:1c,2 --keyword=NC_:1c,2 \
--keyword=g_dngettext:2,3 \
--flag=g_dngettext:2:pass-c-format \
--flag=g_strdup_printf:1:c-format \
--flag=g_string_printf:2:c-format \
--flag=g_string_append_printf:2:c-format \