I'm running into some problems doing translations from python code. As
far as I can see none of the documentation on plone.org is up to date.
The code snippet I have now looks like this:
from zope.i18n import translate
filename=_("filename_actionplan_report",
default=u"Inventory ${title}.doc")
mapping=dict(title=dbsession.title)
filename=translate(filename,
mapping=mapping,
context=self.request,
default=string.Template(filename.default).substitute(**mapping))
self.request.response.setHeader("Content-Disposition",
u"attachment; filename=%s" % filename)
self.request.response.setHeader("Content-Type", "application/msword")
I've found that unless you give a default to translate it will happily
return something useless if no translation catalog has an entry for your
string. That makes it a somewhat stupid API, but something you can
easily deal with. Since I have no translation catalog entry for my
message I would expect the return value for the translate call to be the
default I've passed in, but instead it returns u'Inventory
${title}.doc'. Does anyone know what the right magic invocation of
translate is?
Wichert.
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference_______________________________________________
Plone-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-developers