Found the strftime() method, but i can't get it to translate the month name:
datetime.strftime('%d %B %Y') yields the date with an English month name ('20
March, 2009 '). How to get that in the portal language?Maybe i didn't find the documentation you are referring to? I found http://api.plone.org/Plone/2.1.1/public/DateTime.DateTime.DateTime-class.html (old) and http://docs.python.org/library/time.html (Zope passes strftime through to Python's, and i wouldn't want to use the system locale for translated strings, as it's different from the site language). But none of them mention translating month names. Andreas Jung wrote: > DateTime instance provide the strftime() method (according to the docs). > > -aj > > On Mon, Mar 23, 2009 at 14:21, Kees Hink <[email protected] > <mailto:hink-JZa/QnC6/[email protected]>> wrote: > > 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 > > _______________________________________________ > Product-Developers mailing list > [email protected] > <mailto:[email protected]> > http://lists.plone.org/mailman/listinfo/product-developers > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Product-Developers mailing list > [email protected] > http://lists.plone.org/mailman/listinfo/product-developers _______________________________________________ Product-Developers mailing list [email protected] http://lists.plone.org/mailman/listinfo/product-developers
