Florent Guillaume wrote:
> Martijn Faassen wrote:
>> Zope 2.8 *is* actually interpolating and translating message ids
>> correctly *without* i18n:translate already. I think that this is the
>> same as Zope 3's (deprecated) behavior.
>> The problem is when 'structure' is used in TALES. If this isn't used,
>> translations happen normally. If it is used, translations suddenly
>> break, as do_insertStructure_tal is used instead of do_insertText_tal.
>> I can see that this makes sense if you "structure in" large pieces of
>> HTML -- they won't have translations. It does however break a usecase
>> where your message ids contain HTML. This isn't really clean, but very
>> handy for translators sometimes, especially if they want to use HTML
>> entities and the like. You can then use i18n:translate="" explicitly
>> on the structure, which will cause the *string* to be translated,
>> without interpolation happening. This put me on the wrong track
>> initially, not realizing the impact of 'structure' on the functioning
>> of the TAL interpreter.
> I agree that the use case of having translations containing HTML is
> important, and thus that we'll have to make sure do_insertStructure_tal
> also does correct interpolation when faced with a MessageID.
The Zope 3's TALGenerator/TALInterpreter implementation goes a slightly
different way. This May, Dmitry Vasiliev implemented a couple of fixes
regarding i18n in TAL, among them were:
- tal:replace and i18n:translate="" can be used together. This was
something Martijn mentioned isn't possible in Zope 2. It's possible
in Zope 3 now, though.
- tal:content, tal:replace without i18n:translate="" raises
a DeprecationWarning for MessageID/Message objects. This is the
"fix" we want to undeprecate again...
You can see the whole revision here:
Not mentioned in the changelog is a fix for i18n:translate in
combination with structure. But if you look at the diffs of
talinterpreter.py and talgenerator.py, you will see that the generator
now emits the proper bytecode and the interpreter has two new bytecode
handlers, do_insertI18nStructure_tal and do_insertI18nText_tal.
Personally, I would suggest to port this portion of Dmitry's fix. It
might be slightly more complicated than necessary (there are comments
mentioning some unnecessary code duplication), but at least the
ZPT implementations would be kept in sync. This is important for when
we'll switch Zope 2 over to the Zope 3 ZPT implementation some day
(hopefully for Zope 2.10 as Jim mentioned).
Zope3-dev mailing list