jekyll-open-sdg-plugins 1.0.0.rc17 → 1.0.0.rc18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c16c0638e34af249e19c5e8af25674919b5f2062afe6824c269d0f488837f44f
|
4
|
+
data.tar.gz: c2fdc29cf2d10bbdc29f69f3aa9d8a3f3ddeeda5cb06b9492eca7924f0e5d18f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb568f7cc670ae23da7018b92e0f58b3e449743c7c8ed80c9a359c98034375a7f750cbdb733ed16fcd8d9d669dc998d8d05c53225249cebcb7b021e346e5e534
|
7
|
+
data.tar.gz: 6b7a0fc19f271867fe3494778a06df9a1bb4dadbcdcbb86b20a8d5c780d57823cf9af48c6457101c70b1c5fae997f314b38c4a1802410ec2820758150a8d4ee5
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require_relative "jekyll-open-sdg-plugins/version"
|
2
2
|
require_relative "jekyll-open-sdg-plugins/fetch_remote_data"
|
3
3
|
require_relative "jekyll-open-sdg-plugins/translate_key"
|
4
|
+
require_relative "jekyll-open-sdg-plugins/translate_date"
|
4
5
|
require_relative "jekyll-open-sdg-plugins/translate_metadata_field"
|
5
6
|
require_relative "jekyll-open-sdg-plugins/create_indicators"
|
6
7
|
require_relative "jekyll-open-sdg-plugins/create_goals"
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require "jekyll"
|
2
|
+
require_relative "helpers"
|
3
|
+
|
4
|
+
module Jekyll
|
5
|
+
module TranslateDate
|
6
|
+
|
7
|
+
# Takes a raw Jekyll date and returns a translated string according to the
|
8
|
+
# language of the current page and a date format given.
|
9
|
+
def t_date(date, format_type)
|
10
|
+
|
11
|
+
# Determine the language of the current page.
|
12
|
+
config = @context.registers[:site].config
|
13
|
+
translations = @context.registers[:site].data['translations']
|
14
|
+
language = @context.environments.first['page']['language']
|
15
|
+
|
16
|
+
# Try to find the specified date format in the site config. It needs to be
|
17
|
+
# something like this, assuming the "format_type" param is "standard":
|
18
|
+
# date_formats:
|
19
|
+
# standard:
|
20
|
+
# en: "%b %d, %Y"
|
21
|
+
# es: "%d de %b de %Y"
|
22
|
+
# etc...
|
23
|
+
date_format = '%b %d, %Y'
|
24
|
+
if config.has_key? 'date_formats'
|
25
|
+
if config['date_formats'].has_key? format_type
|
26
|
+
if config['date_formats'][format_type].has_key? language
|
27
|
+
date_format = config['date_formats'][format_type][language]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# Convert the date into English.
|
33
|
+
english = date.strftime(date_format)
|
34
|
+
|
35
|
+
# Now "tokenize" that date by spaces.
|
36
|
+
parts = english.split(' ')
|
37
|
+
|
38
|
+
translated_parts = []
|
39
|
+
parts.each do |part|
|
40
|
+
# Special case: see if we need to remove a comma from the end.
|
41
|
+
removed_comma = false
|
42
|
+
if part.end_with? ','
|
43
|
+
part = part.delete_suffix(',')
|
44
|
+
removed_comma = true
|
45
|
+
end
|
46
|
+
# Look for a translation in the "calendar" translation group.
|
47
|
+
key = 'calendar.' + part
|
48
|
+
translated_part = opensdg_translate_key(key, translations, language)
|
49
|
+
# If it changed from the key, that means it was a working key.
|
50
|
+
if key != translated_part
|
51
|
+
part = translated_part
|
52
|
+
end
|
53
|
+
|
54
|
+
# Add back the comma if needed.
|
55
|
+
if removed_comma
|
56
|
+
part = part + ','
|
57
|
+
end
|
58
|
+
|
59
|
+
translated_parts.push(part)
|
60
|
+
end
|
61
|
+
|
62
|
+
return translated_parts.join(' ')
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
Liquid::Template.register_filter(Jekyll::TranslateDate)
|
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: 1.0.0.
|
4
|
+
version: 1.0.0.rc18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brock Fanning
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-01-
|
11
|
+
date: 2020-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -58,6 +58,7 @@ files:
|
|
58
58
|
- lib/jekyll-open-sdg-plugins/helpers.rb
|
59
59
|
- lib/jekyll-open-sdg-plugins/sdg_variables.rb
|
60
60
|
- lib/jekyll-open-sdg-plugins/search_index.rb
|
61
|
+
- lib/jekyll-open-sdg-plugins/translate_date.rb
|
61
62
|
- lib/jekyll-open-sdg-plugins/translate_key.rb
|
62
63
|
- lib/jekyll-open-sdg-plugins/translate_metadata_field.rb
|
63
64
|
- lib/jekyll-open-sdg-plugins/version.rb
|
@@ -81,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
82
|
version: 1.3.1
|
82
83
|
requirements: []
|
83
84
|
rubyforge_project:
|
84
|
-
rubygems_version: 2.7.
|
85
|
+
rubygems_version: 2.7.6
|
85
86
|
signing_key:
|
86
87
|
specification_version: 4
|
87
88
|
summary: Jekyll plugins for use with the Open SDG platform
|