jekyll-polyglot 1.8.1 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +23 -11
- data/lib/jekyll/polyglot/patches/jekyll/site.rb +22 -11
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58fab59c4c6aabba378edb4622f960b9ee2910c41e9b7cb329218cf4602bfaa2
|
4
|
+
data.tar.gz: 2a077894396baca9c8215a44abe6734abd9c1c00d0975259cf98380f77e72a10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c90c5e30bd2703cfab18b75b0a23d6a94350709dcd4d1acfade18497f4ce7bdddeba18cc9efd1cf527e3aeb5295e422e0108da10a12f556b2a007f5e57a26b6
|
7
|
+
data.tar.gz: fdda50a81bbbd06e90e4b170be83f207b01f1f66eeabea7b4aff68421bc5bbcdf124e3cccf737d01cfa59f48fb914121953140cdde9ecadd6f572b31c1ba08d7
|
data/README.md
CHANGED
@@ -27,15 +27,16 @@ 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", "public"]
|
30
|
+
exclude_from_localization: ["javascript", "images", "css", "public", "sitemap"]
|
31
31
|
parallel_localization: true
|
32
|
+
url: https://polyglot.untra.io
|
32
33
|
```
|
33
34
|
These configuration preferences indicate
|
34
35
|
- what i18n languages you wish to support
|
35
36
|
- what is your default "fallback" language for your content
|
36
|
-
- what root level files/folders are excluded from localization, based
|
37
|
-
|
38
|
-
-
|
37
|
+
- what root level files/folders are excluded from localization, based on if their paths start with any of the excluded regexp substrings. (this is different from the jekyll `exclude: [ .gitignore ]` ; you should `exclude` files and directories in your repo you dont want in your built site at all, and `exclude_from_localization` files and directories you want to see in your built site, but not in your sublanguage sites.)
|
38
|
+
- whether to run language processing in parallel or serial. Set to `false` if building on Windows hosts, or if Polyglot collides with other Jekyll plugins.
|
39
|
+
- your jekyll website production url. Make sure this value is set; Polyglot requires this to relative site urls correctly, and to make functioning language switchers.
|
39
40
|
|
40
41
|
The optional `lang_from_path: true` option enables getting page
|
41
42
|
language from the first or second path segment, e.g `de/first-one.md`, or
|
@@ -46,7 +47,7 @@ When adding new posts and pages, add to the YAML front matter:
|
|
46
47
|
```
|
47
48
|
lang: sv
|
48
49
|
```
|
49
|
-
or whatever appropriate [I18n language code](https://developer.chrome.com/
|
50
|
+
or whatever appropriate [I18n language code](https://developer.chrome.com/docs/extensions/reference/api/i18n#locales)
|
50
51
|
the page should build for. And you're done. Ideally, when designing your site, you should
|
51
52
|
organize files by their relative urls.
|
52
53
|
|
@@ -260,7 +261,7 @@ This plugin stands out from other I18n Jekyll plugins.
|
|
260
261
|
- provides the liquid tag `{{ site.languages }}` to get an array of your I18n strings.
|
261
262
|
- provides the liquid tag `{{ site.default_lang }}` to get the default_lang I18n string.
|
262
263
|
- provides the liquid tag `{{ site.active_lang }}` to get the I18n language string the website was built for. Alternative names for `active_lang` can be configured via `config.lang_vars`.
|
263
|
-
- provides the liquid tag `{{ I18n_Headers
|
264
|
+
- provides the liquid tag `{{ I18n_Headers }}` to append SEO bonuses to your website.
|
264
265
|
- provides the liquid tag `{{ Unrelativized_Link href="/hello" }}` to make urls that do not get influenced by url correction regexes.
|
265
266
|
- provides `site.data` localization for efficient rich text replacement.
|
266
267
|
- a creator that will answer all of your questions and issues.
|
@@ -272,6 +273,13 @@ Jekyll-polyglot has a few spectacular [Search Engine Optimization techniques](ht
|
|
272
273
|
|
273
274
|
See the example [sitemap.xml](/site/sitemap.xml) and [robots.txt](/site/robots.txt) for how to automatically generate a multi-language sitemap for your page and turn it in for the SEO i18n credit.
|
274
275
|
|
276
|
+
The [official Sitemap protocol documentation](https://www.sitemaps.org/protocol.html#location) states:
|
277
|
+
> "The location of a Sitemap file determines the set of URLs that can be included in that Sitemap. A Sitemap file located at http://example.com/catalog/sitemap.xml can include any URLs starting with http://example.com/catalog/ but can not include URLs starting with http://example.com/images/."
|
278
|
+
|
279
|
+
> "It is strongly recommended that you place your Sitemap at the root directory of your web server."
|
280
|
+
|
281
|
+
To comply with this, 'sitemap.xml' should be added to the 'exclude_from_localization' list to ensure that only one `sitemap.xml` file exists in the root directory, rather than creating separate ones for each language.
|
282
|
+
|
275
283
|
## Compatibility
|
276
284
|
Currently supports Jekyll 3.0 , and Jekyll 4.0
|
277
285
|
* Windows users will need to disable parallel_localization on their machines by setting `parallel_localization: false` in the `_config.yml`
|
@@ -291,17 +299,18 @@ If you have something you'd like to contribute to jekyll-polyglot, please open a
|
|
291
299
|
These are talented and considerate software developers across the world that have lent their support to this project.
|
292
300
|
**Thank You! ¡Gracias! Merci! Danke! 감사합니다! תודה רבה! Спасибо! Dankjewel! 谢谢!Obrigado!**
|
293
301
|
|
302
|
+
* [@yunseo-kim](https://github.com/yunseo-kim) [improved i18n sitemaps]((https://polyglot.untra.io/2025/01/18/polyglot-1.9.0/))
|
294
303
|
* [@blackpill](https://github.com/blackpill) [1.8.1](https://polyglot.untra.io/2024/08/18/polyglot-1.8.1/)
|
295
304
|
* [@hacketiwack](https://github.com/hacketiwack) [1.8.1](https://polyglot.untra.io/2024/08/18/polyglot-1.8.1/)
|
296
305
|
* [@jerturowetz](https://github.com/jerturowetz) [sitemap generation](https://polyglot.untra.io/2024/03/17/polyglot-1.8.0/)
|
297
306
|
* [@antoniovazquezblanco](https://github.com/antoniovazquezblanco) [1.7.0](https://polyglot.untra.io/2023/10/29/polyglot-1.7.0/)
|
298
|
-
* [@salinatedcoffee](https://github.com/SalinatedCoffee) [ko support](https://polyglot.untra.io/2023/02/27/korean-support/)
|
299
|
-
* [@aturret](https://github.com/aturret) [zh-CN support](https://polyglot.untra.io/2023/06/08/polyglot-1.6.0-chinese-support/)
|
307
|
+
* [@salinatedcoffee](https://github.com/SalinatedCoffee) [ko support](https://polyglot.untra.io/ko/2023/02/27/korean-support/)
|
308
|
+
* [@aturret](https://github.com/aturret) [zh-CN support](https://polyglot.untra.io/zh-CN/2023/06/08/polyglot-1.6.0-chinese-support/)
|
300
309
|
* [@dougieh](https://github.com/dougieh) [1.5.1](https://polyglot.untra.io/2022/10/01/polyglot-1.5.1/)
|
301
|
-
* [@pandermusubi](https://github.com/PanderMusubi) [nl support](https://polyglot.untra.io/2022/01/15/dutch-site-support/)
|
310
|
+
* [@pandermusubi](https://github.com/PanderMusubi) [nl support](https://polyglot.untra.io/nl/2022/01/15/dutch-site-support/)
|
302
311
|
* [@obfusk](https://github.com/obfusk) [1.5.0](https://polyglot.untra.io/2021/07/17/polyglot-1.5.0/)
|
303
312
|
* [@eighthave](https://github.com/eighthave) [1.5.0](https://polyglot.untra.io/2021/07/17/polyglot-1.5.0/)
|
304
|
-
* [@george-gca](https://github.com/george-gca) [
|
313
|
+
* [@george-gca](https://github.com/george-gca) [pt-BR support](https://polyglot.untra.io/pt-BR/2024/02/29/localized-variables.md)
|
305
314
|
|
306
315
|
### Other Websites Built with Polyglot
|
307
316
|
Feel free to open a PR and list your multilingual blog here you may want to share:
|
@@ -317,6 +326,9 @@ Feel free to open a PR and list your multilingual blog here you may want to shar
|
|
317
326
|
* [Yi Yunseok's personal blog website](https://Yi-Yunseok.GitHub.io)
|
318
327
|
* [Tarlogic Cybersecurity](https://www.tarlogic.com/)
|
319
328
|
* [A beautiful, simple, clean, and responsive Jekyll theme for academics](https://github.com/george-gca/multi-language-al-folio)
|
329
|
+
* [AnotherTurret just another study note blog](https://aturret.space/)
|
330
|
+
* [Diciotech is a collaborative online tech dictionary](https://diciotech.netlify.app/)
|
331
|
+
* [Yunseo Kim's Study Notes](https://www.yunseo.kim/)
|
320
332
|
|
321
333
|
## 2.0 Roadmap
|
322
334
|
* [x] - **site language**: portuguese Brazil `pt-BR`
|
@@ -333,4 +345,4 @@ Feel free to open a PR and list your multilingual blog here you may want to shar
|
|
333
345
|
* [x] - update CI provider
|
334
346
|
|
335
347
|
## Copyright
|
336
|
-
Copyright (c) Samuel Volin
|
348
|
+
Copyright (c) Samuel Volin 2025. License: MIT
|
@@ -3,7 +3,7 @@ require 'etc'
|
|
3
3
|
include Process
|
4
4
|
module Jekyll
|
5
5
|
class Site
|
6
|
-
attr_reader :default_lang, :languages, :exclude_from_localization, :lang_vars
|
6
|
+
attr_reader :default_lang, :languages, :exclude_from_localization, :lang_vars, :lang_from_path
|
7
7
|
attr_accessor :file_langs, :active_lang
|
8
8
|
|
9
9
|
def prepare
|
@@ -108,21 +108,32 @@ module Jekyll
|
|
108
108
|
@exclude = old_exclude
|
109
109
|
end
|
110
110
|
|
111
|
+
def split_on_multiple_delimiters(string)
|
112
|
+
delimiters = ['.', '/']
|
113
|
+
regex = Regexp.union(delimiters)
|
114
|
+
string.split(regex)
|
115
|
+
end
|
116
|
+
|
111
117
|
def derive_lang_from_path(doc)
|
112
118
|
unless @lang_from_path
|
113
119
|
return nil
|
114
120
|
end
|
115
121
|
|
116
|
-
segments = doc.
|
117
|
-
if
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
&& segments[0] =~ /^[a-z]{2,3}(:?[_-](:?[A-Za-z]{2}){1,2}){0,2}$/
|
123
|
-
return segments[0]
|
122
|
+
segments = split_on_multiple_delimiters(doc.path)
|
123
|
+
# loop through all segments and check if they match the language regex
|
124
|
+
segments.each do |segment|
|
125
|
+
if @languages.include?(segment)
|
126
|
+
return segment
|
127
|
+
end
|
124
128
|
end
|
125
129
|
|
130
|
+
# loop through all segments and check if they match the language regex
|
131
|
+
segments.each do |segment|
|
132
|
+
if @languages.include?(segment)
|
133
|
+
return segment
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
126
137
|
nil
|
127
138
|
end
|
128
139
|
|
@@ -152,8 +163,8 @@ module Jekyll
|
|
152
163
|
approved[page_id] = doc
|
153
164
|
@file_langs[page_id] = lang
|
154
165
|
end
|
155
|
-
approved.values.each {|doc| assignPageRedirects(doc, docs) }
|
156
|
-
approved.values.each {|doc| assignPageLanguagePermalinks(doc, docs) }
|
166
|
+
approved.values.each { |doc| assignPageRedirects(doc, docs) }
|
167
|
+
approved.values.each { |doc| assignPageLanguagePermalinks(doc, docs) }
|
157
168
|
approved.values
|
158
169
|
end
|
159
170
|
|
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.
|
4
|
+
version: 1.9.0
|
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: 2025-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|