[Python-Dev] string formatting and i18n
Barry Warsaw
barry at python.org
Mon Sep 5 18:47:04 CEST 2005
On Mon, 2005-09-05 at 12:07, Antoine Pitrou wrote:
> Uh, what about internationalization (i18n) ?
> In i18n you can't avoid the need for parameterized strings.
> For example I want to write :
> _("The file '%s' is read only") % filename
> not :
> _("The file") + " '" + filename + "' " + _("is read only")
>
> because the splitting in the second form will not translate correctly
> into other languages. You *have* to supply the whole non-splitted
> sentence to the translators.
Actually, this was part of the motivation behind PEP 292 and Template
strings, because what you really want is named parameters, not
positional parameters:
'The file $filename in directory $dir is read only'
There are a few techniques for getting full i18n for Template strings.
-Barry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 307 bytes
Desc: This is a digitally signed message part
Url : http://mail.python.org/pipermail/python-dev/attachments/20050905/059efe4b/attachment.pgp
More information about the Python-Dev
mailing list