List Info

Thread: i18n and genshi => UnicodeDecodeError




i18n and genshi => UnicodeDecodeError
country flaguser name
United States
2007-09-27 10:20:14
Hi, I'm trying to use genshi.i18n.Translator module to
translate TEXT
nodes in my web pages.

The stream is generated using XML object and I apply the
filter
"Translator(gettext)" to this stream :
It results in a UnicodeDecodeError (in File
"build/bdist.linux-i686/
egg/genshi/filters/i18n.py", line 181, in __call__).

The data field in the stream causing that is :
- kind : TEXT
- data : "Paramètres"
data is a unicode object and file parsed by XML is UTF-8
encoded.

If I insert a filter "spy" before the Translator
and I replace data
by :
unicode("Paramètres","UTF-8")
it's working fine.

I tought : maybe the data field of the stream is just in the
wrong
format and I tryied with :
unicode(data.encode("UTF-8"),"UTF-8")
But the result is the same : a UnicodeDecodeError.

maybe I'm doing something else wrong, if somebody has an
idea, please
let me know.

Thank you

Tristan LELONG


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Genshi" group.
To post to this group, send email to genshigooglegroups.com
To unsubscribe from this group, send email to
genshi-unsubscribegooglegroups.com
For more options, visit this group at http://gr
oups.google.com/group/genshi?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: i18n and genshi => UnicodeDecodeError
country flaguser name
Germany
2007-09-27 10:28:51
Am 27.09.2007 um 17:20 schrieb blunderer:
> Hi, I'm trying to use genshi.i18n.Translator module to
translate TEXT
> nodes in my web pages.
>
> The stream is generated using XML object and I apply
the filter
> "Translator(gettext)" to this stream :
> It results in a UnicodeDecodeError (in File
"build/bdist.linux-i686/
> egg/genshi/filters/i18n.py", line 181, in
__call__).
>
> The data field in the stream causing that is :
> - kind : TEXT
> - data : "Paramètres"
> data is a unicode object and file parsed by XML is
UTF-8 encoded.
>
> If I insert a filter "spy" before the
Translator and I replace data
> by :
> unicode("Paramètres","UTF-8")
> it's working fine.
>
> I tought : maybe the data field of the stream is just
in the wrong
> format and I tryied with :
>
unicode(data.encode("UTF-8"),"UTF-8")
> But the result is the same : a UnicodeDecodeError.
>
> maybe I'm doing something else wrong, if somebody has
an idea, please
> let me know.

Try using the "ugettext" function instead of
"gettext"; it returns  
unicode objects.

Cheers,
Chris
--
Christopher Lenz
   cmlenz at gmx.de
   http://www.cmlenz.net/


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Genshi" group.
To post to this group, send email to genshigooglegroups.com
To unsubscribe from this group, send email to
genshi-unsubscribegooglegroups.com
For more options, visit this group at http://gr
oups.google.com/group/genshi?hl=en
-~----------~----~----~----~------~----~------~--~---


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )