Re: What is the proper way of markig translations of static array initializers



Alexander Shopov wrote:
The context is stripped when the string is *used*, for
marking it is irrelevant whether it has context or not, so
mark it normally with N_().
I am sorry but this does not work.

When I mark strings simply with N_() the context information is not
stripped away - in fact the original string in English gets shown *with*
the context info - no translation gets shown even though the string is
translated.

You need to mark the strings in the static initialiser using N_() only,
and then when you actually *use* the strings, use Q_() to do the
translation while stripping the context.

So something like this should work:

{
    static const char *stuff[] = {
        N_("Button label|I like strings"),
        N_("Menu label|This is another string"),
        NULL,
    };
    int i;

    for(i = 0; stuff[i]; ++i)
        printf("Translated string is: %s\n", Q_(stuff[i]));
}

        -brian




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