mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Articles translations are enabled. To use this feature, you need to
add a Lang meta into the each article and set DEFAULT_LANG setting which is 'en' by default. Than, only articles in the default language (or without variant in default language) will be shown in the index of the blog. And each Article will have translations list. The same is applicable to the static Pages. Also, separate feeds are generated for each language except default.
This commit is contained in:
parent
1a31c74d5c
commit
3afdb8fcff
4 changed files with 79 additions and 8 deletions
|
|
@ -12,6 +12,8 @@ class Page(object):
|
|||
|
||||
def __init__(self, content, metadatas={}, settings={}, filename=None):
|
||||
self.content = content
|
||||
self.translations = []
|
||||
|
||||
self.status = "published" # default value
|
||||
for key, value in metadatas.items():
|
||||
setattr(self, key, value)
|
||||
|
|
@ -20,11 +22,20 @@ class Page(object):
|
|||
if 'AUTHOR' in settings:
|
||||
self.author = settings['AUTHOR']
|
||||
|
||||
default_lang = settings.get('DEFAULT_LANG', 'en').lower()
|
||||
if not hasattr(self, 'lang'):
|
||||
self.lang = default_lang
|
||||
|
||||
self.in_default_lang = (self.lang == default_lang)
|
||||
|
||||
if not hasattr(self, 'slug'):
|
||||
self.slug = slugify(self.title)
|
||||
|
||||
if not hasattr(self, 'url'):
|
||||
self.url = '%s.html' % self.slug
|
||||
if self.in_default_lang:
|
||||
self.url = '%s.html' % self.slug
|
||||
else:
|
||||
self.url = '%s-%s.html' % (self.slug, self.lang)
|
||||
|
||||
if filename:
|
||||
self.filename = filename
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue