[Python-Dev] PEP 215 redux: toward a simplified consensus?

Paul Prescod paul@prescod.net
Mon, 25 Feb 2002 13:46:46 -0800


Jeff Epler wrote:
> 
> On Mon, Feb 25, 2002 at 01:18:57PM -0800, Neil Schemenauer wrote:
> > Jeff Epler wrote:
> > > But how do you internationalize your program once you use $-subs?
> >
> > So don't use them.  What's the problem?
> 
> The problem is when I have to internationalize a program some schmuck
> wrote using $-subs throughout.

I think you go through and remove the "$" signs (probably at the same
time you are removing "_") and use a runtime function to do the
translation (probably the same function doing the interpolation). Then
you take on the responsibility yourself for making sure that the
original string is a constant (not a user-supplied variable) and that
the replacement strings come from somewhere secure.

So:

a = $"Hello there $name"

becomes:

a = _("Hello there $name")

I think Barry's gettext already does that or something, doesn't it?

 Paul Prescod