Skip to content

Commit 8c15857

Browse files
committed
Made locales an ivar.
1 parent 35364e1 commit 8c15857

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

_plugins/news.rb

+8-9
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ def initialize(site,base,layout,lang,posts)
1212
@dir = File.join(@lang,news_dir)
1313
@name = 'index.html'
1414

15+
@locales = @site.config['locales']['news'][@lang] ||
16+
@site.config['locales']['news']['en']
17+
1518
process(@name)
1619
read_yaml(File.join(base, '_layouts'),layout)
1720

@@ -27,10 +30,6 @@ def news_dir
2730
end
2831
end
2932

30-
def locales
31-
@site.config['locales']['news'][@lang] || @site.config['locales']['news']['en']
32-
end
33-
3433
def month_names
3534
month_names = @site.config['locales']['month_names'][@lang]
3635
month_names ||= @site.config['locales']['month_names']['en']
@@ -51,7 +50,7 @@ def initialize(site,base,lang,year,month,posts)
5150
@month = month
5251
@dir = File.join(@dir,@year.to_s,"%.2d" % @month)
5352

54-
title = locales['monthly_archive_title']
53+
title = @locales['monthly_archive_title']
5554

5655
data['title'] = title.gsub(/%Y|%m|%B/, {
5756
'%Y' => @year.to_s,
@@ -73,8 +72,8 @@ def initialize(site,base,lang,year,posts)
7372
@year = year
7473
@dir = File.join(@dir,@year.to_s)
7574

76-
title = locales['yearly_archive_title']
77-
month_link_text = locales['monthly_archive_link']
75+
title = @locales['yearly_archive_title']
76+
month_link_text = @locales['monthly_archive_link']
7877

7978
data['title'] = title.gsub('%Y', @year.to_s)
8079
data['year'] = @year
@@ -105,8 +104,8 @@ class Index < ArchivePage
105104
def initialize(site,base,lang,posts)
106105
super(site,base,LAYOUT,lang,posts)
107106

108-
title = locales['recent_news']
109-
year_link_text = locales['yearly_archive_link']
107+
title = @locales['recent_news']
108+
year_link_text = @locales['yearly_archive_link']
110109

111110
data['title'] = title
112111
data['posts'] = posts.last(MAX_POSTS).reverse

0 commit comments

Comments
 (0)