[Zope3-dev] Re: Use case not covered for translation of message ids

Godefroid Chapelle gotcha at bubblenet.be
Sat Sep 18 10:21:05 EDT 2004


Just in case you had not understood the first one ;-)

I thought I had not succeded to send it.

Godefroid Chapelle wrote:

> Hi
> 
> While working at the mountain sprint on the port of message ids to Z2, 
> we found that the following code is badly processed by zope 3:
> 
> <div tal:content="string:My content item is of type ${type_msgid}." />
> 
> Currently, the message id is not translated : the id is concatenated to 
> the text in the string expression.
> 
> It can be said that the above example is contrived as the text above 
> will never be translated.
> 
> The ideal code should be :
> 
> <div i18n:translate="">My content item is of type <span 
> tal:replace="type_msgid" i18n:name="type" />.</div>
> 
> Anyway, in the first case, the developer has made its part of the i18n 
> job : he has stated that type is to be translated. Even if the template 
> designer did not make his part, we think the message id should be 
> translated.
> 
> Please find hereunder a fix to the class StringExpr of 
> zope/tales/expressions.py which allows the user to see the translated 
> message id.
> 
> from zope.i18n.messageid import MessageID
> 
> 
>     def __call__(self, econtext):
>         vvals = []
>         for var in self._vars:
>             v = var(econtext)
>             if isinstance(v, MessageID):
>                 v = econtext.translate(v, domain=v.domain,
>                         mapping=v.mapping, default=v.default)
>             vvals.append(v)
>         return self._expr % tuple(vvals)
> 
> -- 
> Godefroid with Jurgen Kartnaller
> 
> 
> 
> 



More information about the Zope3-dev mailing list