Translation-extract stumbles at main template

Plone 5.1.5, infrae.i18nextract, i18ndude.

Running bin/translation-extract and it rejects the copy of main_template.pt in my overrides folder with a 'bad syntax in attributes' TAL error.

It's correct: the template (this bit is identical to the distribution) has:

tal:attributes="class body_class; dir python:isRTL and 'rtl' or 'ltr'; python:plone_view.patterns_settings();"
Any ideas on fixing the template or the extract script?

Thanks

1 Like

The reason might be that tal:attributes can work with a dict (in this case python:plone_view.patterns_settings()) or with attribute name and value pairs (class body_class; dir python:isRTL and 'rtl' or 'ltr').
Probably i18ndude has trouble with that.

A quick win might be changing:

<el tal:attributes="class body_class; dir python:isRTL and 'rtl' or 'ltr'; 
 python:plone_view.patterns_settings();" />

to:

<el class="${body_class}"
      dir="${python:isRTL and 'rtl' or 'ltr'}" 
      tal:attributes="python:plone_view.patterns_settings();" 
/>

Let us know!

Are you using the latest version of i18ndude? I think this may have been fixed in a more recent version.
Possibly related to https://github.com/collective/i18ndude/issues/36 although that was fixed in i18ndude 4.3 in 2017.

It could also be that you need a newer zope.tal version in your i18ndude.

1 Like

Thanks, Alessandro. That was plausible but didn't work. I'm following Maurits' suggestions now and in the usual cascading requirement conflicts when the version of one component is bumped up.

1 Like

Catch-up. After much faffing with newer versions of zope.tal and i18ndude I am still seeing an error parsing tal:attributes="python:plone_view.patterns_settings();". Slightly shamefully I have resorted to deleting that line, running bin/translation-extract successfully, then putting the line back again. At least it moves me on to the next problem, and I'll come back to this one.