Search code examples
gettextxgettext

Generating context (msgctxt) using xgettext


I'm trying to generate msgctxt lines using xgettext. It is not clear to me how to define context in the keyword option. The documentation uses the term contextargnumc, but doesn't give a clear example what it should look like. My best guess is that it's supposed to be an index number with c after it since the default keyword specifications have that kind of syntax. This does not work and I can't figure out an alternative.

My code looks like this

LOCALIZE("Context","Test");

When I run xgettext with

--keyword=LOCALIZE:1,2

I get plural like the documentation claims.

msgid "Context"
msgid_plural "Test"
msgstr[0] ""
msgstr[1] ""

When I add c and run xgettext with

--keyword=LOCALIZE:1c,2

I don't get anything.

Am I missing something or is the context supposed to be defined somehow else?


Solution

  • Found the culprit. Seems to have been a mix between xgettext versions.

    My system had an install of GnuWin which has an old version of gettext. I had installed the latest gettext package in Cygwin and used that for my tests. Cygwin was showing that the version of gettext was the latest, but for some reason xgettext was pointing to the GnuWin version.

    Moved to use the latest version of xgettext and got msgctxt out with the c after index number.