[Python-Dev] *Simpler* string substitutions
Matthias Urlichs
smurf@noris.de
Fri, 21 Jun 2002 22:46:52 +0200
Aahz:
> On Thu, Jun 20, 2002, Gustavo Niemeyer wrote:
> >
> > "Serving HTTP on", sa[0], "port", sa[1], "..."
>
_("Serving HTTP on ${addr} port ${port}").sub(addr=sa[0], port=sa[1])
_("Serving HTTP on ${sa[0]} port ${sa[1]}").sub()
or some equivalent syntax.
Note that the second way, above, has a distinct disadvantage for the
translating person. He or she would probably know what "addr" stands
for, but what is a "sa[0]" ???
> This is where current string handling comes up short. What's the
> correct way to internationalize this string?
Currently, you do the same thing but use % and a dictionary. As I
said, equivalent syntax.
> What if the person
> handling I18N isn't a Python programmer?
>
The person gets frustrated and bitches at the programmer until the
programmer fixes the code...
--
Matthias Urlichs