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

Support for tal:switch and tal:case #24

Closed ale-rt closed 9 years ago

ale-rt commented 9 years ago

Chameleon added the attributes switch and case:

At the moment if the pt contains them i18ndude fails with this traceback:

[ale@kenobi pricesurvey]$ ./i18n.sh 
There was an error processing ./browser/templates/survey.pt
Traceback (most recent call last):
  File "/opt/utils/i18ndude/local/lib/python2.7/site-packages/i18ndude/extract.py", line 509, in tal_strings
    p.parseFile(filename)
  File "/opt/utils/i18ndude/local/lib/python2.7/site-packages/zope/tal/htmltalparser.py", line 131, in parseFile
    self.parseString(data)
  File "/opt/utils/i18ndude/local/lib/python2.7/site-packages/zope/tal/htmltalparser.py", line 137, in parseString
    self.feed(data)
  File "/usr/lib/python2.7/HTMLParser.py", line 117, in feed
    self.goahead(0)
  File "/usr/lib/python2.7/HTMLParser.py", line 161, in goahead
    k = self.parse_starttag(i)
  File "/usr/lib/python2.7/HTMLParser.py", line 327, in parse_starttag
    self.handle_starttag(tag, attrs)
  File "/opt/utils/i18ndude/local/lib/python2.7/site-packages/zope/tal/htmltalparser.py", line 165, in handle_startta
    self.getpos())
  File "/opt/utils/i18ndude/local/lib/python2.7/site-packages/zope/tal/talgenerator.py", line 498, in emitStartElemen
    raise TALError("bad TAL attribute: " + repr(key), position)
TALError: bad TAL attribute: 'switch', at line 40, column 23, in file ./browser/templates/survey.pt
ale-rt commented 9 years ago

I don't know if this is the correct place to file an issue: maybe it is better to file an issue against zope.tal?

ale-rt commented 9 years ago

The error is fixed adding switch and case to this frozenset:

mauritsvanrees commented 9 years ago

Seems something for zope.tal indeed.

Alternatively, it would help if i18ndude supported Chameleon out of the box. See issue #21.

mauritsvanrees commented 9 years ago

See also https://github.com/plone/Products.CMFPlone/commit/72446991256ca9ed1f2df47edcc5a9e8e6bb6657 and https://github.com/plone/buildout.coredev/blob/040259ef9b5f6765af02a75c544686e1bbf801df/experimental/i18n.cfg#L1

ale-rt commented 9 years ago

Thanks for the feedback I am preparing a PR for i18ndude (no monkey patching of zope.tal).

Indeed, I would also like to modify some bits of zope.tal to make it more easy to integrate chameleon.