[gtk+] Cleanup some translation handling
- From: Matthias Clasen <matthiasc src gnome org>
- To: svn-commits-list gnome org
- Subject: [gtk+] Cleanup some translation handling
- Date: Mon, 15 Jun 2009 18:30:08 -0400 (EDT)
commit de3cc277064937727e2f728113e0d63c64aa3bb8
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Jun 15 18:04:49 2009 -0400
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.
gdk-pixbuf/gdk-pixbuf-io.c | 2 +-
gdk-pixbuf/gdk-pixdata.c | 7 ++++---
gdk/x11/gdkapplaunchcontext-x11.c | 8 ++++----
gtk/gtkbuilderparser.c | 36 +-----------------------------------
po/Makefile.in.in | 2 ++
5 files changed, 12 insertions(+), 43 deletions(-)
---
diff --git a/gdk-pixbuf/gdk-pixbuf-io.c b/gdk-pixbuf/gdk-pixbuf-io.c
index abb9203..b5036c8 100644
--- a/gdk-pixbuf/gdk-pixbuf-io.c
+++ b/gdk-pixbuf/gdk-pixbuf-io.c
@@ -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);
}
diff --git a/gdk-pixbuf/gdk-pixdata.c b/gdk-pixbuf/gdk-pixdata.c
index e9cdf8f..ed60ab5 100644
--- a/gdk-pixbuf/gdk-pixdata.c
+++ b/gdk-pixbuf/gdk-pixdata.c
@@ -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;
}
diff --git a/gdk/x11/gdkapplaunchcontext-x11.c b/gdk/x11/gdkapplaunchcontext-x11.c
index 106fcf5..3dace4a 100644
--- a/gdk/x11/gdkapplaunchcontext-x11.c
+++ b/gdk/x11/gdkapplaunchcontext-x11.c
@@ -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)
diff --git a/gtk/gtkbuilderparser.c b/gtk/gtkbuilderparser.c
index c5cb2d8..f6f12a5 100644
--- a/gtk/gtkbuilderparser.c
+++ b/gtk/gtkbuilderparser.c
@@ -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);
diff --git a/po/Makefile.in.in b/po/Makefile.in.in
index 28a3d40..2a65416 100644
--- a/po/Makefile.in.in
+++ b/po/Makefile.in.in
@@ -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 \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]