jekyll-locale 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jekyll/locale/handler.rb +29 -5
- data/lib/jekyll/locale/mixins/support.rb +1 -1
- data/lib/jekyll/locale/version.rb +1 -1
- data/lib/jekyll/patches/utils.rb +5 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7711d55551114d2ff94841695d72b0db57e5101
|
4
|
+
data.tar.gz: afa5ee87a7bb1a70fa8af07eb4d258b0f53a6cc3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdd9f7566119e15ed95fa2c92aef41bda3e474a45585b0872c1e9584d30fbc40f6dfe61ff5406c8caebdb6034386da2c6b6f806944cb713a8b7eeb72c4056d91
|
7
|
+
data.tar.gz: 719fb8949ff087f5684de77b5c6aaf9f2ed25200a8d8b95c4e6ed2c073a85b428102ed4c9285c1332282cb51bc184f9fcf0b8cc0617c742084f23593e3e18ab6
|
@@ -21,6 +21,7 @@ module Jekyll
|
|
21
21
|
else
|
22
22
|
DEFAULT_CONFIG
|
23
23
|
end
|
24
|
+
@sanitized_locale = {}
|
24
25
|
end
|
25
26
|
|
26
27
|
def reset
|
@@ -29,7 +30,8 @@ module Jekyll
|
|
29
30
|
end
|
30
31
|
|
31
32
|
def data
|
32
|
-
locale_data[current_locale] ||
|
33
|
+
locale_data[sanitized_locale(current_locale)] ||
|
34
|
+
locale_data[sanitized_locale(default_locale)] || {}
|
33
35
|
end
|
34
36
|
|
35
37
|
def portfolio
|
@@ -39,6 +41,9 @@ module Jekyll
|
|
39
41
|
def filtered_portfolio
|
40
42
|
@filtered_portfolio ||= begin
|
41
43
|
portfolio.reject do |item|
|
44
|
+
# consider only instances of class that include `Jekyll::Locale::Support` mixin
|
45
|
+
next true unless item.is_a?(Jekyll::Locale::Support)
|
46
|
+
|
42
47
|
item.relative_path =~ exclusion_regex
|
43
48
|
end
|
44
49
|
end
|
@@ -47,6 +52,9 @@ module Jekyll
|
|
47
52
|
def read
|
48
53
|
available_locales.each do |locale|
|
49
54
|
portfolio.each do |canon_doc|
|
55
|
+
# consider only instances of class that include `Jekyll::Locale::Support` mixin
|
56
|
+
next unless canon_doc.is_a?(Jekyll::Locale::Support)
|
57
|
+
|
50
58
|
loc_page_path = site.in_source_dir(content_dirname, locale, canon_doc.relative_path)
|
51
59
|
next unless File.exist?(loc_page_path)
|
52
60
|
next unless Jekyll::Utils.has_yaml_header?(loc_page_path)
|
@@ -83,6 +91,10 @@ module Jekyll
|
|
83
91
|
@default_locale ||= fetch("locale")
|
84
92
|
end
|
85
93
|
|
94
|
+
def sanitized_locale(locale_key)
|
95
|
+
@sanitized_locale[locale_key] ||= locale_key.downcase.tr("-", "_")
|
96
|
+
end
|
97
|
+
|
86
98
|
def content_dirname
|
87
99
|
@content_dirname ||= fetch("content_dir")
|
88
100
|
end
|
@@ -115,11 +127,23 @@ module Jekyll
|
|
115
127
|
|
116
128
|
def locale_data
|
117
129
|
@locale_data ||= begin
|
118
|
-
ldata
|
119
|
-
|
130
|
+
ldata = site.site_data[locales_dir]
|
131
|
+
result = {}
|
132
|
+
return result unless ldata.is_a?(Hash)
|
133
|
+
|
134
|
+
ldata.each do |loc, loc_data|
|
135
|
+
locale = Utils.snakeify(loc)
|
136
|
+
result[locale] = {}
|
137
|
+
next unless loc_data.is_a?(Hash)
|
138
|
+
|
139
|
+
loc_data.each do |key, value|
|
140
|
+
next if key == "locale_date"
|
141
|
+
|
142
|
+
result[locale][Utils.snakeify(key)] = value.to_s
|
143
|
+
end
|
144
|
+
end
|
120
145
|
|
121
|
-
|
122
|
-
Jekyll::Utils.snake_case_keys(ldata)
|
146
|
+
result
|
123
147
|
end
|
124
148
|
end
|
125
149
|
|
data/lib/jekyll/patches/utils.rb
CHANGED
@@ -15,13 +15,17 @@ module Jekyll
|
|
15
15
|
def snake_case_keys(hash)
|
16
16
|
transform_keys(hash) do |key|
|
17
17
|
begin
|
18
|
-
|
18
|
+
snakeify(key)
|
19
19
|
rescue StandardError
|
20
20
|
key.to_s
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
+
def snakeify(input)
|
26
|
+
slugify(input.to_s, :mode => "latin", :replacement => "_")
|
27
|
+
end
|
28
|
+
|
25
29
|
def slugify(string, mode: nil, cased: false, replacement: "-")
|
26
30
|
mode ||= "default"
|
27
31
|
return nil if string.nil?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-locale
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ashwin Maroli
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|