Closed gyst closed 5 years ago
Update: I got a reproduction and verfied that spaces and other punctuation characters break the translation, but dashes are fine. I updated the PR to allow dashes.
Problem confirmed.
On master though, when I edit src/i18ndude/tests/input/test1.pt
and change one of itsi18n:name
attributes to something illegal, and run bin/test
, I already get a traceback:
Running zope.testrunner.layer.UnitTests tests:
Set up zope.testrunner.layer.UnitTests in 0.000 seconds.
Running:
16/51 (31.4%)There was an error processing /Users/maurits/tools/src/i18ndude/src/i18ndude/tests/input/test1.pt
Traceback (most recent call last):
File "/Users/maurits/tools/src/i18ndude/src/i18ndude/extract.py", line 531, in tal_strings
parser.parseFile(filename)
File "/Users/maurits/shared-eggs/cp36m/zope.tal-4.3.0-py3.6.egg/zope/tal/htmltalparser.py", line 150, in parseFile
self.parseString(data)
File "/Users/maurits/shared-eggs/cp36m/zope.tal-4.3.0-py3.6.egg/zope/tal/htmltalparser.py", line 156, in parseString
self.feed(data)
File "/usr/local/py36/parts/opt/lib/python3.6/html/parser.py", line 111, in feed
self.goahead(0)
File "/usr/local/py36/parts/opt/lib/python3.6/html/parser.py", line 173, in goahead
k = self.parse_endtag(i)
File "/usr/local/py36/parts/opt/lib/python3.6/html/parser.py", line 421, in parse_endtag
self.handle_endtag(elem.lower())
File "/Users/maurits/shared-eggs/cp36m/zope.tal-4.3.0-py3.6.egg/zope/tal/htmltalparser.py", line 214, in handle_endtag
self.gen.emitEndElement(tag, position=self.getpos())
File "/Users/maurits/shared-eggs/cp36m/zope.tal-4.3.0-py3.6.egg/zope/tal/talgenerator.py", line 798, in emitEndElement
self.emitI18nVariable(varname)
File "/Users/maurits/shared-eggs/cp36m/zope.tal-4.3.0-py3.6.egg/zope/tal/talgenerator.py", line 343, in emitI18nVariable
raise TALError("illegal i18n:name: %r" % varname, self.position)
zope.tal.taldefs.TALError: illegal i18n:name: 'foo some', at line 24, column 5, in file /Users/maurits/tools/src/i18ndude/src/i18ndude/tests/input/test1.pt
This probably depends on which zope.tal
version you have, and maybe which Python version. So with a recent enough zope.tal
you won't actually run into the problem, because it breaks earlier. 4.3.0 is actually the minimum required version, so maybe it only somehow depends on the Python version.
Or this is only on older versions (branch 4.x). Are you getting the errors with the latest i18ndude version?
Anyway, a fix in i18ndude
seems good.
With my test above, a space indeed gives a problem, tab or newline too. dash is fine, underscore is fine too. I will add a few comments in the PR.
I have released your fix in i18ndude 5.3.1.
Still waiting for a more exhaustive bug report / reproduction.