[ZPT] i18n ZPT called from python

Toni Vicens tvicens at gmail.com
Sun Oct 19 21:16:40 EDT 2008


Hi everyone,

I'm trying to call some i18n ZPT to generate mails in different languages
from a python External method.

Does anybody know hot to set the target_language of a template being called
from python code?

For the moment I succeeded doing:

def mailGenerator(self):
    request = self.REQUEST
    form = {'language':'fr'}
    request.form = form
    body=self.mail_templates.mail_template1(self, var1=foo, var2=bar)
    return body

which returns mail_template1 in french

but when I try

def mailGenerator(self):
    request = self.REQUEST
    form = {'language':'fr'}
    request.form = form
    body=self.mail_templates.mail_template1(self, var1=foo, var2=bar)
    form = {'language':'en'}
    request.form = form
    body = body + self.mail_templates.mail_template1(self, var1=foo,
var2=bar)
    return body

I get both mail_templates in the same language, instead of getting the
second one in English.

The environment I'm working on is Zope 2.10 and PlacelessTranslationService
1.4.12

Any ideas?

Thank you in advance,
Toni.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/zpt/attachments/20081020/3a8d9c96/attachment.html 


More information about the ZPT mailing list