collective / i18ndude

i18ndude performs various tasks related to ZPT's, Python Scripts and i18n.
https://pypi.org/project/i18ndude
4 stars 9 forks source link

zope.tal error with i18n:ignore #20

Closed gforcada closed 9 years ago

gforcada commented 9 years ago

It gives me the following traceback:

      File "/home/gil/.buildout/eggs/Zope2-2.13.22-py2.7.egg/Products/Five/browser/pagetemplatefile.py", line 59, in __call__
        sourceAnnotations=getattr(debug_flags, 'sourceAnnotations', 0),
      File "/home/gil/.buildout/eggs/zope.pagetemplate-3.6.3-py2.7.egg/zope/pagetemplate/pagetemplate.py", line 126, in pt_render
        raise PTRuntimeError(str(self._v_errors))
       - Warning: Compilation failed
       - Warning: zope.tal.taldefs.I18NError: bad i18n attribute: u'ignore', at line 15, column 5
    PTRuntimeError: ['Compilation failed', "zope.tal.taldefs.I18NError: bad i18n attribute: u'ignore', at line 15, column 5"]

Seems that the problem comes from zope.tal (version 3.5.2) where only a few specific attributes are allowed and as ignore is not one of them it raises an error.

I will submit a pull request to zope.tal to allow it, we should probably warn in our docs about this?

mauritsvanrees commented 9 years ago

Is this also true for the latest zope.tal? In the i18ndude buildout we use 4.1.1. But I think it indeed happens there as well.

So: i18ndude is completely happy, but when Zope/Plone tries to show the template you get the above error, right?

The code in i18ndude handling i18n:ignore or i18n:ignore-attributes was added by @janjaapdriessen. Maybe he has an idea? Jan-Jaap, are you actually using zope.tal or something else? Did you run into this problem too?

gforcada commented 9 years ago

I was looking at it today and both zope.tal and Chameleon have a whitelist of attributes that are ok for i18n domain, any other attribute raises that error (or a similar one with Chameleon).

I already made PR for both:

https://github.com/zopefoundation/zope.tal/pull/4 https://github.com/malthe/chameleon/pull/205

janjaapdriessen commented 9 years ago

@mauritsvanrees in the original commit collective/i18ndude@1b73cb152efd8d3c9944ef37cf9a4dfab2dd26b2 I wrote that when using Chameleon, it's necessary to update the i18n.WHITELIST:

# Make it a non-frozen set.
chameleon.i18n.WHITELIST = set(chameleon.i18n.WHITELIST)
chameleon.i18n.WHITELIST.update(('ignore', 'ignore-attributes'))

This comment didn't make it into the changes of the i18ndude release and I was too lazy to do a pull request on chameleon. Thank you @gforcada for fixing this properly!