Can we translate python code defined in a tal template

Hi
I was playing with i18ndude and wanted to translate something which we generally don't do this way but I'm just experimenting.
I'm aware of translating python string defined in view.py using MessageFactory like

from zope.i18nmessageid import MessageFactory

_ = MessageFactory('collective.todo')

and then defining some string in view.py as

str = _('Hello world!')

I was wondering if we can do something about below codes?

<p tal:define="talks python:['Dexterity for the win!',
                             'Deco is the future',
                             'A keynote on some weird topic',
                             'The talk that I did not submit']"
      tal:repeat="talk talks"
      tal:content="talk">
    A talk
</p>

with

<p tal:define="talks python:['Dexterity for the win!',
                             'Deco is the future',
                             'A keynote on some weird topic',
                             'The talk that I did not submit']"
      tal:repeat="talk talks"
      i18n:translate=""
      i18n:domain="collective.todo"
      tal:content="talk">
    A talk
</p>

you will be able to translate each talk if you have the string in the po file. But i18ndude won't be able to extract those messages no.

2 Likes

Yeah, I noticed that. Is there any workaround on this?

Define the strings in a view and get those strings via an attribute on the view.

1 Like

A though: could it be an option to define them as a vocabulary?