Xgettext - extract translatable strings and update .pot

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

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

Is this the preferred way to update the template so that old messages are also saved? Another question is how to distinguish between translatable strings from regular strings in the source code. I assume xgettext will pull all the lines from the mentioned source code file.

It would be great if anyone could share the right approach ... Thanks

+4
source share
2 answers

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

Please 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 
+3
source

The easiest way to achieve this:

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

You do not need -j , --join-existing , because xgettext accepts .po and .pot as regular input files.

The -j , --join-existing option is rarely useful. In combination with -D , --directory it causes the sample.pot output file used as the input file to not be executed in the directory list. If you use -lc , --language=c , you need -j , --join-existing , because sample.pot is otherwise parsed as the source C / C ++ file.

In addition, -o sample.pot , --output=sample.pot has the same effect as -d sample , --default-domain=sample . You can safely omit one of them.

+1
source

Source: https://habr.com/ru/post/1337531/


All Articles