I've a build script that scan source dir (PHP) and execute the xgettext --join-existing ...
for updated translation and save into a pot file, e.g.
find . -type f -name '*.php' -not -path './vendor/*' |
xargs xgettext --join-existing --keyword=_e --keyword=_x
--keyword=__ --from-code=UTF-8 --default-domain=myapp
--output=languages/myapp/myapp.pot
I don't know why, after several times of code refactoring and building, the pot file will have something like this
#: src/Member/Auth.php:196
#: src/Member/Auth.php:135
msgid "Login failed!"
msgstr ""
Why there are two lines of source/line in the comment? (I guess it was due to we've moved the message around in the source.)
So, how to make the xgettext ignore if the same file has updated content?
Or should I not recommend to use
--join-existing
in the build script? (But sometimes we have manual item in the pot file, so how to solve?)
Sounds logically that
xgettext
appends information (even source reference), because it is explicitly set with the option--join-existing
. But following workarounds could help.Workaround 1
Remove previous source references from the pot file with sed before building the new pot:
Workaround 2
Do not use the option
--join-existing
and place the manual items in a dummy php file.