forked from github/pelican
Merge pull request #215 from farseerfc/d1d82db4f7096793feee4e56ff510b0846762b04
Changing LOCALE according to lang of current page in DATE_FORMAT
This commit is contained in:
commit
278d1105cf
1 changed files with 5 additions and 0 deletions
|
|
@ -5,6 +5,7 @@ from pelican.settings import _DEFAULT_CONFIG
|
|||
from datetime import datetime
|
||||
from os import getenv
|
||||
from sys import platform, stdin
|
||||
import locale
|
||||
|
||||
class Page(object):
|
||||
"""Represents a page
|
||||
|
|
@ -86,6 +87,10 @@ class Page(object):
|
|||
else:
|
||||
self.date_format = settings['DEFAULT_DATE_FORMAT']
|
||||
|
||||
if isinstance(self.date_format, tuple):
|
||||
locale.setlocale(locale.LC_ALL, self.date_format[0])
|
||||
self.date_format = self.date_format[1]
|
||||
|
||||
if hasattr(self, 'date'):
|
||||
if platform == 'win32':
|
||||
self.locale_date = self.date.strftime(self.date_format.encode('ascii','xmlcharrefreplace')).decode(stdin.encoding)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue