I have a pretty well-working command that extracts strings from all my .js and .html files (which are just Underscore templates). However, it doesn't seem to work for Translator comments.
For example, I have this in one of my .js files:
/// TRANSLATORS: The word "manual" stands for manual process
gettext("manual");
Using the following command:
find . -iname '*.html' -o -iname '*.js' | xargs xgettext --language=Python --from-code=utf-8 --keyword=pgettext:1c,2 --keyword=npgettext:1c,2,3 --add-comments=/
xgettext should extract the comment from the .js file and put it into my .po file like this:
#. TRANSLATORS: The word "manual" stands for manual process
#: tax.js:200
msgid "manual" msgstr ""
But it doesn't. Am I doing something wrong here or are translator comments just not working in Python mode?
EDIT: I have accepted John Flatness' answer as the correct one, however I did find a workaround that enables me to still use the Python mode and extract translator comments. It's not perfect, because it actually leaves some of the syntax inside the comments:
In my tax.js
file:
/*
# This is a translator comment */
gettext("What is this?");
Run this command:
find . -iname '*.html' -o -iname '*.js' | xargs xgettext --language=Python --from-code=utf-8 --keyword=pgettext:1c,2 --keyword=npgettext:1c,2,3 -c
Result in .po file:
#. This is a translator comment */
#: tax.js:201
msgid "What is this?"
msgstr ""
As You can see, the only problems are that:
- I have to write the comment in 2 lines
- The comment terminator
*/
is left in the translator comments
This should not be much of an issue in most cases, though.