How do I get "date.strftime" in the language set by "/i18n/setlang/"

959 views
Skip to first unread message

jul

unread,
Mar 2, 2010, 12:19:08 PM3/2/10
to Django users
hi,

I have a multilingual site and I'd like to get some date in the
current language. With date.strftime, I get the date in english
only...
The language is set by "/i18n/setlang/".
How can I do that?

thanks
jul

James Bennett

unread,
Mar 2, 2010, 12:47:00 PM3/2/10
to django...@googlegroups.com

For simple formatting, you could just do what the "date" template filter does:

from django.utils.dateformat import format
format(value, format_string)

This uses a slightly different format-string syntax than strftime, but
it is locale-aware and so will translate month and day names for you
in the process.


--
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

jul

unread,
Mar 2, 2010, 1:03:05 PM3/2/10
to Django users
Perfect. Thanks.
Reply all
Reply to author
Forward
0 new messages