Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gettext does not flag python format strings with "python-format" unlike old style python strings with format specifiers

It seems that gettext is not able to recognise Python format strings with replacement fields properly and hence does not flag them as "python-format". E.g.

ugettext("This is a sample format string with a {kwarg}").format(kwarg='key word argument')

However, gettext identifies Python strings with format specifiers properly and flags such source strings with "python-format", e.g.,

ugettext("This is a sample string with a %(format_spec).") % {'format_spec': 'format specifier'}

I have tried using xgettext and Django's manage.py makemessages tools to generate PO files for Python format strings, but didn't see the Python format strings being flagged as "python-format".

Also, http://www.gnu.org/software/gettext/manual/html_node/Python.html does not specify anything about the new Python format strings.

Please help me find a work around for this issue.

like image 458
rtnpro Avatar asked Dec 04 '25 23:12

rtnpro


1 Answers

I suppose you are being hit by this bug: the gettext tools support only the old Python string format for substitutions. So you should use old string format. Or you can use a different tool for doing your translations.

like image 98
Vicent Avatar answered Dec 07 '25 14:12

Vicent



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!