If you can, I would strongly recommend using the Zope3/Five way of doing translations and i18n in general! See here: http://worldcookery.com/files/fivei18n/ http://codespeak.net/z3/five/i18n.html I've made my site fully internationalized, localized and utf-8 using this method without resorting to any "trickery". setdefaultencoding() is apparently frowned upon ... Not sure why though. Good luck! J.F. -----Original Message----- From: zope-bounces@zope.org [mailto:zope-bounces@zope.org] On Behalf Of Patrick Ulmer Sent: August 24, 2007 04:27 To: zope@zope.org Subject: Re: [Zope] utf-8 problem in Zope when using Localizer Hi, I think I solved the problem. <dtml-var "MessageCatalog('Hallo Welt!').encode('utf-8')"> works. I read some further and found out that I should use something like import sys sys.setdefaultencoding('utf-8') I set it global in sitecustomize.py under /usr/lib/python2.4/site-packages and then <dtml-var "MessageCatalog('Hallo Welt!')"> works. Now I only must find the right place for setdefaultencoding() so it only affect my zope-instance. Regars Patrick Patrick Ulmer schrieb:
I think it's the right way for a solution. Now my page is utf-8, but if the string returned from MessageCatalog have utf-8 chars and not online chars in ascii range I get this error-message:
Error Type: UnicodeEncodeError Error Value: 'ascii' codec can't encode character u'\xf4' in position 3: ordinal not in range(128)
Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )