Skip to content

Commit

Permalink
Making INDEX_PATH, RSS_PATH and AUTHOR_PATH translatable (fixes #1914).
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfontein committed Dec 5, 2016
1 parent 122380a commit 9c4f0d3
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGES.txt
Expand Up @@ -31,6 +31,8 @@ Features
have been converted to the new system. (Issue #2107)
* Added ``CATEGORIES_INDEX_PATH``, similar to ``TAGS_INDEX_PATH``.
(Issue #2567)
* Made ``INDEX_PATH``, ``RSS_PATH`` and ``AUTHOR_PATH`` translatable.
(Issue #1914)

New in v7.8.1
=============
Expand Down
3 changes: 3 additions & 0 deletions nikola/conf.py.in
Expand Up @@ -389,6 +389,7 @@ HIDDEN_CATEGORIES = []
# output / TRANSLATION[lang] / AUTHOR_PATH / index.html (list of tags)
# output / TRANSLATION[lang] / AUTHOR_PATH / author.html (list of posts for a tag)
# output / TRANSLATION[lang] / AUTHOR_PATH / author.xml (RSS feed for a tag)
# (translatable)
# AUTHOR_PATH = "authors"

# If AUTHOR_PAGES_ARE_INDEXES is set to True, each author's page will contain
Expand All @@ -413,6 +414,7 @@ HIDDEN_AUTHORS = ['Guest']

# Final location for the main blog page and sibling paginated pages is
# output / TRANSLATION[lang] / INDEX_PATH / index-*.html
# (translatable)
# INDEX_PATH = ""

# Optional HTML that displayed on “main” blog index.html files.
Expand Down Expand Up @@ -461,6 +463,7 @@ USE_BASE_TAG = False

# Final location for the blog main RSS feed is:
# output / TRANSLATION[lang] / RSS_PATH / rss.xml
# (translatable)
# RSS_PATH = ""

# Slug the Tag URL. Easier for users to type, special characters are
Expand Down
3 changes: 3 additions & 0 deletions nikola/nikola.py
Expand Up @@ -657,6 +657,9 @@ def __init__(self, **config):
'TAGS_INDEX_PATH',
'CATEGORY_PATH',
'CATEGORIES_INDEX_PATH',
'INDEX_INDEX_PATH',
'RSS_INDEX_PATH',
'AUTHOR_INDEX_PATH',
'DATE_FORMAT',
'JS_DATE_FORMAT',
)
Expand Down
4 changes: 2 additions & 2 deletions nikola/plugins/task/authors.py
Expand Up @@ -73,15 +73,15 @@ def get_classification_friendly_name(self, author, lang, only_last_component=Fal

def get_overview_path(self, lang, dest_type='page'):
"""A path handler for the list of all classifications."""
return [self.site.config['AUTHOR_PATH']], 'always'
return [self.site.config['AUTHOR_PATH'][lang]], 'always'

def get_path(self, author, lang, dest_type='page'):
"""A path handler for the given classification."""
if self.site.config['SLUG_AUTHOR_PATH']:
slug = utils.slugify(author, lang)
else:
slug = author
return [self.site.config['AUTHOR_PATH'], slug], 'auto'
return [self.site.config['AUTHOR_PATH'][lang], slug], 'auto'

def provide_overview_context_and_uptodate(self, lang):
"""Provide data for the context and the uptodate list for the list of all classifiations."""
Expand Down
4 changes: 2 additions & 2 deletions nikola/plugins/task/indexes.py
Expand Up @@ -69,7 +69,7 @@ def get_classification_friendly_name(self, classification, lang, only_last_compo
def get_path(self, classification, lang, dest_type='page'):
"""A path handler for the given classification."""
if dest_type == 'rss':
return [self.site.config['RSS_PATH']], True
return [self.site.config['RSS_PATH'][lang]], True
# 'page' (index) or 'feed' (Atom)
page_number = None
if dest_type == 'page':
Expand All @@ -78,7 +78,7 @@ def get_path(self, classification, lang, dest_type='page'):
page_number = int(classification)
except:
pass
return [self.site.config['INDEX_PATH']], 'always', page_number
return [self.site.config['INDEX_PATH'][lang]], 'always', page_number

def provide_context_and_uptodate(self, classification, lang, node=None):
"""Provide data for the context and the uptodate list for the list of the given classifiation."""
Expand Down

0 comments on commit 9c4f0d3

Please sign in to comment.