[z3-five] Re: Five's translation service, Localizer and PTS
Martijn Faassen
faassen at infrae.com
Thu Jan 26 11:31:11 CET 2006
Florent Guillaume wrote:
> Hi!
>
> yuppie wrote:
>
>> I'm trying to figure out how this is supposed to work:
>>
>> Translated messages normally contain non-ascii characters and are used
>> together with non-ascii content.
>>
>> Five's translation service always returns unicode.
>>
>> Mixing non-ascii encoded strings with unicode in a page template
>> triggers UnicodeDecodeErrors, so all other strings used in the page
>> template have to be unicode as well.
>>
>> How does that work together with Localizer or PTS? Do they return
>> unicode if they are used as fallback translation service?
>>
>> Is there a way to get non-unicode translations from Five's translation
>> service?
>>
>> What am I missing?
>
>
> I can answer you about the Localizer side.
>
> Localizer does a monkey patch of the zope 2 pagetemplate engine so that
> its StringIO method (used to build the resulting string in chunks)
> converts any unicode values to the final encoding.
>
> That's the only sane way I could find 3 years ago to deal with mixed
> str/unicode installations.
Hey yuppie!,
PlacelessTranslationService does something like that too.
These monkey patches in PTS broke Silva when we were using it in Silva
(we have removed it in Silva 1.5). In some complicated scenarios where
we were relying on page templates to return unicode strings, they
weren't anymore. It resulted in more nasty patching of Silva.
In Silva 1.5 we use Five's i18n, and we're very happy it returns proper
unicode. Whole classes of subtle unicode related errors have disappeared.
Regards,
Martijn
More information about the z3-five
mailing list