Search code examples
c++cgettextxgettext

xgettext - extract translatable strings and update .pot


I have inherited a sample.pot file. Now, I have added new messages in a1.c and a2.cpp. Is it possible for me to use xgettext and output the contents to same sample.pot instead of creating a new one? Eg:-

xgettext -d sample -s -o sample.pot a1.c
xgettext -d sample -s -o sample.pot a2.cpp

Is this preferred way to go in order to update the template such that old messages are also preserved? The other question is how do we distinguish translatable strings from normal strings in source code. I assume xgettext will pull all strings from mentioned source code file.

It would be great if anybody can share the correct approach..Thanks


Solution

  • Does the -j, --join-existing option ("join messages with existing file") not do what you need?

    Note that you can specify more than one input file on the command line.

    xgettext -d sample -s -j -o sample.pot a1.c a2.cpp