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: 8804fc2db82ffef8783b42cebef72fcf9ad2293bfb249a2a3ed411cf9c6517d0
4
- data.tar.gz: 8a706f0c5e87c53b85ec2f35ff692b14d2a66c6cdf95a4d70fab819042553111
3
+ metadata.gz: a90eda21a79655067f6d99cbfe719c5a007f7797a8513ddbbb292ed64513ed17
4
+ data.tar.gz: 1d8ece9fd6206caf59839d79da3d1ebd7a890a32f92466be9233588c2358613b
5
5
  SHA512:
6
- metadata.gz: c958e70e0ff05db0a32c81278c92c10a6283e3aeed1db568f55006cf5599295e7baae7ac83d8912904476551a6c2cac75814651a2317d12b8fe67480abf90956
7
- data.tar.gz: 4b9cb24ef6688502c646ac1187f7aa89d0f4ad257d9dfe925de5f2d672e7363385c3143b6676d31bfba1d1e5c2e504ffa502fe37455e95679aa60e2f5efaee91
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. "indicator_name" in translated metadata
14
- # 2. If the default language, "indicator_name" in non-translated metadata
15
- # 3. if global, translated global indicator name
16
- # 4. "indicator_name" in non-translated metadata
17
- # 5. indicator ID
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
- field = 'indicator_name'
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
- # First choice, is there a subfolder translation of the name?
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? field
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
- # Next choice, is the name actually a "translation key"?
63
+ # 2. Is the override field actually a "translation key"?
57
64
  if !name
58
- if meta and meta.has_key? field
59
- untranslated = meta[field]
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
- # Next, if this is the default language, use the non-translated name
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? field
74
- name = meta[field]
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
- # Next, is this a global indicator with a translation? For this we actually
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
- # Next just return the non-translated name, if available.
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? field
95
- name = meta[field]
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
@@ -1,3 +1,3 @@
1
1
  module JekyllOpenSdgPlugins
2
- VERSION = "0.0.10".freeze
2
+ VERSION = "0.0.11".freeze
3
3
  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.10
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-05-25 00:00:00.000000000 Z
11
+ date: 2019-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll