jekyll-polyglot 1.3.1 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/LICENSE +1 -1
- data/README.md +19 -6
- data/lib/jekyll/polyglot/patches/jekyll/site.rb +40 -6
- data/lib/jekyll/polyglot/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e3f7773339c45333233f02e73f7e7c96e87a6609ebdb6e6c1082b3adebf679d0
|
4
|
+
data.tar.gz: 5d8bdce1424b3be47d4e1dc07d1dba638436c2c65674e00845c354352b118387
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 154f29a20360f6db96f4be7c8584158c9d71c723ae306ad4093ab306eb6b52877bf75ebd5cf222251ebbadfada6c075d1dda06b65f0108b0eddbc8621e05b016
|
7
|
+
data.tar.gz: 240fdec79c5f4188d46a3ec160b17b8fc57fd5341564e105464bf877aa0d8bfe7b69d1f1bbc51c56d03c2a85499f33143ed77eb9131e62891e2c7f76147065c1
|
data/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2015 -
|
1
|
+
Copyright (c) 2015 - 2020 Samuel Volin
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
4
|
|
data/README.md
CHANGED
@@ -27,15 +27,20 @@ In your `_config.yml` file, add the following preferences
|
|
27
27
|
```YAML
|
28
28
|
languages: ["en", "sv", "de", "fr"]
|
29
29
|
default_lang: "en"
|
30
|
-
exclude_from_localization: ["javascript", "images", "css"]
|
30
|
+
exclude_from_localization: ["javascript", "images", "css", "README.md"]
|
31
31
|
parallel_localization: true
|
32
32
|
```
|
33
33
|
These configuration preferences indicate
|
34
34
|
- what i18n languages you wish to support
|
35
35
|
- what is your default "fallback" language for your content
|
36
|
-
- what root level folders are
|
36
|
+
- what root level files/folders are excluded from localization, based
|
37
|
+
on if their paths start with any of the excluded regexp substrings
|
37
38
|
- whether to run language processing in parallel or serial
|
38
39
|
|
40
|
+
The optional `lang_from_path: true` option enables getting page
|
41
|
+
language from the first or second path segment, e.g `de/first-one.md`, or
|
42
|
+
`_posts/zh_Hans_HK/use-second-segment.md` , if the lang frontmatter isn't defined.
|
43
|
+
|
39
44
|
## How To Use It
|
40
45
|
When adding new posts and pages, add to the YAML front matter:
|
41
46
|
```
|
@@ -152,13 +157,21 @@ Jekyll-polyglot has a few spectacular [Search Engine Optimization techniques](ht
|
|
152
157
|
|
153
158
|
### Other Websites Built with Polyglot
|
154
159
|
let us know if you make a multilingual blog you want to share:
|
155
|
-
* [Polyglot
|
160
|
+
* [Polyglot project website](http://polyglot.untra.io)
|
156
161
|
* [LogRhythm Corporate Website](http://logrhythm.com)
|
157
162
|
* [All Over Earth](https://allover.earth/)
|
163
|
+
* [Hanare Cafe in Toshijima, Japan](https://hanarecafe.com)
|
164
|
+
* [F-Droid](https://f-droid.org)
|
158
165
|
|
159
166
|
## Compatibility
|
160
|
-
Currently supports Jekyll 3.0 .
|
161
|
-
|
167
|
+
Currently supports Jekyll 3.0 , and Jekyll 4.0 (for the most part)
|
168
|
+
|
169
|
+
* *Windows users will need to disable parallel_localization on their machines by setting `parallel_localization: false` in the `_config.yml`
|
170
|
+
* In Jekyll 4.0 , SCSS source maps will generate improperly due to how Polyglot operates. The workaround is to disable the CSS sourcemaps. Adding rhe following to your `config.yml` will disable sourcemap generation:
|
171
|
+
```yaml
|
172
|
+
sass:
|
173
|
+
sourcemap: never
|
174
|
+
```
|
162
175
|
|
163
176
|
## Copyright
|
164
|
-
Copyright (c) Samuel Volin
|
177
|
+
Copyright (c) Samuel Volin 2020. License: MIT
|
@@ -8,7 +8,15 @@ module Jekyll
|
|
8
8
|
@file_langs = {}
|
9
9
|
fetch_languages
|
10
10
|
@parallel_localization = config.fetch('parallel_localization', true)
|
11
|
-
@
|
11
|
+
@lang_from_path = config.fetch('lang_from_path', false)
|
12
|
+
@exclude_from_localization = config.fetch('exclude_from_localization', []).map do |e|
|
13
|
+
if File.directory?(e) and e[-1] != '/'
|
14
|
+
e + '/'
|
15
|
+
else
|
16
|
+
e
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
12
20
|
end
|
13
21
|
|
14
22
|
def fetch_languages
|
@@ -88,13 +96,32 @@ module Jekyll
|
|
88
96
|
@exclude = old_exclude
|
89
97
|
end
|
90
98
|
|
99
|
+
def derive_lang_from_path(doc)
|
100
|
+
if !@lang_from_path
|
101
|
+
return nil
|
102
|
+
end
|
103
|
+
segments = doc.relative_path.split('/')
|
104
|
+
if doc.relative_path[0] == '_' \
|
105
|
+
and segments.length > 2 \
|
106
|
+
and segments[1] =~ /^[a-z]{2,3}(:?[_-](:?[A-Za-z]{2}){1,2}){0,2}$/
|
107
|
+
return segments[1]
|
108
|
+
elsif segments.length > 1 \
|
109
|
+
and segments[0] =~ /^[a-z]{2,3}(:?[_-](:?[A-Za-z]{2}){1,2}){0,2}$/
|
110
|
+
return segments[0]
|
111
|
+
else
|
112
|
+
return nil
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
91
116
|
# assigns natural permalinks to documents and prioritizes documents with
|
92
|
-
# active_lang languages over others
|
117
|
+
# active_lang languages over others. If lang is not set in front matter,
|
118
|
+
# then this tries to derive from the path, if the lang_from_path is set.
|
119
|
+
# otherwise it will assign the document to the default_lang
|
93
120
|
def coordinate_documents(docs)
|
94
121
|
regex = document_url_regex
|
95
122
|
approved = {}
|
96
123
|
docs.each do |doc|
|
97
|
-
lang = doc.data['lang'] || @default_lang
|
124
|
+
lang = doc.data['lang'] || derive_lang_from_path(doc) || @default_lang
|
98
125
|
url = doc.url.gsub(regex, '/')
|
99
126
|
doc.data['permalink'] = url
|
100
127
|
next if @file_langs[url] == @active_lang
|
@@ -133,10 +160,14 @@ module Jekyll
|
|
133
160
|
|
134
161
|
# a regex that matches relative urls in a html document
|
135
162
|
# matches href="baseurl/foo/bar-baz" and others like it
|
136
|
-
# avoids matching excluded files
|
163
|
+
# avoids matching excluded files. prepare makes sure
|
164
|
+
# that all @exclude dirs have a trailing slash.
|
137
165
|
def relative_url_regex
|
138
166
|
regex = ''
|
139
|
-
(@exclude
|
167
|
+
(@exclude).each do |x|
|
168
|
+
regex += "(?!#{x})"
|
169
|
+
end
|
170
|
+
(@languages).each do |x|
|
140
171
|
regex += "(?!#{x}\/)"
|
141
172
|
end
|
142
173
|
%r{href=\"?#{@baseurl}\/((?:#{regex}[^,'\"\s\/?\.#]+\.?)*(?:\/[^\]\[\)\(\"\'\s]*)?)\"}
|
@@ -144,7 +175,10 @@ module Jekyll
|
|
144
175
|
|
145
176
|
def absolute_url_regex(url)
|
146
177
|
regex = ''
|
147
|
-
(@exclude
|
178
|
+
(@exclude).each do |x|
|
179
|
+
regex += "(?!#{x})"
|
180
|
+
end
|
181
|
+
(@languages).each do |x|
|
148
182
|
regex += "(?!#{x}\/)"
|
149
183
|
end
|
150
184
|
%r{href=\"?#{url}#{@baseurl}\/((?:#{regex}[^,'\"\s\/?\.#]+\.?)*(?:\/[^\]\[\)\(\"\'\s]*)?)\"}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-polyglot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Volin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -63,8 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
63
63
|
- !ruby/object:Gem::Version
|
64
64
|
version: '0'
|
65
65
|
requirements: []
|
66
|
-
|
67
|
-
rubygems_version: 2.5.1
|
66
|
+
rubygems_version: 3.1.2
|
68
67
|
signing_key:
|
69
68
|
specification_version: 4
|
70
69
|
summary: I18n plugin for Jekyll Blogs
|