Reputation: 24363
I am working on translating an application I am developing. I have strings like:
echo _("Welcome to my site");
I can then use the command line to create a .po
file from all the PHP files in a particular directory by doing:
find . -iname "*.php" | xargs xgettext
However, when I import this into Poedit, I see a box called "Notes for translators". This may be useful sometimes, however I can't figure out how to populate it. What code do I need to add to my PHP file so that xgettext will add notes to translators?
Upvotes: 4
Views: 1668
Reputation: 634
In Poedit, you can go to File/Preferences/Extractors menu, select the appropiate language you are extracting (PHP in your case), and then click Edit. Here you can see the command used to extract translations:
xgettext --language=PHP --add-comments=TRANSLATORS: --add-comments=translators: --force-po -o %o %C %K %F
You can see and modify here how additional translator comments are parsed. You can use // TRANSLATORS: your notes
or // translators: your notes
in the line before you use the _('your text')
to add these comments to the code. Example:
// translators: 'practice' is a verb, used on a button as an action.
echo _('practice');
Only one --add-comments
parameter will be active at a time, so // translators:
is set as the default in Poedit.
Upvotes: 3
Reputation: 49044
the help of xgettext shows:
-cTAG, --add-comments=TAG place comment blocks starting with TAG and preceding keyword lines in output file -c, --add-comments place all comment blocks preceding keyword lines in output file
so add in your file by example:
// COMMENTTAG: This is another block comment that will be extracted by xgettext.
And run xgettext with --add-comments=COMMENTTAG
Upvotes: 6