Skip to content

Commit 6076df5

Browse files
authoredDec 25, 2016
Merge pull request #2601 from getnikola/archive-improvements
Improving friendly archive names.
2 parents c81a222 + 493ac54 commit 6076df5

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed
 

‎nikola/data/themes/base/messages/messages_en.py

+2
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,6 @@
4141
"Write your post here.": "Write your post here.",
4242
"old posts, page %d": "old posts, page %d",
4343
"page %d": "page %d",
44+
"{month} {day}, {year}": "{month} {day}, {year}",
45+
"{month} {year}": "{month} {year}",
4446
}

‎nikola/plugins/task/archive.py

+13-3
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,20 @@ def get_classification_friendly_name(self, classification, lang, only_last_compo
9797
elif len(classification) == 1:
9898
return classification[0]
9999
elif len(classification) == 2:
100-
return nikola.utils.LocaleBorg().get_month_name(int(classification[1]), lang)
100+
month = nikola.utils.LocaleBorg().get_month_name(int(classification[1]), lang)
101+
if only_last_component:
102+
return month
103+
else:
104+
year = classification[0]
105+
return self.site.MESSAGES[lang]['{month} {year}'].format(year=year, month=month)
101106
else:
102-
# Fallback
103-
return '/'.join(classification)
107+
day = int(classification[2])
108+
if only_last_component:
109+
return str(day)
110+
else:
111+
year = classification[0]
112+
month = nikola.utils.LocaleBorg().get_month_name(int(classification[1]), lang)
113+
return self.site.MESSAGES[lang]['{month} {day}, {year}'].format(year=year, month=month, day=day)
104114

105115
def get_path(self, classification, lang, dest_type='page'):
106116
"""A path handler for the given classification."""

‎translations/nikola.messages/en.po

+8
Original file line numberDiff line numberDiff line change
@@ -146,3 +146,11 @@ msgstr "Posts by %s"
146146

147147
msgid "Toggle navigation"
148148
msgstr "Toggle navigation"
149+
150+
#. Used to format months per year
151+
msgid "{month} {year}"
152+
msgstr "{month} {year}"
153+
154+
#. Used to format a date
155+
msgid "{month} {day}, {year}"
156+
msgstr "{month} {day}, {year}"

0 commit comments

Comments
 (0)
Please sign in to comment.