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

Peter Funk pf at artcom-gmbh.de
Mon Jan 17 05:49:35 EST 2000


If someone is going to internationalize an application in Python, 
the source will become slightly less readable.  
The following example statements
        print "This is just an annoying message"
	b = Tkinter.Button(text="Foo Bar", ...)
will turn into
        print _("This is just an annoying message")
        b = Tkinter.Button(text=_("Foo Bar"), ...) 
or even more ugly:
        print gettext("This is just an annoying message")
        b = Tkinter.Button(text=gettext("Foo Bar"), ...)
or
        print i18n("This is just an annoying message")
        b = Tkinter.Button(text=i18n("Foo Bar"), ...)

Here the *gettext* method (function) has to return a string, which
is possibly translated into a foreign language.  Since Python already
knows raw string literals, I thought that it would be nice, if a
similar notation could be used to mark i18n string literals.
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.  May be there could be a sys.i18n function which could be 
initially defined as a identity function:
	def i18n(string):
		return(string)
This way preparing applications for i18n would become even easier.
What do you think?

Regards, Peter
-- 
Peter Funk, Oldenburger Str.86, D-27777 Ganderkesee, Germany, Fax:+49 4222950260
office: +49 421 20419-0 (ArtCom GmbH, Grazer Str.8, D-28359 Bremen)




More information about the Python-list mailing list