jekyll-open-sdg-plugins 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a90eda21a79655067f6d99cbfe719c5a007f7797a8513ddbbb292ed64513ed17
|
4
|
+
data.tar.gz: 1d8ece9fd6206caf59839d79da3d1ebd7a890a32f92466be9233588c2358613b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25485625bf21860d2a01a02129f786abac71e9629a440f2141539cb9f0a9a0ecfd8854fb70470d5386d03de73c9c9987e09100d0651e89081b143d3e110512d8
|
7
|
+
data.tar.gz: 92511bd4e3fe27fd6eda3544d3f8afc42da9f704e04abf9855f3199c4ccdc6f0e53627db68f6c51b9bd1daa9902f1925d7370a5abdde44a82df4cada161f59a2
|
@@ -10,11 +10,15 @@ module Jekyll
|
|
10
10
|
#
|
11
11
|
# The order of preference in the lookup is:
|
12
12
|
#
|
13
|
-
# 1. "
|
14
|
-
# 2.
|
15
|
-
# 3.
|
16
|
-
# 4.
|
17
|
-
# 5.
|
13
|
+
# 1. "indicator_name_national" in translated metadata - subfolder approach
|
14
|
+
# 2. "indicator_name_national" in translated metadata - translation key approach
|
15
|
+
# 3. If the default language, "indicator_name_national" in non-translated metadata
|
16
|
+
# 4. If a global indicator, translated global indicator name
|
17
|
+
# 5. "indicator_name" in translated metadata - subfolder approach
|
18
|
+
# 6. "indicator_name" in translated metadata - translation key approach
|
19
|
+
# 7. "indicator_name" in non-translated metadata
|
20
|
+
# 8. Finally, fall back to the indicator ID
|
21
|
+
|
18
22
|
def get_indicator_name(inid)
|
19
23
|
|
20
24
|
# Safety code - abort now if id is nil.
|
@@ -42,21 +46,24 @@ module Jekyll
|
|
42
46
|
data = @context.registers[:site].data
|
43
47
|
translations = data['translations']
|
44
48
|
meta = data['meta'][inid]
|
45
|
-
|
49
|
+
|
50
|
+
# The metadata fields that we'll seek, first "override" then "default".
|
51
|
+
override_field = 'indicator_name_national'
|
52
|
+
default_field = 'indicator_name'
|
46
53
|
|
47
54
|
name = false
|
48
55
|
|
49
|
-
#
|
56
|
+
# 1. Is there a subfolder translation of the override field?
|
50
57
|
if meta and meta.has_key? language
|
51
|
-
if !name and meta[language].has_key?
|
58
|
+
if !name and meta[language].has_key? override_field
|
52
59
|
name = meta[language][field]
|
53
60
|
end
|
54
61
|
end
|
55
62
|
|
56
|
-
#
|
63
|
+
# 2. Is the override field actually a "translation key"?
|
57
64
|
if !name
|
58
|
-
if meta and meta.has_key?
|
59
|
-
untranslated = meta[
|
65
|
+
if meta and meta.has_key? override_field
|
66
|
+
untranslated = meta[override_field]
|
60
67
|
translated = opensdg_translate_key(untranslated, translations, language)
|
61
68
|
if untranslated != translated
|
62
69
|
# If the opensdg_translate_key() function returned something else,
|
@@ -66,17 +73,17 @@ module Jekyll
|
|
66
73
|
end
|
67
74
|
end
|
68
75
|
|
69
|
-
#
|
70
|
-
# if available.
|
76
|
+
# 3. If this is the default language, use the non-translated override
|
77
|
+
# field, if available.
|
71
78
|
if !name
|
72
79
|
if language == languages[0]
|
73
|
-
if meta and meta.has_key?
|
74
|
-
name = meta[
|
80
|
+
if meta and meta.has_key? override_field
|
81
|
+
name = meta[override_field]
|
75
82
|
end
|
76
83
|
end
|
77
84
|
end
|
78
85
|
|
79
|
-
#
|
86
|
+
# 4. Is this a global indicator with a translation? For this we actually
|
80
87
|
# need the inid dot-delimited.
|
81
88
|
if !name
|
82
89
|
inid_dots = inid.gsub('-', '.')
|
@@ -89,14 +96,36 @@ module Jekyll
|
|
89
96
|
end
|
90
97
|
end
|
91
98
|
|
92
|
-
#
|
99
|
+
# 5. Is there a subfolder translation of the default field?
|
100
|
+
if !name
|
101
|
+
if meta and meta.has_key? language
|
102
|
+
if !name and meta[language].has_key? default_field
|
103
|
+
name = meta[language][default_field]
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
# 6. Is the default field actually a "translation key"?
|
109
|
+
if !name
|
110
|
+
if meta and meta.has_key? default_field
|
111
|
+
untranslated = meta[default_field]
|
112
|
+
translated = opensdg_translate_key(untranslated, translations, language)
|
113
|
+
if untranslated != translated
|
114
|
+
# If the opensdg_translate_key() function returned something else,
|
115
|
+
# that means it was an actual "translation key".
|
116
|
+
name = translated
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
# 7. Use the non-translated default field, if available.
|
93
122
|
if !name
|
94
|
-
if meta and meta.has_key?
|
95
|
-
name = meta[
|
123
|
+
if meta and meta.has_key? default_field
|
124
|
+
name = meta[default_field]
|
96
125
|
end
|
97
126
|
end
|
98
127
|
|
99
|
-
# Still here? Just return the inid.
|
128
|
+
# 8. Still here? Just return the inid.
|
100
129
|
if !name
|
101
130
|
name = inid
|
102
131
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-open-sdg-plugins
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brock Fanning
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|