[Zope3-Users] Re: question about request.locale and creation time
Philipp von Weitershausen
philipp at weitershausen.de
Sat Jan 13 16:16:18 EST 2007
Shailesh Kumar wrote:
> When I look at the Creation time and Modification time in any of the
> container views, it shows me the UTC time.
> Looking at
> <http://zope.app.container.browser.contents.py>: Line 174
> I found that:
> formatter = self.request.locale.dates.getFormatter(
> 'dateTime', 'short')
> created = self.safe_getattr(dc, 'created', None)
> if created is not None:
> info['created'] = formatter.format(created)
> modified = self.safe_getattr(dc, 'modified', None)
> if modified is not None:
> info['modified'] = formatter.format(modified)
> is being used to compute them.
No, the local formatter is used to *format* dates according to the
current locale. 8th of March this year, for example would be "3/8/2007"
in the U.S. English locale, but "08.03.2007" in the German locale.
> I am puzzled, how does the browser set its locale? I guess this must be
> a very basic question. But I am not able to figure it out.
request.locale is set according to the most preferred language/locale
returned by the IUserPreferredLanguages adapter for the request. The
default adapter reads browser's the Accept-Language header. More
influence though the website directly.
My book talks about this in detail: http://worldcookery.com
http://worldcookery.com -- Professional Zope documentation and training
2nd edition of Web Component Development with Zope 3 is now shipping!
More information about the Zope3-users