jekyll-polyglot 1.2.2 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +26 -12
- data/lib/jekyll/polyglot/hooks/coordinate.rb +6 -1
- data/lib/jekyll/polyglot/hooks/process.rb +3 -1
- data/lib/jekyll/polyglot/liquid/tags/i18n-headers.rb +3 -2
- data/lib/jekyll/polyglot/patches/jekyll/site.rb +3 -1
- data/lib/jekyll/polyglot/version.rb +1 -1
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 526e59c26e6980628a9518162f6787e3b844d012
|
4
|
+
data.tar.gz: 526882c53b913ff61c2cb2722897a77bbb66c9fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0dc16249857ec6caf827301a61cfb73397ee33a45fab94697ec948da5196950eeb94161362a36caed5ecac667a6261c4a7b5dba7d5ebdd3988a31130c152a0af
|
7
|
+
data.tar.gz: 0f902861343803834c3c9b01aca95b9ed2969d77e076c7658de5755aa00879a147cfbf94c1f4e61fbf8c34c788418db77e22e287d80d212c551e0315cd54d164
|
data/README.md
CHANGED
@@ -9,15 +9,22 @@ __Polyglot__ is a fast, painless, open-source internationalization plugin for [J
|
|
9
9
|
Jekyll doesn't provide native support for multi-language blogs. This plugin was modeled after the [jekyll-multiple-languages-plugin](https://github.com/screeninteraction/jekyll-multiple-languages-plugin), whose implementation I liked, but execution I didn't.
|
10
10
|
|
11
11
|
## Installation
|
12
|
-
|
13
|
-
```
|
12
|
+
Add jekyll-polyglot to your `Gemfile` if you are using Bundler:
|
13
|
+
```Ruby
|
14
|
+
group :jekyll_plugins do
|
15
|
+
gem "jekyll-polyglot"
|
16
|
+
end
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install the gem manually by doing `gem install jekyll-polyglot` and specify the plugin using `_config.yml`:
|
20
|
+
```YAML
|
14
21
|
gems:
|
15
22
|
- jekyll-polyglot
|
16
23
|
```
|
17
24
|
|
18
25
|
## Configuration
|
19
26
|
In your `_config.yml` file, add the following preferences
|
20
|
-
```
|
27
|
+
```YAML
|
21
28
|
languages: ["en", "sv", "de", "fr"]
|
22
29
|
default_lang: "en"
|
23
30
|
exclude_from_localization: ["javascript", "images", "css"]
|
@@ -80,35 +87,42 @@ becomes
|
|
80
87
|
<p>Nous sommes un restaurant situé à Paris . <a href="/fr/menu/">Ceci est notre menu.</a></p>
|
81
88
|
</article>
|
82
89
|
```
|
83
|
-
|
90
|
+
Notice the link `<a href="/fr/menu/">...` directs to the french website.
|
84
91
|
|
85
92
|
Even if you are falling back to `default_lang` page, relative links built on the *french* site will
|
86
93
|
still link to *french* pages.
|
87
94
|
|
95
|
+
#### Localized site.data
|
96
|
+
|
97
|
+
There are cases when `site.data` localization is required.
|
98
|
+
For instance: you might need to localize `_data/navigation.yml` that holds "navigation menu".
|
99
|
+
In order to localize it, just place language-specific files in `_data/:lang/...` folder, and Polyglot will bring those keys to the top level.
|
100
|
+
|
88
101
|
## How It Works
|
89
|
-
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
|
102
|
+
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.
|
90
103
|
|
91
|
-
`Jekyll::Site.process` is the
|
104
|
+
`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.
|
92
105
|
|
93
106
|
## Features
|
94
107
|
This plugin stands out from other I18n Jekyll plugins.
|
95
|
-
- automatically corrects your relative links, keeping your *french*
|
108
|
+
- automatically corrects your relative links, keeping your *french* visitors on your *french* website, even when content has to fallback to the `default_lang`.
|
96
109
|
- builds all versions of your website *simultaneously*, allowing big websites to scale efficiently.
|
97
110
|
- provides the liquid tag `{{ site.languages }}` to get an array of your I18n strings.
|
98
111
|
- provides the liquid tag `{{ site.default_lang }}` to get the default_lang I18n string.
|
99
112
|
- provides the liquid tag `{{ site.active_lang }}` to get the I18n language string the website was built for.
|
100
113
|
- provides the liquid tag `{{ I18n_Headers https://yourwebsite.com/ }}` to append SEO bonuses to your website.
|
101
|
-
-
|
114
|
+
- provides `site.data` localization for efficient rich text replacement.
|
115
|
+
- a creator that will answer all of your questions and issues.
|
102
116
|
|
103
117
|
## SEO Recipes
|
104
|
-
Jekyll-polyglot has a few spectacular [Search Engine Optimization
|
118
|
+
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!
|
105
119
|
|
106
120
|
## Examples
|
107
121
|
Check out the example project website [here](https://untra.github.io/polyglot)
|
108
|
-
(Jekyll resources are on the project's [site](https://github.com/untra/polyglot/tree/site)
|
122
|
+
(Jekyll resources are on the project's [site](https://github.com/untra/polyglot/tree/master/site) directory)
|
109
123
|
|
110
124
|
### Other Websites Built with Polyglot
|
111
|
-
|
125
|
+
let us know if you make a multilingual blog you want to share:
|
112
126
|
* [LogRhythm Corporate Website](http://logrhythm.com)
|
113
127
|
|
114
128
|
## Compatibility
|
@@ -116,4 +130,4 @@ Currently supports Jekyll 3.0 .
|
|
116
130
|
Windows users will need to disable parallel_localization on their machines by setting `parallel_localization: false` in the `_config.yml`
|
117
131
|
|
118
132
|
## Copyright
|
119
|
-
Copyright (c) Samuel Volin
|
133
|
+
Copyright (c) Samuel Volin 2017. License: MIT
|
@@ -1,6 +1,11 @@
|
|
1
1
|
# hook to coordinate blog posts and pages into distinct urls,
|
2
2
|
# and remove duplicate multilanguage posts and pages
|
3
3
|
Jekyll::Hooks.register :site, :post_read do |site|
|
4
|
-
site.
|
4
|
+
if site.data.include?(site.active_lang)
|
5
|
+
site.data = site.data.merge(site.data[site.active_lang])
|
6
|
+
end
|
7
|
+
site.collections.each do |_, collection|
|
8
|
+
collection.docs = site.coordinate_documents(collection.docs)
|
9
|
+
end
|
5
10
|
site.pages = site.coordinate_documents(site.pages)
|
6
11
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# hook to make a call to process rendered documents,
|
2
2
|
Jekyll::Hooks.register :site, :post_render do |site|
|
3
|
-
site.
|
3
|
+
site.collections.each do |_, collection|
|
4
|
+
site.process_documents(collection.docs)
|
5
|
+
end
|
4
6
|
site.process_documents(site.pages)
|
5
7
|
end
|
@@ -12,13 +12,14 @@ module Jekyll
|
|
12
12
|
def render(context)
|
13
13
|
site = context.registers[:site]
|
14
14
|
permalink = context.registers[:page]['permalink']
|
15
|
+
siteUrl = (@url.empty?) ? site.config['url'] : @url
|
15
16
|
i18n = "<meta http-equiv=\"Content-Language\" content=\"#{site.active_lang}\">"
|
16
17
|
i18n += "<link rel=\"alternate\" i18n=\"#{site.default_lang}\""\
|
17
|
-
" href=\"#{
|
18
|
+
" href=\"#{siteUrl}#{permalink}\" />\n"
|
18
19
|
site.languages.each do |lang|
|
19
20
|
next if lang == site.default_lang
|
20
21
|
i18n += "<link rel=\"alternate\" i18n=\"#{lang}\""\
|
21
|
-
" href=\"#{
|
22
|
+
" href=\"#{siteUrl}/#{lang}#{permalink}\" />\n"
|
22
23
|
end
|
23
24
|
i18n
|
24
25
|
end
|
@@ -112,7 +112,9 @@ module Jekyll
|
|
112
112
|
@exclude.each do |x|
|
113
113
|
regex += "(?!#{x}\/)"
|
114
114
|
end
|
115
|
-
|
115
|
+
url_quoted = config['url']
|
116
|
+
url_quoted = Regexp.quote(url_quoted) unless url_quoted.nil?
|
117
|
+
%r{href=\"(?:#{url_quoted})?#{@baseurl}\/((?:#{regex}[^,'\"\s\/?\.#]+\.?)*(?:\/[^\]\[\)\(\"\'\s]*)?)\"}
|
116
118
|
end
|
117
119
|
|
118
120
|
def relativize_urls(doc)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-polyglot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Volin
|
@@ -14,20 +14,20 @@ dependencies:
|
|
14
14
|
name: jekyll
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '3.0'
|
20
|
-
- - ~>
|
20
|
+
- - "~>"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '3.1'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '3.0'
|
30
|
-
- - ~>
|
30
|
+
- - "~>"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '3.1'
|
33
33
|
description: Fast open source i18n plugin for Jekyll blogs.
|
@@ -60,17 +60,17 @@ require_paths:
|
|
60
60
|
- lib
|
61
61
|
required_ruby_version: !ruby/object:Gem::Requirement
|
62
62
|
requirements:
|
63
|
-
- -
|
63
|
+
- - ">="
|
64
64
|
- !ruby/object:Gem::Version
|
65
65
|
version: '0'
|
66
66
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
67
|
requirements:
|
68
|
-
- -
|
68
|
+
- - ">="
|
69
69
|
- !ruby/object:Gem::Version
|
70
70
|
version: '0'
|
71
71
|
requirements: []
|
72
72
|
rubyforge_project:
|
73
|
-
rubygems_version: 2.
|
73
|
+
rubygems_version: 2.5.2
|
74
74
|
signing_key:
|
75
75
|
specification_version: 4
|
76
76
|
summary: I18n plugin for Jekyll Blogs
|