jekyll-polyglot 1.0.1 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/polyglot.rb +26 -28
- metadata +3 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca5555c293e66a474d1e376be77e2734c3306f4a
|
4
|
+
data.tar.gz: 4c4c2f6caa77f7571ba4274964873e598ff7cb29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4a344bd2433929d60bd767747a8366e3beefef1152e1ee0fe2f5e8ee2be5fed005ed14875b3f99e9f94197eb8c9f8b147c38433d7578b84ca6e1917b7d2cba8
|
7
|
+
data.tar.gz: af745ab17521284b5dfc294de4666dc80b8a0eaca237817d61099e7bb342c460bb69fffdb169b5b2926c51371d68043fcd521526c20cbbe7f3bb7079357a0713
|
data/lib/polyglot.rb
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# Jekyll Polyglot v1.1.1
|
2
|
+
# Fast, painless, open source i18n plugin for Jekyll 3.0 Blogs.
|
3
|
+
# author: Samuel Volin (@untra)
|
4
|
+
# github: https://github.com/untra/polyglot
|
5
|
+
# license: MIT
|
1
6
|
include Process
|
2
7
|
module Jekyll
|
3
8
|
# Alteration to Jekyll Site class
|
@@ -8,7 +13,6 @@ module Jekyll
|
|
8
13
|
attr_accessor :file_langs, :active_lang
|
9
14
|
|
10
15
|
def prepare
|
11
|
-
@start_time = time
|
12
16
|
@file_langs = {}
|
13
17
|
@default_lang = config['default_lang'] || 'en'
|
14
18
|
@languages = config['languages'] || ['en']
|
@@ -50,44 +54,38 @@ module Jekyll
|
|
50
54
|
def process_language(lang)
|
51
55
|
@active_lang = lang
|
52
56
|
config['active_lang'] = @active_lang
|
53
|
-
return
|
57
|
+
return process_orig if @active_lang == @default_lang
|
54
58
|
process_active_language
|
55
59
|
end
|
56
60
|
|
57
61
|
def process_active_language
|
58
|
-
dest_orig = dest
|
59
|
-
exclude_orig = exclude
|
60
62
|
@dest = @dest + '/' + @active_lang
|
61
63
|
@exclude += config['exclude_from_localization']
|
62
|
-
|
63
|
-
@dest = dest_orig
|
64
|
-
@exclude = exclude_orig
|
64
|
+
process_orig
|
65
65
|
end
|
66
66
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
filter
|
71
|
-
generate
|
72
|
-
render
|
73
|
-
cleanup
|
74
|
-
puts "Building #{lang} Site"
|
75
|
-
write
|
76
|
-
end
|
77
|
-
|
78
|
-
def filter
|
67
|
+
# hook to coordinate blog posts into distinct urls,
|
68
|
+
# and remove duplicate multilanguage posts
|
69
|
+
Jekyll::Hooks.register :site, :post_read do |site|
|
79
70
|
langs = {}
|
80
71
|
approved = {}
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
72
|
+
n = ''
|
73
|
+
site.languages.each do |lang|
|
74
|
+
n += "([\/\.]#{lang}[\/\.])|"
|
75
|
+
end
|
76
|
+
n.chomp! '|'
|
77
|
+
site.posts.docs.each do |doc|
|
78
|
+
language = doc.data['lang'] || site.default_lang
|
79
|
+
url = doc.url.gsub(%r{#{n}}, '/')
|
80
|
+
doc.data['permalink'] = url
|
81
|
+
next if langs[url] == site.active_lang
|
82
|
+
if langs[url] == site.default_lang
|
83
|
+
next if language != site.active_lang
|
86
84
|
end
|
87
|
-
approved[
|
88
|
-
langs[
|
85
|
+
approved[url] = doc
|
86
|
+
langs[url] = language
|
89
87
|
end
|
90
|
-
|
88
|
+
site.posts.docs = approved.values
|
91
89
|
end
|
92
90
|
end
|
93
91
|
|
@@ -143,7 +141,7 @@ module Jekyll
|
|
143
141
|
n += "(?!#{x}\/)"
|
144
142
|
end
|
145
143
|
# regex that looks for all relative urls except for excluded files
|
146
|
-
%r{href=\"
|
144
|
+
%r{href=\"#{site.baseurl}\/((?:#{n}[^,'\"\s\/?\.#-]+\.?)*(?:\/[^\]\[\)\(\"\'\s]*)?)\"}
|
147
145
|
end
|
148
146
|
end
|
149
147
|
|
metadata
CHANGED
@@ -1,35 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-polyglot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Volin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: listen
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '3.0'
|
20
|
-
- - ">="
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 3.0.0
|
23
|
-
type: :development
|
24
|
-
prerelease: false
|
25
|
-
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
requirements:
|
27
|
-
- - "~>"
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '3.0'
|
30
|
-
- - ">="
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: 3.0.0
|
11
|
+
date: 2015-12-20 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
33
13
|
description: Fast open source internationalization plugin for Jekyll blogs.
|
34
14
|
email: untra.sam@gmail.com
|
35
15
|
executables: []
|