2

Does Pyramid i18n of .pt files support HTML5 mark-up? Currently the i18n tag extractor (Babel?) seems to want XHTML based input and does not accept HTML5 mark-up. Thus if you want to use i18n in .pt files you are forced to write them in XML'ish way?

Mikko Ohtamaa
  • 82,057
  • 50
  • 264
  • 435
  • HTML5 is just as much XML as earlier versions of HTML: it can be written both in XML and non-XHTML form. – Wichert Akkerman Sep 19 '11 at 08:23
  • Can you explain what you mean with 'Chameleon 2.0 did not seem to work with Babel' ? No Chameleon version uses Babel, so your remark feels off. – Wichert Akkerman Sep 19 '11 at 08:24
  • Hi Wichert! Thanks for coming back as nice question as this. By following this tutorial https://pylonsproject.org/projects/pyramid/1.0/narr/i18n.html I tried to extract msgids from .pt files. If .pt file is not valid XML (e.g. self-closing tags and stuff) parser fails (I assume this is Babel parser, not Chameleon itself) because it only accepts XML'ish HTML as input. – Mikko Ohtamaa Sep 19 '11 at 22:24
  • Also clarified the question - hopefully better now – Mikko Ohtamaa Sep 19 '11 at 22:25

1 Answers1

3

Chameleon 1 included two Babel extraction plugins (one for python code and one for XML files), which is what the Pyramid documentation is referring to. Chameleon 2 no longer includes those plugins and focuses on its core functionality of being a template library. These two plugins have been cleaned up and are now included in the new lingua package. The pyramid documentation has been updated to reflect that since Pyramid 1.1 (as you can see in the Pyramid 1.1 i18n chapter).

The lingua XML plugin uses expat to parse its input, so will indeed fail on HTML files that do not use XML notation. Since I personally feel quite strongly that XML notation is a much better choice I am not likely to chance the lingua implementation to support non-XML syntax. There is one exception: lingua does allow for missing namespace declaration.

Wichert Akkerman
  • 4,918
  • 2
  • 23
  • 30
  • What would it take to have HTML5 compatible parser to plugged in? Do we talk about adding just one plug-in file or is more pervasive change? html5lib supports DOM output http://code.google.com/p/html5lib/ – Mikko Ohtamaa Sep 21 '11 at 16:06
  • It would take adding an alternative for https://github.com/wichert/lingua/blob/master/src/lingua/extractors/xml.py . – Wichert Akkerman Sep 22 '11 at 10:31
  • 1
    For what it's worth: lingua no longer requires templates to be valid XML, and can process HTML 5 templates without problems. – Wichert Akkerman Aug 20 '14 at 15:07