jekyll-polyglot 1.8.0 → 1.9.0

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: 55de36ccc381edcf3d22e5f275b99ceb59a4e684bb528516157963c8ebb41cac
4
- data.tar.gz: 8bdcc86093ad1c3af1133a05e3993317dc7ced60e74f596acf6934d5a92b7792
3
+ metadata.gz: 58fab59c4c6aabba378edb4622f960b9ee2910c41e9b7cb329218cf4602bfaa2
4
+ data.tar.gz: 2a077894396baca9c8215a44abe6734abd9c1c00d0975259cf98380f77e72a10
5
5
  SHA512:
6
- metadata.gz: fb5bc80fda64369a25f465704993bc914af411ab8f285ee4bf5651ab7f7b036ff495426de44f4c3550aa75fd5d1b85cb21119389c031c36c44c6601daddc73b2
7
- data.tar.gz: c4f560e754305637589ae43c90d8dbf101ef3283761177db0be579ff3e1d3139e19f1c003d3b3b7f61b7b543a93598a41b1595ec3f6a2dbb7196c59b497e5c14
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
- 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
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/webstore/i18n)
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 https://yourwebsite.com/ }}` to append SEO bonuses to your website.
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,15 +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
 
294
- * [@jerturowetz](https://github.com/jerturowetz) 1.7.1
302
+ * [@yunseo-kim](https://github.com/yunseo-kim) [improved i18n sitemaps]((https://polyglot.untra.io/2025/01/18/polyglot-1.9.0/))
303
+ * [@blackpill](https://github.com/blackpill) [1.8.1](https://polyglot.untra.io/2024/08/18/polyglot-1.8.1/)
304
+ * [@hacketiwack](https://github.com/hacketiwack) [1.8.1](https://polyglot.untra.io/2024/08/18/polyglot-1.8.1/)
305
+ * [@jerturowetz](https://github.com/jerturowetz) [sitemap generation](https://polyglot.untra.io/2024/03/17/polyglot-1.8.0/)
295
306
  * [@antoniovazquezblanco](https://github.com/antoniovazquezblanco) [1.7.0](https://polyglot.untra.io/2023/10/29/polyglot-1.7.0/)
296
- * [@salinatedcoffee](https://github.com/SalinatedCoffee) [ko support](https://polyglot.untra.io/2023/02/27/korean-support/)
297
- * [@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/)
298
309
  * [@dougieh](https://github.com/dougieh) [1.5.1](https://polyglot.untra.io/2022/10/01/polyglot-1.5.1/)
299
- * [@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/)
300
311
  * [@obfusk](https://github.com/obfusk) [1.5.0](https://polyglot.untra.io/2021/07/17/polyglot-1.5.0/)
301
312
  * [@eighthave](https://github.com/eighthave) [1.5.0](https://polyglot.untra.io/2021/07/17/polyglot-1.5.0/)
302
- * [@george-gca](https://github.com/george-gca) [Localized Variables](https://polyglot.untra.io/2024/02/29/localized-variables.md)
313
+ * [@george-gca](https://github.com/george-gca) [pt-BR support](https://polyglot.untra.io/pt-BR/2024/02/29/localized-variables.md)
303
314
 
304
315
  ### Other Websites Built with Polyglot
305
316
  Feel free to open a PR and list your multilingual blog here you may want to share:
@@ -315,6 +326,9 @@ Feel free to open a PR and list your multilingual blog here you may want to shar
315
326
  * [Yi Yunseok's personal blog website](https://Yi-Yunseok.GitHub.io)
316
327
  * [Tarlogic Cybersecurity](https://www.tarlogic.com/)
317
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/)
318
332
 
319
333
  ## 2.0 Roadmap
320
334
  * [x] - **site language**: portuguese Brazil `pt-BR`
@@ -331,4 +345,4 @@ Feel free to open a PR and list your multilingual blog here you may want to shar
331
345
  * [x] - update CI provider
332
346
 
333
347
  ## Copyright
334
- Copyright (c) Samuel Volin 2023. License: MIT
348
+ Copyright (c) Samuel Volin 2025. License: MIT
@@ -16,7 +16,7 @@ module Jekyll
16
16
  site_url = @url.empty? ? site.config['url'] : @url
17
17
  i18n = "<meta http-equiv=\"Content-Language\" content=\"#{site.active_lang}\">\n"
18
18
  i18n += "<link rel=\"alternate\" hreflang=\"#{site.default_lang}\" "\
19
- "href=\"#{site_url}#{permalink}\"/>\n"
19
+ "href=\"#{site_url}/#{permalink}\"/>\n"
20
20
  site.languages.each do |lang|
21
21
  next if lang == site.default_lang
22
22
 
@@ -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.relative_path.split('/')
117
- if doc.relative_path[0] == '_' \
118
- && segments.length > 2 \
119
- && segments[1] =~ /^[a-z]{2,3}(:?[_-](:?[A-Za-z]{2}){1,2}){0,2}$/
120
- return segments[1]
121
- elsif segments.length > 1 \
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
 
@@ -138,7 +149,7 @@ module Jekyll
138
149
  lang_exclusive = doc.data['lang-exclusive'] || []
139
150
  url = doc.url.gsub(regex, '/')
140
151
  page_id = doc.data['page_id'] || url
141
- doc.data['permalink'] = url unless defined?(doc.data['permalink'])
152
+ doc.data['permalink'] = url if doc.data['permalink'].to_s.empty? && !doc.data['lang'].to_s.empty?
142
153
 
143
154
  # skip entirely if nothing to check
144
155
  next if @file_langs.nil?
@@ -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
 
@@ -185,7 +196,7 @@ module Jekyll
185
196
  end
186
197
  end
187
198
 
188
- # performs any necesarry operations on the documents before rendering them
199
+ # performs any necessary operations on the documents before rendering them
189
200
  def process_documents(docs)
190
201
  # return if @active_lang == @default_lang
191
202
 
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.8.0
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: 2024-03-17 00:00:00.000000000 Z
11
+ date: 2025-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -63,7 +63,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
63
63
  requirements:
64
64
  - - ">="
65
65
  - !ruby/object:Gem::Version
66
- version: 2.4.0
66
+ version: 2.7.0
67
67
  required_rubygems_version: !ruby/object:Gem::Requirement
68
68
  requirements:
69
69
  - - ">="