Paul Dixon
Paul Dixon

Reputation: 300975

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

I'm looking at using xgettext to aid translation of large codebase, and I have two questions:

Maybe I'm using the wrong tool, in which case suggestions are welcome. What I want is to be able to scan the code and update the .po files with any new strings, but leaving any header information intact.

EDIT: I know that poedit can scan code, but I was hoping to find a command line application to perform the scanning to automate the process more easily.

Upvotes: 6

Views: 5165

Answers (1)

Douglas Leeder
Douglas Leeder

Reputation: 53320

Yes, basically you're using the tools wrong.

xgettext extracts the tags and creates the template file. (e.g. *.pot file)

The msgmerge command updates a .po file with changes from the .pot file.

We have make rules to update the .po files, like the one below:

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

Upvotes: 13

Related Questions