Re: Add translation contexts



To: GNOME-i18n
Cc: TP list

On 20/09/2007, at 3:16 PM, Sven Neumann wrote:

I want to patch Balsa to add context informations but the strings are
used in a initializer so the macro Q_ is not appropriated:

Index: libbalsa/source-viewer.c
===================================================================
--- libbalsa/source-viewer.c    (révision 7714)
+++ libbalsa/source-viewer.c    (copie de travail)
@@ -40,9 +40,12 @@
 /* Normal items */
 static GtkActionEntry entries[] = {
     /* Top level */
-    {"FileMenu", NULL, N_("_File")},
-    {"EditMenu", NULL, N_("_Edit")},
-    {"ViewMenu", NULL, N_("_View")},
+    /* This is the text that should appear on a menu title.
+     * Don't include the prefix 'menu title|' in the translation.
+     */
+    {"FileMenu", NULL, Q_("menu title|_File")},
+    {"EditMenu", NULL, Q_("menu title|_Edit")},
+    {"ViewMenu", NULL, Q_("menu title|_View")},
     /* Items */
     {"Close", GTK_STOCK_CLOSE, N_("_Close"), "<control>W",
      N_("Close the window"), G_CALLBACK(close_cb)},

Does anyone have a solution?

______

The solution is to add context and to use N_() in the initializer. Then,
in the code where gettext() is currently used to translate the struct
entry, this code needs to be changed to use g_strip_context(). Here's an
example from the GIMP source code for translating a GtkActionEntry
label:

label = g_strip_context (entries[i].label, gettext (entries [i].label));

Is this adding context in the string headers (deprecated), or using the new msgctxt feature from gettext (recommended)?

If you're using msgctxt, it should work. If not, the gettext devs. can advise. :)

from Clytie

Vietnamese Free Software Translation Team
http://vnoss.net/dokuwiki/doku.php?id=projects:l10n



Attachment: PGP.sig
Description: This is a digitally signed message part



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]