Skip to content

Commit 9673de7

Browse files
committed
Use format strings for localized archives titles
1 parent 44f646c commit 9673de7

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

_config.yml

+4-6
Original file line numberDiff line numberDiff line change
@@ -234,17 +234,15 @@ locales:
234234
de:
235235
continue: Weiterlesen...
236236
recent_news: Aktuelle Neuigkeiten
237-
archive_title:
238-
prefix: Archiv für
239-
postfix:
237+
yearly_archive_title: "Archiv für %Y"
238+
monthly_archive_title: "Archiv für %m/%Y"
240239
yearly_archives: Archiv
241240
monthly_archives: Archiv nach Monat
242241
en:
243242
continue: Continue Reading...
244243
recent_news: Recent News
245-
archive_title:
246-
prefix:
247-
postfix: Archives
244+
yearly_archive_title: "%Y Archives"
245+
monthly_archive_title: "%B %Y Archives"
248246
yearly_archives: Archives by Year
249247
monthly_archives: Archives by Month
250248

_plugins/news.rb

+8-6
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,14 @@ def initialize(site,base,lang,year,month,posts)
4343
@dir = File.join(@dir,@year.to_s,"%.2d" % @month)
4444

4545
if site.config['locales']['news'][lang]
46-
title = site.config['locales']['news'][lang]['archive_title']
46+
title = site.config['locales']['news'][lang]['monthly_archive_title']
4747
else
48-
title = site.config['locales']['news']['en']['archive_title']
48+
title = site.config['locales']['news']['en']['monthly_archive_title']
4949
end
5050

51-
data['title'] = "#{title['prefix']} #{MONTHS[@month]} #{@year} #{title['postfix']}".strip
51+
data['title'] = title.gsub(/%Y|%m|%B/, {
52+
'%Y' => @year.to_s, '%m' => @month, '%B' => MONTHS[@month]
53+
})
5254
data['year'] = year
5355
end
5456

@@ -65,12 +67,12 @@ def initialize(site,base,lang,year,posts)
6567
@dir = File.join(@dir,@year.to_s)
6668

6769
if site.config['locales']['news'][lang]
68-
title = site.config['locales']['news'][lang]['archive_title']
70+
title = site.config['locales']['news'][lang]['yearly_archive_title']
6971
else
70-
title = site.config['locales']['news']['en']['archive_title']
72+
title = site.config['locales']['news']['en']['yearly_archive_title']
7173
end
7274

73-
data['title'] = "#{title['prefix']} #{@year} #{title['postfix']}".strip
75+
data['title'] = title.gsub('%Y', @year.to_s)
7476

7577
months = posts.map { |post| post.date.month }.uniq
7678

0 commit comments

Comments
 (0)