views:

233

answers:

1

I'm internationalizing a python program and cant get plural forms into the .pot file. I have marked string that require plural translations with a _pl() eg.

self.write_info(_pl("%(num)d track checked", "%(num)d tracks checked", song_obj.song_count) % {"num" : song_obj.song_count})

Then I'm running: xgettext --language=Python --keyword=_pl --output=output.pot *.py Only the first (singular) string is generated in the pot file.

+1  A: 

I haven't used this with Python, and can't test at the moment, but try --keyword=_pl:1,2 instead.

From the GNU gettext docs:

--keyword[=keywordspec]’ Additional keyword to be looked for (without keywordspec means not to use default keywords).

If keywordspec is a C identifier id, xgettext looks for strings in the first argument of each call to the function or macro id. If keywordspec is of the form ‘id:argnum’, xgettext looks for strings in the argnumth argument of the call. If keywordspec is of the form ‘id:argnum1,argnum2’, xgettext looks for strings in the argnum1st argument and in the argnum2nd argument of the call, and treats them as singular/plural variants for a message with plural handling.

DNS
Thanks for your help, this worked correctly.
wodemoneke