How to use xgettext iteratively to update .po files for translation

I use xgettext to help translate a large code base, and I have two questions:

  • If I have one .po file for each language, is there an easy way to update them all using one xgettext scan for the codebase, or do I need to run xgettext once for each language?
  • If I add the target langauge to the .po file header with poedit , it seems that xgettext overwrites this with the default headers. How can i stop this?

Perhaps I am using the wrong tool, in which case suggestions are welcome. I want to be able to scan code and update .po files with any new lines, but leaving the header information intact.

EDIT: I know that poedit can scan code, but I was hoping to find a command line application to run the scan to simplify the process.

+3
source share
1 answer

Yes, basically you use the tools incorrectly.

xgettextextracts tags and creates a template file. (e.g. * .pot file)

The command msgmergeupdates the .po file with the changes from the .pot file.

We have rules for updating .po files as shown below:

%.en.po : %.pot
    -[ -e $@ ] && msgmerge --width=110 --update $@ $<
    [ -e $@ ] || cp $< $@
+8
source

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


All Articles