jekyll-polyglot 1.4.1 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 44004d45f57d6cd3d029fb2dd11aa4636a003648e88cbb8c0af96707379143ea
4
- data.tar.gz: 944467976c70ec60171b5c8e9717d13ac844be691ab315d7937aa827eb9d42de
3
+ metadata.gz: 575ea909b15958d5cddafc881fb4342326f205bf9fafbce8a79981133c4a15e5
4
+ data.tar.gz: 1e881bdd502d11c0b3c171b7a4db7670d314f32ea0fe192a9a3fffbd47b1e1c2
5
5
  SHA512:
6
- metadata.gz: 381ec1f760288a9945c0a353b3b1cdc5ba7bcbc14a6f6b261e23d28ae6007b25770814d2b14deb8daec986271211f9b822429135449de3974b6c71041807c344
7
- data.tar.gz: 8a39f63b3b72670d561299308940a76f24008d73ca84411272776767beee24c2d8a1b5dce02f99d5a490635ec8ddfaa11b0ce390a203073cc283bf13c73e378a
6
+ metadata.gz: 15cd5d7b397550143957d9ebf7404c35c241bf4357f75f6fa7f44bde56034d631a3ea6ee0e7e3d80a53a9f8abcb99a5ee5b8685d125b63e08369db9cae28c1d7
7
+ data.tar.gz: f837a8c341809322d210a90098d9016d6303865a665a832abf38443912f61c969a1e5c08dc4b2206f0ef47712ce24e208202b6c46e2d34ceaa1066c6ff19aeef
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2015 - 2020 Samuel Volin
1
+ Copyright (c) 2015 - 2022 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
@@ -1,7 +1,7 @@
1
- :abc: Polyglot
1
+ 🔤 Polyglot
2
2
  ---
3
3
  [![Gem Version](https://badge.fury.io/rb/jekyll-polyglot.svg)](https://badge.fury.io/rb/jekyll-polyglot)
4
- [![Build Status](https://travis-ci.org/untra/polyglot.svg?branch=master)](https://travis-ci.org/untra/polyglot)
4
+ [![CircleCI](https://circleci.com/gh/untra/polyglot/tree/master.svg?style=svg)](https://circleci.com/gh/untra/polyglot/?branch=master)
5
5
 
6
6
  __Polyglot__ is a fast, painless, open-source internationalization plugin for [Jekyll](http://jekyllrb.com) blogs. Polyglot is easy to setup and use with any Jekyll project, and it scales to the languages you want to support. With fallback support for missing content, automatic url relativization, and powerful SEO tools, Polyglot allows any multi-language jekyll blog to focus on content without the cruft.
7
7
 
@@ -34,7 +34,7 @@ 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
36
  - what root level files/folders are excluded from localization, based
37
- on if their paths start with any of the excluded regexp substrings. (this is different than the jekyll `exclude: [README.md, CNAME]` ; 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 in your built site, but not in your sublanguage sites.)
37
+ on if their paths start with any of the excluded regexp substrings. (this is different than 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
38
  - whether to run language processing in parallel or serial
39
39
 
40
40
  The optional `lang_from_path: true` option enables getting page
@@ -112,32 +112,19 @@ becomes
112
112
 
113
113
  #### Disabling Url Relativizing
114
114
  _New in 1.4.0_
115
- If you dont want a href attribute to be relativized (such as for making [a language switcher](https://github.com/untra/polyglot/blob/master/site/_includes/sidebar.html#L40)), you can use the `{% static_href %}href="..."{% endstatic_href %}` block tag.
115
+ If you dont want a href attribute to be relativized (such as for making [a language switcher](https://github.com/untra/polyglot/blob/master/site/_includes/sidebar.html#L40)), you can use the block tag:
116
116
 
117
117
  ```html
118
- <a {% static_href %}href="/about"{% endstatic_href %}>click this static link</a>
118
+ {% static_href %}href="..."{% endstatic_href %}
119
119
  ```
120
120
 
121
- that will generate `<a href="/about">click this static link</a>` which is what you would normally use to create a url unmangled by invisible language relativization.
122
-
123
- _Previous (no longer) Recommendation:_
124
- If you don't want aa url to be relativized, you can add a space explicitly into the href to prevent a url from being relativized by polyglot.
125
-
126
- For example, the following urls will be relativized:
127
-
128
121
  ```html
129
- href="http://mywebsite.com/about"
130
- href="/about"
122
+ <a {% static_href %}href="/about"{% endstatic_href %}>click this static link</a>
131
123
  ```
132
124
 
133
- and the following urls will be left alone:
134
-
135
- ```html
136
- href=" http://mywebsite.com/about"
137
- href=" /about"
138
- ```
125
+ that will generate `<a href="/about">click this static link</a>` which is what you would normally use to create a url unmangled by invisible language relativization.
139
126
 
140
- combine with a [html minifier](https://github.com/digitalsparky/jekyll-minifier) for a polished and production ready website. -->
127
+ Combine with a [html minifier](https://github.com/digitalsparky/jekyll-minifier) for a polished and production ready website.
141
128
 
142
129
  #### Exclusive site language generation
143
130
  _New in 1.4.0_
@@ -152,6 +139,11 @@ lang-exclusive: ['en', 'fr']
152
139
  ---
153
140
  ```
154
141
 
142
+ #### Machine-aware site building
143
+ _New in 1.5.0_
144
+
145
+ Polyglot will only start builds after it confirms there is a cpu core ready to accept the build thread. This ensures that jekyll will build large sites efficiently streamlining build processes instead of overloading machines with process thrash.
146
+
155
147
  #### Localized site.data
156
148
 
157
149
  There are cases when `site.data` localization is required.
@@ -159,7 +151,7 @@ For instance: you might need to localize `_data/navigation.yml` that holds "navi
159
151
  In order to localize it, just place language-specific files in `_data/:lang/...` folder, and Polyglot will bring those keys to the top level.
160
152
 
161
153
  ## How It Works
162
- This plugin makes modifications to existing Jekyll classes and modules, namely `Jekyll::StaticFile` and `Jekyll::Site`. These changes are as lightweight and slim as possible. The biggest change is in `Jekyll::Site.process`. Polyglot overwrites this method to instead spawn a separate thread for each language you intend to process the site for. Each of those threads calls the original `Jekyll::Site.process` method with its language in mind, ensuring your website scales to support any number of languages, while building all of your site languages simultaneously.
154
+ This plugin makes modifications to existing Jekyll classes and modules, namely `Jekyll::StaticFile` and `Jekyll::Site`. These changes are as lightweight and slim as possible. The biggest change is in `Jekyll::Site.process`. Polyglot overwrites this method to instead spawn a separate process for each language you intend to process the site for. Each of those processes calls the original `Jekyll::Site.process` method with its language in mind, ensuring your website scales to support any number of languages, while building all of your site languages simultaneously.
163
155
 
164
156
  `Jekyll::Site.process` is the entry point for the Jekyll build process. Take care whatever other plugins you use do not also attempt to overwrite this method. You may have problems.
165
157
 
@@ -171,7 +163,7 @@ This plugin stands out from other I18n Jekyll plugins.
171
163
  - provides the liquid tag `{{ site.default_lang }}` to get the default_lang I18n string.
172
164
  - 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`.
173
165
  - provides the liquid tag `{{ I18n_Headers https://yourwebsite.com/ }}` to append SEO bonuses to your website.
174
- - provides the liquid tag `{{ Unrelativized_Link href="/hello" }}` to make urls that do not get influenced by url correction regexs.
166
+ - provides the liquid tag `{{ Unrelativized_Link href="/hello" }}` to make urls that do not get influenced by url correction regexes.
175
167
  - provides `site.data` localization for efficient rich text replacement.
176
168
  - a creator that will answer all of your questions and issues.
177
169
 
@@ -179,13 +171,15 @@ This plugin stands out from other I18n Jekyll plugins.
179
171
  Jekyll-polyglot has a few spectacular [Search Engine Optimization techniques](https://untra.github.io/polyglot/seo) to ensure your Jekyll blog gets the most out of it's multilingual audience. Check them out!
180
172
 
181
173
  ### Other Websites Built with Polyglot
182
- let us know if you make a multilingual blog you want to share:
174
+ Feel free to open a PR and list your multilingual blog here you may want to share:
175
+
183
176
  * [Polyglot project website](https://polyglot.untra.io)
184
177
  * [LogRhythm Corporate Website](https://logrhythm.com)
185
178
  * [All Over Earth](https://allover.earth/)
186
179
  * [Hanare Cafe in Toshijima, Japan](https://hanarecafe.com)
187
180
  * [F-Droid](https://f-droid.org)
188
181
  * [Ubuntu MATE](https://ubuntu-mate.org)
182
+ * [Leo3418 blog](https://leo3418.github.io/)
189
183
 
190
184
  ## Compatibility
191
185
  Currently supports Jekyll 3.0 , and Jekyll 4.0
@@ -204,14 +198,16 @@ But for real I would appreciate any contributions and support. This started as a
204
198
  If you have something you'd like to contribute to jekyll-polyglot, please open a PR!
205
199
 
206
200
 
207
- ## Roadmap
201
+ ## 2.0 Roadmap
208
202
  * [ ] - **site language**: portuguese `pt_BR` `pt_PT`
209
203
  * [ ] - **site language**: arabic `ar`
210
204
  * [ ] - **site language**: japanese `ja`
211
205
  * [x] - **site language**: russian `ru`
206
+ * [x] - **site language**: dutch `nl`
212
207
  * [ ] - **site language**: korean `ko`
213
- * [ ] - **site language**: hebrew `he`
208
+ * [x] - **site language**: hebrew `he`
214
209
  * [ ] - get whitelisted as an official github-pages jekyll plugin
210
+ * [x] - update CI provider
215
211
 
216
212
  ## Copyright
217
- Copyright (c) Samuel Volin 2021. License: MIT
213
+ Copyright (c) Samuel Volin 2022. License: MIT
@@ -1,3 +1,5 @@
1
+ require 'etc'
2
+
1
3
  include Process
2
4
  module Jekyll
3
5
  class Site
@@ -31,22 +33,27 @@ module Jekyll
31
33
  prepare
32
34
  all_langs = (@languages + [@default_lang]).uniq
33
35
  if @parallel_localization
36
+ nproc = Etc.nprocessors
34
37
  pids = {}
35
- all_langs.each do |lang|
36
- pids[lang] = fork do
37
- process_language lang
38
+ begin
39
+ all_langs.each do |lang|
40
+ pids[lang] = fork do
41
+ process_language lang
42
+ end
43
+ while pids.length >= (lang == all_langs[-1] ? 1 : nproc)
44
+ sleep 0.1
45
+ pids.map do |lang, pid|
46
+ pids.delete lang if waitpid pid, Process::WNOHANG
47
+ end
48
+ end
38
49
  end
39
- end
40
- Signal.trap('INT') do
50
+ rescue Interrupt
41
51
  all_langs.each do |lang|
52
+ next unless pids.key? lang
42
53
  puts "Killing #{pids[lang]} : #{lang}"
43
54
  kill('INT', pids[lang])
44
55
  end
45
56
  end
46
- all_langs.each do |lang|
47
- waitpid pids[lang]
48
- detach pids[lang]
49
- end
50
57
  else
51
58
  all_langs.each do |lang|
52
59
  process_language lang
@@ -183,7 +190,7 @@ module Jekyll
183
190
  end
184
191
  end
185
192
  start = disabled ? 'ferh' : 'href'
186
- %r{#{start}=\"?#{@baseurl}\/((?:#{regex}[^,'\"\s\/?\.#]+\.?)*(?:\/[^\]\[\)\(\"\'\s]*)?)\"}
193
+ %r{#{start}=\"?#{@baseurl}\/((?:#{regex}[^,'\"\s\/?\.]+\.?)*(?:\/[^\]\[\)\(\"\'\s]*)?)\"}
187
194
  end
188
195
 
189
196
  # a regex that matches absolute urls in a html document
@@ -201,7 +208,7 @@ module Jekyll
201
208
  end
202
209
  end
203
210
  start = disabled ? 'ferh' : 'href'
204
- %r{(?<!hreflang="#{@default_lang}" )#{start}=\"?#{url}#{@baseurl}\/((?:#{regex}[^,'\"\s\/?\.#]+\.?)*(?:\/[^\]\[\)\(\"\'\s]*)?)\"}
211
+ %r{(?<!hreflang="#{@default_lang}" )#{start}=\"?#{url}#{@baseurl}\/((?:#{regex}[^,'\"\s\/?\.]+\.?)*(?:\/[^\]\[\)\(\"\'\s]*)?)\"}
205
212
  end
206
213
 
207
214
  def relativize_urls(doc, regex)
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.1
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Volin
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-18 00:00:00.000000000 Z
11
+ date: 2022-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -49,7 +49,7 @@ homepage: https://polyglot.untra.io/
49
49
  licenses:
50
50
  - MIT
51
51
  metadata: {}
52
- post_install_message:
52
+ post_install_message:
53
53
  rdoc_options: []
54
54
  require_paths:
55
55
  - lib
@@ -64,9 +64,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
64
  - !ruby/object:Gem::Version
65
65
  version: 2.7.0
66
66
  requirements: []
67
- rubyforge_project:
68
- rubygems_version: 2.7.6
69
- signing_key:
67
+ rubygems_version: 3.3.7
68
+ signing_key:
70
69
  specification_version: 4
71
70
  summary: I18n plugin for Jekyll Blogs
72
71
  test_files: []