David Planella <david.plane...@ubuntu.com> added the comment:

It would be nice that %-formatting had the same functionality as in C when it 
comes to discarding unnamed arguments, but from the comments I understand that 
being deprecated no changes in functionality are contemplated.

However, before recommending using str.format, the fact that gettext does not 
yet seem to support it should also be taken into account. Some examples:

= %-formatting =

print gettext.ngettext("%(package)d package", "%(package)d packages", 
countInstall) % { 'package': countInstall}

Renders the following in a POT template:

#, python-format
msgid "%(package)d package"
msgid_plural "%(package)d packages"
msgstr[0] ""
msgstr[1] ""

-- All good. The string is marked as a python-format one and the %(package) 
argument can be dropped in the translation for the languages which need it. No 
program crash.

= str.format() formatting =

print gettext.ngettext("{no_of_packages} package", "{no_of_packages} packages", 
countInstall).format(no_of_packages=countInstall)

Renders the following in a POT template:

msgid "{no_of_packages} package"
msgid_plural "{no_of_packages} packages"
msgstr[0] ""
msgstr[1] ""

-- Not marked as python-format, since gettext does not seem to support the {} 
notation. No error-checking can take place for arguments. Not good.

print _("{day} day").format(day=countInstall)

msgid "{day} day"
msgstr ""

-- Same comment as above.

print _("{0} package").format(countInstall)

Extracted string in a POT template:

msgid "{0} package"
msgstr ""

-- Same comment as above

I understand that part of the error is in gettext, but I thought I'd mention it 
here as well, since this has caused quite a lot of crashes in Hebrew and Arabic 
translations in Ubuntu in the past, and will continue to do it until addressed.

----------
nosy: +dpm

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue8359>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to