i18n ZPT called from python
"Toni Vicens" <[email protected]> Mon, 20 Oct 2008 03:16:40 +0200
| Newsgroups | gmane.comp.web.zope.page-templates |
|---|---|
| Message-ID | <[email protected]> |
--===============0444039379365817338==
Content-Type: multipart/alternative;
boundary="----=_Part_83400_7006098.1224465400637"
------=_Part_83400_7006098.1224465400637
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
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.
------=_Part_83400_7006098.1224465400637
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
<div dir="ltr">Hi everyone,<br><br>I'm trying to call some i18n ZPT to generate mails in different languages from a python External method.<br><br>Does anybody know hot to set the target_language of a template being called from python code?<br>
<br>For the moment I succeeded doing:<br><br>def mailGenerator(self):<br> request = self.REQUEST<br> form = {'language':'fr'}<br> request.form = form<br> body=self.mail_templates.mail_template1(self, var1=foo, var2=bar)<br>
return body<br><br>which returns mail_template1 in french<br><br>but when I try<br><br>def mailGenerator(self):<br>
request = self.REQUEST<br>
form = {'language':'fr'}<br>
request.form = form<br>
body=self.mail_templates.mail_template1(self, var1=foo, var2=bar)<br> form = {'language':'en'}<br>
request.form = form<br>
body = body + self.mail_templates.mail_template1(self, var1=foo, var2=bar)<br>
return body<br><br>I get both mail_templates in the same language, instead of getting the second one in English.<br><br>The environment I'm working on is Zope 2.10 and PlacelessTranslationService 1.4.12<br>
<br>Any ideas?<br><br>Thank you in advance,<br>Toni.<br></div>
------=_Part_83400_7006098.1224465400637--
--===============0444039379365817338==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
ZPT mailing list
[email protected]
http://mail.zope.org/mailman/listinfo/zpt
--===============0444039379365817338==--