[Product-Developers] translating a date in a page template
Kees Hink
hink at gw20e.com
Mon Mar 23 13:21:19 UTC 2009
How can i translate a DateTime object from TAL?
My use case is a custom content type (AT) which has a DateTime field. I would
like to show the date for this field as '%d %B %Y', where %B is the full name of
the month in the site's language. (Site language is Dutch, this is also set in
portal_languages.)
I tried to create a translation using toLocalizedTime()
<span tal:define="translation python: context.toLocalizedTime(datetime)"
tal:replace="translation" />
where 'datetime' is a DateTime object. However, this renders the date in
'%d-%m-%Y' format.
Possibly related: Dates in document bylines are shown in English. I have set the
site language to Dutch and the site property localLongTimeFormat to '%d %B, %Y
%I:%M %p'. It shows the right format, but untranslated.
setup:
* Plone 3.2.1
* CMF 2.1.2
* Zope (Zope 2.10.6-final, python 2.4.5, linux2)
* Python 2.4.5 (#2, Aug 1 2008, 02:22:02) [GCC 4.3.1]
* PIL 1.1.6
More information about the Product-Developers
mailing list