Proposal: i-String literals in Future Version of Python?

François Pinard pinard at iro.umontreal.ca
Mon Jan 17 13:56:04 EST 2000


pf at artcom-gmbh.de (Peter Funk) writes:

> So that some magic in the python interpreter expands
> 	print i"This is just a message"
> into a call to a gettext function internally, if such a function is
> available.

That might be nice, but it would not be sufficient, as the textual
domain for the translation is not specified.  It should be in some way.
The textual domain cannot be specified once for a whole program, as a
program can be made up of libraries pertaining to different translation
domains, and execution control might fly like hell between libraries :-).
If i"Text" was to call gettext automatically, the Python interpreter would
also need to know, on a per file basis, which textual domain to use.

Our best bet, right now, is sticking to _("text") for immediate translation,
and to ''"text" for deferred translation.  The value of `_' should be a
bound function into an instance of a Translation class, in which the textual
domain has been frozen (as I sketched in a recent message).  Each module
or file would initialise its global `_' by calling a convenience function
accepting a textual domain name, and retrieving the bound function for
the proper textual domain name, creating on the fly a new instance of the
Translation class, as necessary.

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard






More information about the Python-list mailing list