jekyll-locales 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +19 -0
- data/lib/jekyll/locales.rb +1 -0
- data/lib/jekyll/locales/hooks/page_post_init.rb +7 -0
- data/lib/jekyll/locales/site.rb +13 -10
- data/lib/jekyll/locales/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 764336f02b1a0f2d7875de245b0ee0079f4e8bb98f312b5922acd843c06cd027
|
4
|
+
data.tar.gz: 8df9900565b574eb1d6782375713c5b9d29bf7369bd21d3b88cc70547311f1a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f96129ee3b801fe9a5552501bd3a7df7ee1328df62cb4e70e59b3579599de75e842466e3bbb7de62586afafc259883d812b95e312d97262b700501a8c4c135d
|
7
|
+
data.tar.gz: 277f7ed8ec305865cc5299e766a19d849e3dbb2f39c2ffec6737bcace7b04174f62876503c383cac994929c89949d04a02e6564561f5ee397b7e181231e52130
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -61,6 +61,25 @@ locales:
|
|
61
61
|
|
62
62
|
Then you can access them by using `page.locales` in your layout.
|
63
63
|
|
64
|
+
### Pages
|
65
|
+
|
66
|
+
You can translate the front matter by adding locale-specific variables
|
67
|
+
in it:
|
68
|
+
|
69
|
+
```yaml
|
70
|
+
---
|
71
|
+
layout: page
|
72
|
+
title: Default title
|
73
|
+
locales:
|
74
|
+
es:
|
75
|
+
title: Título en castellano
|
76
|
+
permalink: pagina/
|
77
|
+
en:
|
78
|
+
title: English title
|
79
|
+
permalink: page/
|
80
|
+
---
|
81
|
+
```
|
82
|
+
|
64
83
|
### Themes
|
65
84
|
|
66
85
|
To translate your theme, put the string into `_data/LANGUAGE.yml` files,
|
data/lib/jekyll/locales.rb
CHANGED
data/lib/jekyll/locales/site.rb
CHANGED
@@ -9,20 +9,24 @@ module Jekyll
|
|
9
9
|
# * The plugin generates a copy of the site for every language at
|
10
10
|
# _site/LANGUAGE
|
11
11
|
class Site
|
12
|
+
attr_reader :locale
|
13
|
+
|
12
14
|
# We don't monkey patch because the Site is already instantiated
|
13
15
|
alias process_single process
|
14
16
|
|
15
17
|
# Process the site once per available locale
|
16
18
|
def process
|
17
19
|
locales.each do |locale|
|
20
|
+
@locale = locale
|
21
|
+
|
18
22
|
Jekyll.logger.info 'Generating locale:', locale
|
19
23
|
|
20
|
-
|
24
|
+
locale_config
|
21
25
|
|
22
26
|
Jekyll.logger.info 'Destination:', config['destination']
|
23
27
|
Jekyll.logger.info 'Base URL:', config['baseurl']
|
24
28
|
|
25
|
-
|
29
|
+
symlink
|
26
30
|
process_single
|
27
31
|
copy_redirector
|
28
32
|
end
|
@@ -33,9 +37,9 @@ module Jekyll
|
|
33
37
|
|
34
38
|
private
|
35
39
|
|
36
|
-
def
|
37
|
-
@dest = config['destination'] =
|
38
|
-
config['baseurl'] =
|
40
|
+
def locale_config
|
41
|
+
@dest = config['destination'] = locale_destination
|
42
|
+
config['baseurl'] = locale_baseurl
|
39
43
|
|
40
44
|
# XXX: Retrocompatibility
|
41
45
|
config['locale'] = config['lang'] = locale
|
@@ -61,27 +65,26 @@ module Jekyll
|
|
61
65
|
end
|
62
66
|
|
63
67
|
# Add locale to the site destination
|
64
|
-
def
|
68
|
+
def locale_destination
|
65
69
|
File.join(root_destination, locale)
|
66
70
|
end
|
67
71
|
|
68
72
|
# If the site has a baseurl, we add the locale to it. But we add
|
69
73
|
# it anyway so relative URLs include the locale
|
70
|
-
def
|
74
|
+
def locale_baseurl
|
71
75
|
[orig_baseurl, locale].join('/')
|
72
76
|
end
|
73
77
|
|
74
78
|
# Creates a symlink to the _posts/ directory so Jekyll believes
|
75
79
|
# it's processing a single site.
|
76
|
-
def
|
80
|
+
def symlink
|
77
81
|
FileUtils.rm_f('_posts')
|
78
82
|
FileUtils.ln_s("_#{locale}", '_posts')
|
79
83
|
end
|
80
84
|
|
81
85
|
# TODO: Make configurable
|
82
86
|
def redirector
|
83
|
-
@redirector ||= File.join(
|
84
|
-
'redirector.html')
|
87
|
+
@redirector ||= File.join(locale_destination, 'redirector.html')
|
85
88
|
end
|
86
89
|
|
87
90
|
def redirector_to_index(redir)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-locales
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- f
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-10-
|
11
|
+
date: 2019-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- jekyll-locales.gemspec
|
91
91
|
- lib/jekyll-locales.rb
|
92
92
|
- lib/jekyll/locales.rb
|
93
|
+
- lib/jekyll/locales/hooks/page_post_init.rb
|
93
94
|
- lib/jekyll/locales/site.rb
|
94
95
|
- lib/jekyll/locales/version.rb
|
95
96
|
homepage: https://0xacab.org/sutty/jekyll/jekyll-locales
|