jekyll-polyglot 1.13.0 → 1.14.0
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 +4 -4
- data/README.md +8 -5
- data/lib/jekyll/polyglot/patches/jekyll/site.rb +42 -15
- metadata +5 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 431827884e33750d9871432f109f15ef806adc3c92ac12d69b4dd71d7f5b8c26
|
|
4
|
+
data.tar.gz: fbd2aa987e77785d37ad5578ef06b78fdd6f8de30e65007886c13f782605b51c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6b28158712094d6870f20bec2882608de81f0188087a8c609da85a6fd7c94f2a12769a220448696984e2464d34b9eadacdd55732b4a84e767d812d153bf69cb5
|
|
7
|
+
data.tar.gz: 9280111b1d14364adf562230d8e84512224ad880c88d9797771ce9fdaf3a5fe474ba803b9cfb691687f81ea92b9d21b4bcd90b3a7950d1d2b46268f666081c4d
|
data/README.md
CHANGED
|
@@ -30,13 +30,14 @@ languages: ["en", "sv", "de", "fr"]
|
|
|
30
30
|
default_lang: "en"
|
|
31
31
|
exclude_from_localization: ["javascript", "images", "css", "public", "sitemap", "CNAME"]
|
|
32
32
|
parallel_localization: true
|
|
33
|
+
serial_default_lang: true
|
|
33
34
|
url: https://polyglot.untra.io
|
|
34
35
|
```
|
|
35
36
|
These configuration preferences indicate
|
|
36
37
|
- what i18n languages you wish to support
|
|
37
38
|
- what is your default "fallback" language for your content
|
|
38
39
|
- 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.)
|
|
39
|
-
- 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.
|
|
40
|
+
- 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. - If `parallel_localization` collides with other jekyll plugins, this setting makes polyglot build the default language first before processing the other language sites.
|
|
40
41
|
- 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.
|
|
41
42
|
|
|
42
43
|
The optional `lang_from_path: true` option enables getting the page language from a filepath segment seperated by `/` or `.`, e.g `de/first-one.md`, or `_posts/zh_HK/use-second-segment.md` , if the lang frontmatter isn't defined.
|
|
@@ -461,7 +462,7 @@ These are talented and considerate software developers across the world that hav
|
|
|
461
462
|
* [@george-gca](https://github.com/george-gca) [pt-BR support](https://polyglot.untra.io/pt-BR/2024/02/29/localized-variables.md)
|
|
462
463
|
* [@PanderMusubi](https://github.com/PanderMusubi) - 1.12 / jekyll-minimal-mistakes-polyglot demo
|
|
463
464
|
* [@GruberMarkus](https://github.com/GruberMarkus) - redirect anchor support
|
|
464
|
-
* [@rathboma](https://github.com/rathboma) - page.rendered_lang / sublanguage redirects
|
|
465
|
+
* [@rathboma](https://github.com/rathboma) - page.rendered_lang / sublanguage redirects / serial_default_lang
|
|
465
466
|
* [@manabu-nakamura](https://github.com/manabu-nakamura) - Japanese strings
|
|
466
467
|
|
|
467
468
|
### Other Websites Built with Polyglot
|
|
@@ -496,10 +497,12 @@ Feel free to open a PR and list your multilingual blog here you may want to shar
|
|
|
496
497
|
* [x] - **site language**: turkish `tk`
|
|
497
498
|
* [x] - **site language**: ukrainian `uk`
|
|
498
499
|
* [x] - **site language**: hindi `hi`
|
|
499
|
-
* [
|
|
500
|
-
* [
|
|
501
|
-
* [ ] - get whitelisted as an official github-pages jekyll plugin
|
|
500
|
+
* [x] - **site language**: chinese Taiwan `zh-TW`
|
|
501
|
+
* [x] - **site language**: portuguese Portugal `pt-PT`
|
|
502
502
|
* [x] - update CI provider
|
|
503
|
+
* [ ] - get to 512 github stars
|
|
504
|
+
* [ ] - get whitelisted as an official github-pages jekyll plugin
|
|
505
|
+
|
|
503
506
|
|
|
504
507
|
## Copyright
|
|
505
508
|
Copyright (c) Samuel Volin 2025. License: MIT
|
|
@@ -3,13 +3,14 @@ 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, :lang_from_path, :fallback_canonical_to_default_lang
|
|
6
|
+
attr_reader :default_lang, :languages, :exclude_from_localization, :lang_vars, :lang_from_path, :fallback_canonical_to_default_lang, :serial_default_lang
|
|
7
7
|
attr_accessor :file_langs, :active_lang
|
|
8
8
|
|
|
9
9
|
def prepare
|
|
10
10
|
@file_langs = {}
|
|
11
11
|
fetch_languages
|
|
12
12
|
@parallel_localization = config.fetch('parallel_localization', true)
|
|
13
|
+
@serial_default_lang = config.fetch('serial_default_lang', false)
|
|
13
14
|
@lang_from_path = config.fetch('lang_from_path', false)
|
|
14
15
|
@fallback_canonical_to_default_lang = config.fetch('fallback_canonical_to_default_lang', false)
|
|
15
16
|
@exclude_from_localization = config.fetch('exclude_from_localization', []).map do |e|
|
|
@@ -34,14 +35,21 @@ module Jekyll
|
|
|
34
35
|
prepare
|
|
35
36
|
all_langs = ([@default_lang] + @languages).uniq
|
|
36
37
|
if @parallel_localization
|
|
38
|
+
if @serial_default_lang
|
|
39
|
+
# Run the default language in the parent first to prime
|
|
40
|
+
process_language @default_lang
|
|
41
|
+
langs_to_fork = @languages - [@default_lang]
|
|
42
|
+
else
|
|
43
|
+
langs_to_fork = all_langs
|
|
44
|
+
end
|
|
37
45
|
nproc = Etc.nprocessors
|
|
38
46
|
pids = {}
|
|
39
47
|
begin
|
|
40
|
-
|
|
48
|
+
langs_to_fork.each do |lang|
|
|
41
49
|
pids[lang] = fork do
|
|
42
50
|
process_language lang
|
|
43
51
|
end
|
|
44
|
-
while pids.length >= (lang ==
|
|
52
|
+
while pids.length >= (lang == langs_to_fork[-1] ? 1 : nproc)
|
|
45
53
|
sleep 0.1
|
|
46
54
|
pids.map do |pid_lang, pid|
|
|
47
55
|
next unless waitpid pid, Process::WNOHANG
|
|
@@ -52,7 +60,7 @@ module Jekyll
|
|
|
52
60
|
end
|
|
53
61
|
end
|
|
54
62
|
rescue Interrupt
|
|
55
|
-
|
|
63
|
+
langs_to_fork.each do |lang|
|
|
56
64
|
next unless pids.key? lang
|
|
57
65
|
|
|
58
66
|
puts "Killing #{pids[lang]} : #{lang}"
|
|
@@ -154,12 +162,7 @@ module Jekyll
|
|
|
154
162
|
explicit_lang = doc.data['lang'] || derive_lang_from_path(doc)
|
|
155
163
|
lang = explicit_lang || @default_lang
|
|
156
164
|
|
|
157
|
-
#
|
|
158
|
-
# Check the explicit value (not the fallback) so that documents with an
|
|
159
|
-
# unconfigured lang like 'de' are excluded even if normalization would
|
|
160
|
-
# map them to default_lang. Compare case-insensitively so case-mismatched
|
|
161
|
-
# frontmatter (e.g. 'pt-br' vs configured 'pt-BR') is normalized below
|
|
162
|
-
# rather than rejected here.
|
|
165
|
+
# Skip documents whose explicit lang is not in configured languages.
|
|
163
166
|
if explicit_lang && valid_languages.none? { |l| l.downcase == explicit_lang.downcase }
|
|
164
167
|
Jekyll.logger.warn "Polyglot:", "Skipping #{doc.relative_path} - lang '#{explicit_lang}' not in configured languages #{valid_languages.inspect}"
|
|
165
168
|
next
|
|
@@ -211,11 +214,12 @@ module Jekyll
|
|
|
211
214
|
user_redirects = user_redirects.map do |redirect_path|
|
|
212
215
|
# Normalize path to start with /
|
|
213
216
|
redirect_path = "/#{redirect_path}" unless redirect_path.start_with?('/')
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
+
if redirect_path == "/#{doc_lang}"
|
|
218
|
+
'/'
|
|
219
|
+
elsif redirect_path.start_with?("/#{doc_lang}/")
|
|
220
|
+
redirect_path.delete_prefix("/#{doc_lang}")
|
|
217
221
|
else
|
|
218
|
-
|
|
222
|
+
redirect_path
|
|
219
223
|
end
|
|
220
224
|
end
|
|
221
225
|
end
|
|
@@ -305,7 +309,10 @@ module Jekyll
|
|
|
305
309
|
non_rel_regex = relative_url_regex(true)
|
|
306
310
|
non_abs_regex = absolute_url_regex(url, true)
|
|
307
311
|
docs.each do |doc|
|
|
308
|
-
unless @active_lang == @default_lang
|
|
312
|
+
unless @active_lang == @default_lang || doc.output.nil?
|
|
313
|
+
localize_redirect_target(doc)
|
|
314
|
+
relativize_urls(doc, rel_regex)
|
|
315
|
+
end
|
|
309
316
|
correct_nonrelativized_urls(doc, non_rel_regex)
|
|
310
317
|
if url
|
|
311
318
|
unless @active_lang == @default_lang then relativize_absolute_urls(doc, abs_regex, url) end
|
|
@@ -314,6 +321,26 @@ module Jekyll
|
|
|
314
321
|
end
|
|
315
322
|
end
|
|
316
323
|
|
|
324
|
+
# jekyll-redirect-from renders its target into (script location=, meta refresh url=)
|
|
325
|
+
# rewrite the redirect target before language lookaheads in the href regexes skip
|
|
326
|
+
def localize_redirect_target(doc)
|
|
327
|
+
return if @active_lang == @default_lang || doc.output.nil?
|
|
328
|
+
|
|
329
|
+
redirect = doc.data['redirect']
|
|
330
|
+
return unless redirect.is_a?(Hash)
|
|
331
|
+
|
|
332
|
+
target = redirect['to'].to_s
|
|
333
|
+
origin = "#{config['url']}#{@baseurl}"
|
|
334
|
+
return unless target.start_with?("#{origin}/")
|
|
335
|
+
|
|
336
|
+
path = target.delete_prefix(origin)
|
|
337
|
+
return if path.start_with?("/#{@active_lang}/")
|
|
338
|
+
|
|
339
|
+
localized = "#{origin}/#{@active_lang}#{path}"
|
|
340
|
+
doc.output = doc.output.gsub(target, localized)
|
|
341
|
+
redirect['to'] = localized
|
|
342
|
+
end
|
|
343
|
+
|
|
317
344
|
# a regex that matches urls or permalinks with i18n prefixes or suffixes
|
|
318
345
|
# matches /en/foo , .en/foo , foo.en/ and other simmilar default urls
|
|
319
346
|
# made by jekyll when parsing documents without explicitly set permalinks
|
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.14.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: 2026-
|
|
11
|
+
date: 2026-08-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: jekyll
|
|
@@ -65,14 +65,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
65
65
|
requirements:
|
|
66
66
|
- - ">="
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: 3.
|
|
68
|
+
version: 3.2.0
|
|
69
69
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
70
|
requirements:
|
|
71
71
|
- - ">="
|
|
72
72
|
- !ruby/object:Gem::Version
|
|
73
|
-
version: 3.
|
|
73
|
+
version: 3.2.0
|
|
74
74
|
requirements: []
|
|
75
|
-
rubygems_version: 3.
|
|
75
|
+
rubygems_version: 3.4.19
|
|
76
76
|
signing_key:
|
|
77
77
|
specification_version: 4
|
|
78
78
|
summary: I18n plugin for Jekyll Blogs
|