I am currently trying to implement internationalization in an application (Python 2.6) and have run into an error involving string formatting. A string marked translatable looks like this:
foo = _("I would like to have %d pounds of cheese" % amount)
Running pygettext
on my source tree then complains when it hits this line:
$ pygettext .
*** ./foobar.py:45: Seen unexpected token "%"
The resulting messages.pot
file does not contain the string after pygettext has done its work.
What is the way to go for string formatting with gettext?
Translate the unreplaced string. Or replace on the translated string.
foo = _("I would like to have %d pounds of cheese") % amount