Re: Using gettext with a GOptionEntry



Kevin DeKorte wrote:
Hi,

I'm trying to use gettext to do translation on a GOptionEntry table,
currently this works as is, but the text isn't translated.

static GOptionEntry entries[] = {
    {"window", NULL, 0, G_OPTION_ARG_INT, &embed_window, "Window to
embed in", "WID"},
    {"playlist", NULL, 0, G_OPTION_ARG_NONE, &playlist, "File Argument
is a playlist", NULL},
    {NULL}
};

I tried this

static GOptionEntry entries[] = {
    {"window", NULL, 0, G_OPTION_ARG_INT, &embed_window, _("Window to
embed in"), "WID"},
    {"playlist", NULL, 0, G_OPTION_ARG_NONE, &playlist, _("File Argument
is a playlist"), NULL},
    {NULL}
};

But it won't compile. Using _() works on my other strings that are in
other areas. So what is the best way to setup this entries variable and
allow it to use translation.
This is by no means GTK+-related, and a very basic question regarding
gettext usage.

Use the N_() macro, something like this:

static GOptionEntry entries[] = {
    {"window", NULL, 0, G_OPTION_ARG_INT, &embed_window, N_("Window to
embed in"), "WID"},
...

I'll leave it up to you to research about N_() and discover how and why
it works.

-- 
One of the most striking differences between a cat and a lie is that a
cat has
only nine lives.
        -- Mark Twain, "Pudd'nhead Wilson's Calendar"

Eduardo M KALINOWSKI
ekalin bol com br
http://move.to/hpkb




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