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

Philipp von Weitershausen philipp at weitershausen.de
Mon Sep 27 15:15:41 EDT 2004


Martijn Faassen wrote:
> Jim Fulton wrote:
> [snip]
> 
>>> Would there be something to say for switching on automatic 
>>> translation on per-page in ZCML?
>>
>>
>>
>> A page indicates that it wants text to be translated using i18n:translate
>> attributes.
>>
> 
> Doesn't that require setting the message id in it?

There are two basic setups:

1. Static text in the template has to be translated:

   <p i18n:translate="">This text will be translated</p>

   This will both turn the text into a message id *and* translate it.

2. A value passed in from some machinery (e.g. an ISized adapter) needs 
to be translated.

   a) in the adapter code, we do:

     msg = _(..)
     msg.mapping = {...}

     That way, the extractor tool find the message id; plus, we can
     provide a mapping for variable interpolation.

   b) in the zpt we do

     <p tal:content="size_adapter/sizeForDisplay" i18n:translate="" />

     This time, the i18n:translate will only invoke the translation
     because we are already dealing with a message id. IMO, it is
     still important having to explicitly state that this thing should be
     translated. Not all components might return message ids and
     sometimes you wouldn't want msgids to be translated (e.g. when
     managing them).

Philipp



More information about the Zope3-dev mailing list