forked from github/pelican
Changes about locales and dates.
Add a way to specify the locale in the settings, and the date formating as well. Fixes #61.
This commit is contained in:
parent
3070c8fc9e
commit
d13e6f14fb
16 changed files with 39 additions and 13 deletions
|
|
@ -47,6 +47,15 @@ class Page(object):
|
|||
if filename:
|
||||
self.filename = filename
|
||||
|
||||
if not hasattr(self, 'date_format'):
|
||||
if self.lang in settings['DATE_FORMATS']:
|
||||
self.date_format = settings['DATE_FORMATS'][self.lang]
|
||||
else:
|
||||
self.date_format = settings['DEFAULT_DATE_FORMAT']
|
||||
|
||||
# store the settings ref.
|
||||
self._settings = settings
|
||||
|
||||
def check_properties(self):
|
||||
"""test that each mandatory property is set."""
|
||||
for prop in self.mandatory_properties:
|
||||
|
|
@ -65,6 +74,11 @@ class Page(object):
|
|||
def summary(self):
|
||||
return truncate_html_words(self.content, 50)
|
||||
|
||||
@property
|
||||
def locale_date(self):
|
||||
return self.date.strftime(self.date_format)
|
||||
|
||||
|
||||
|
||||
class Article(Page):
|
||||
mandatory_properties = ('title', 'date', 'category')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue