Re: [Zope3-dev] i18n, unicode, and the underline

Top Page

Reply to this message
Author: Barry Warsaw
Date:  
To: Guido van Rossum
CC: Stephan Richter, Gary Poster, zope3-dev
Subject: Re: [Zope3-dev] i18n, unicode, and the underline
On Fri, 2003-04-11 at 11:44, Barry Warsaw wrote:

> Ok, given this, I'm fine with allowing human readable messages in Zope's
> Python code be marked with _('str') when 'str' is us-ascii. If it's
> anything else, you must use _(u'ustr'). If you screw up you'll get an
> exception at the earliest possible point -- a good thing.


BTW, this Just Works already!

Here's the twisty maze...

_ is usually bound to a MessageIDFactory instance. When this instance
is called, e.g. _('str') it creates a MessageID object, and /that/ is a
subclass of unicode. The __new__() for MessageID is essentially
equivalent to calling unicode(str) with no codec, which is exactly what
Guido suggested.

Neat!

-Barry



_______________________________________________
Zope3-dev mailing list
Zope3-dev@???
http://mail.zope.org/mailman/listinfo/zope3-dev