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

sathya sathya@zeomega.com
Fri, 11 Apr 2003 11:05:06 -0500


  i am assuming "s" is logically equivalent to u"s"   
from what i understand the po files contain these strings as indexes and 
so  does it matter if the index is a unicode string or an ascii string ?
at run time _() should simply substitute whatever is in the po database 
?  (i know there is no such thing as a dumb question ;)
 

Barry Warsaw wrote:

>On Fri, 2003-04-11 at 11:29, Guido van Rossum wrote:
>
>  
>
>>Before this misinformation spreads, Barry underestimates unicode()!
>>
>>Without an encoding argument, unicode(u) accepts a unicode string and
>>returns it unchanged, and unicode(s) also accepts an 8-bit string and
>>attempts to convert it using the ASCII encoding -- exactly what _()
>>should do.
>>    
>>
>
>Why, I didn't know that!  BTW, using any encoding argument causes a
>TypeError.  I guess that makes sense.
>
>  
>
>>Of course, concatenating u"" works exactly the same.  And according to
>>timeit, it's more than twice as fast!
>>
>>[guido@odiug linux]$ ./python ../Lib/timeit.py -s 's=""' 'unicode(s)'
>>1000000 loops, best of 3: 1.43 usec per loop
>>[guido@odiug linux]$ ./python ../Lib/timeit.py -s 's=""' 's+u""'
>>1000000 loops, best of 3: 0.668 usec per loop
>>    
>>
>
>LOL!
>
>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.
>
>I'd like Zope developers to get in the habit of wrapping messages in _()
>all the time, so that we rarely see unmarked Unicode strings.  By
>infusing this in the culture now we can make it much easier to translate
>future Zope versions, products, etc.
>
>I'll work on adding this to Zope.
>-Barry
>
>
>
>_______________________________________________
>Zope3-dev mailing list
>Zope3-dev@zope.org
>http://mail.zope.org/mailman/listinfo/zope3-dev
>  
>