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

Wrong line numbers reported in find-untranslated #34

Closed mauritsvanrees closed 8 years ago

mauritsvanrees commented 8 years ago

See remarks by @vincentfretin in pull request #32. It is basically this problem in lxml and maybe most xml libraries: https://bugs.launchpad.net/lxml/+bug/526799

Take this file, simplified from the confirm.pt that Vincent points to:

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
      xmlns:i18n="http://xml.zope.org/namespaces/i18n"
      lang="en"
      i18n:domain="plone">
<body>
  <input
      type="submit"
      value="Confirm action"
      name="form.button.confirm"
      class="standalone" />
</body>
</html>

Running find-untranslated on it complains about line 3:

confirm.pt:3:2:
-ERROR- - value attribute of <... submit/button> lacks i18n:attribute

This is because lxml turns the content into:

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:i18n="http://xml.zope.org/namespaces/i18n" xml:lang="en" lang="en" i18n:domain="plone">
<body>
  <input type="submit" value="Confirm action" name="form.button.confirm" class="standalone"/>
</body>
</html>

So every tag tag is now on one line instead of possibly multiple.