jekyll_i18n_multi_page 0.2.2 → 0.3.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: 7ab7353b6670825d24f8fd26c49762132c22ad3af093a945bf21f96655f1b9d3
4
- data.tar.gz: 583fb4f7a2e54b329e6d4f51d6cdbd4e90f43904c9bc45fa2a0b09f2bb5db105
3
+ metadata.gz: e93428ccd6df5984bf99cffe1b8a2b1a9c8be3abe3176d0d63d330809efc49bc
4
+ data.tar.gz: 538d278cdc58a8e399a61dce7ec145985bafb80c61ff40babed5fb4f706ec866
5
5
  SHA512:
6
- metadata.gz: dd22ccc6d154a3d231fe2aec8f66a2b07f38bc4dacd575b1abbb4ff518e23dc6ab5a5cb0aa5f7b8203929555ce63b5a20012523e3341b2e182d56d8a67f58dfe
7
- data.tar.gz: 702610d0058f4c2217e80e2a460e8bcf30ff2f7441104f3768d51768f81daee8d95e91c321a8c42d3ea29bc1d6e70948e9e30475a5bea4f1d90ed821ea1cc942
6
+ metadata.gz: de0b544924288a1b5d91f9764595c3be72ace2ba5aa029d85a13e6fff65eb7ae1808af549858307956d1a0cbd2ab8e30f3d8b7e6f1384582909553ca07fd97d2
7
+ data.tar.gz: d1cd0f9153c97e63de4be043043f81e84f6c0f6e7af7b47f114e6adcf9a7b4f75760c5442e157ec42f098eb5c59eaf3fe938ee74f7eeecf080cb07a5dd7abd35
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jekyll_i18n_multi_page (0.2.2)
4
+ jekyll_i18n_multi_page (0.3.0)
5
5
  activesupport (~> 6.0)
6
6
  i18n
7
7
  jekyll (>= 3.0)
@@ -15,8 +15,8 @@ GEM
15
15
  minitest (~> 5.1)
16
16
  tzinfo (~> 1.1)
17
17
  zeitwerk (~> 2.1, >= 2.1.8)
18
- addressable (2.6.0)
19
- public_suffix (>= 2.0.2, < 4.0)
18
+ addressable (2.7.0)
19
+ public_suffix (>= 2.0.2, < 5.0)
20
20
  appraisal (2.2.0)
21
21
  bundler
22
22
  rake
@@ -33,7 +33,7 @@ GEM
33
33
  ffi (1.11.1)
34
34
  forwardable-extended (2.6.0)
35
35
  http_parser.rb (0.6.0)
36
- i18n (1.6.0)
36
+ i18n (1.7.0)
37
37
  concurrent-ruby (~> 1.0)
38
38
  jekyll (4.0.0)
39
39
  addressable (~> 2.4)
@@ -50,7 +50,7 @@ GEM
50
50
  rouge (~> 3.0)
51
51
  safe_yaml (~> 1.0)
52
52
  terminal-table (~> 1.8)
53
- jekyll-sass-converter (2.0.0)
53
+ jekyll-sass-converter (2.0.1)
54
54
  sassc (> 2.0.1, < 3.0)
55
55
  jekyll-watch (2.2.1)
56
56
  listen (~> 3.0)
@@ -59,24 +59,23 @@ GEM
59
59
  kramdown-parser-gfm (1.1.0)
60
60
  kramdown (~> 2.0)
61
61
  liquid (4.0.3)
62
- listen (3.1.5)
63
- rb-fsevent (~> 0.9, >= 0.9.4)
64
- rb-inotify (~> 0.9, >= 0.9.7)
65
- ruby_dep (~> 1.2)
62
+ listen (3.2.0)
63
+ rb-fsevent (~> 0.10, >= 0.10.3)
64
+ rb-inotify (~> 0.9, >= 0.9.10)
66
65
  mercenary (0.3.6)
67
66
  method_source (0.9.2)
68
- minitest (5.11.3)
67
+ minitest (5.12.2)
69
68
  pathutil (0.16.2)
70
69
  forwardable-extended (~> 2.6)
71
70
  pry (0.12.2)
72
71
  coderay (~> 1.1.0)
73
72
  method_source (~> 0.9.0)
74
- public_suffix (3.1.1)
73
+ public_suffix (4.0.1)
75
74
  rake (10.5.0)
76
75
  rb-fsevent (0.10.3)
77
76
  rb-inotify (0.10.0)
78
77
  ffi (~> 1.0)
79
- rouge (3.9.0)
78
+ rouge (3.12.0)
80
79
  rspec (3.8.0)
81
80
  rspec-core (~> 3.8.0)
82
81
  rspec-expectations (~> 3.8.0)
@@ -90,9 +89,8 @@ GEM
90
89
  diff-lcs (>= 1.2.0, < 2.0)
91
90
  rspec-support (~> 3.8.0)
92
91
  rspec-support (3.8.2)
93
- ruby_dep (1.5.0)
94
92
  safe_yaml (1.0.5)
95
- sassc (2.1.0)
93
+ sassc (2.2.1)
96
94
  ffi (~> 1.9)
97
95
  simplecov (0.17.0)
98
96
  docile (~> 1.1)
@@ -106,7 +104,7 @@ GEM
106
104
  tzinfo (1.2.5)
107
105
  thread_safe (~> 0.1)
108
106
  unicode-display_width (1.6.0)
109
- zeitwerk (2.1.9)
107
+ zeitwerk (2.2.0)
110
108
 
111
109
  PLATFORMS
112
110
  ruby
data/README.md CHANGED
@@ -28,7 +28,7 @@ plugins:
28
28
 
29
29
  ## Usage
30
30
 
31
- Declare available locales in your website in `_config.yml`:
31
+ Declare available locales in Jekyll config `_config.yml`:
32
32
 
33
33
  ```yml
34
34
  i18n:
@@ -58,16 +58,19 @@ zh-TW:
58
58
  hello: 哈囉
59
59
  ```
60
60
 
61
- `page.i18n` is the way to access the current localized contents, said you have a HTML named `index.html` with content as the following:
61
+ `page.i18n` is the way to access the current localized contents, said you have a HTML named `index.html`:
62
+
62
63
  ```html
63
64
  ---
64
65
  ---
66
+ {{ page.i18n.title }}
65
67
  {{ page.i18n.hello }}
66
68
  ```
67
69
 
68
- After building of Jekyll, the dist folder should have two files `index.html` and `tw/index.html`
70
+ After building, the dist folder should have two files `index.html` and `tw/index.html`.
69
71
 
70
72
  Assume you have a file named `some/where/my.html` you should have its path in the localization file:
73
+
71
74
  ```yml
72
75
  # _i18n/my-en-site.yml
73
76
  en:
@@ -87,7 +90,7 @@ i18n_locales: ['zh-TW']
87
90
  ---
88
91
  {{ page.i18n.hello }}
89
92
  ```
90
- Using `i18n_locales` to declare the support locales. Then Jekyll will build `tw/index.html` file only.
93
+ Using `i18n_locales` to declare the supported locales. In this example, Jekyll will build `tw/index.html` file only.
91
94
 
92
95
  **How to disable the features on certain pages**
93
96
 
@@ -98,6 +101,16 @@ i18n_disabled: true
98
101
  ```
99
102
  Using `i18n_disabled` to tell the plugin do not do anything for me.
100
103
 
104
+ **Show/Hide something for certain locales**
105
+
106
+ ```html
107
+ ---
108
+ ---
109
+ {% if page.i18n_locale == 'en' %}
110
+ You will see me only in the en page.
111
+ {% end %}
112
+ ```
113
+
101
114
  **Translate helper**
102
115
 
103
116
  ```
@@ -105,6 +118,19 @@ Using `i18n_disabled` to tell the plugin do not do anything for me.
105
118
  ```
106
119
  `t` tag provides a way to translate content. When you take this way, you must write a full path.
107
120
 
121
+ **i18n Filter**
122
+
123
+ the filter is useful for forlooop in the case of page.i18n being unavailable. For example:
124
+
125
+ ```
126
+ ---
127
+ i18n_disabled: true
128
+ i18n_locale: zh-TW
129
+ ---
130
+ {% t my.array %} <!-- the result from tags can not be reused like variable. -->
131
+ {% assign items = 'my.array' | i18n %}
132
+ ```
133
+
108
134
  ## Contributing
109
135
 
110
136
  Bug reports and pull requests are welcome on GitHub at https://github.com/yfxie/jekyll_i18n_multi_page.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- jekyll_i18n_multi_page (0.2.1)
4
+ jekyll_i18n_multi_page (0.3.0)
5
5
  activesupport (~> 6.0)
6
6
  i18n
7
7
  jekyll (>= 3.0)
@@ -61,7 +61,7 @@ GEM
61
61
  ruby_dep (~> 1.2)
62
62
  mercenary (0.3.6)
63
63
  method_source (0.9.2)
64
- minitest (5.11.3)
64
+ minitest (5.12.2)
65
65
  pathutil (0.16.2)
66
66
  forwardable-extended (~> 2.6)
67
67
  pry (0.12.2)
@@ -102,7 +102,7 @@ GEM
102
102
  thread_safe (0.3.6)
103
103
  tzinfo (1.2.5)
104
104
  thread_safe (~> 0.1)
105
- zeitwerk (2.1.9)
105
+ zeitwerk (2.2.0)
106
106
 
107
107
  PLATFORMS
108
108
  ruby
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- jekyll_i18n_multi_page (0.2.1)
4
+ jekyll_i18n_multi_page (0.3.0)
5
5
  activesupport (~> 6.0)
6
6
  i18n
7
7
  jekyll (>= 3.0)
@@ -65,7 +65,7 @@ GEM
65
65
  ruby_dep (~> 1.2)
66
66
  mercenary (0.3.6)
67
67
  method_source (0.9.2)
68
- minitest (5.11.3)
68
+ minitest (5.12.2)
69
69
  pathutil (0.16.2)
70
70
  forwardable-extended (~> 2.6)
71
71
  pry (0.12.2)
@@ -106,7 +106,7 @@ GEM
106
106
  tzinfo (1.2.5)
107
107
  thread_safe (~> 0.1)
108
108
  unicode-display_width (1.6.0)
109
- zeitwerk (2.1.9)
109
+ zeitwerk (2.2.0)
110
110
 
111
111
  PLATFORMS
112
112
  ruby
@@ -4,6 +4,7 @@ require 'active_support/core_ext/hash'
4
4
  require 'jekyll_i18n_multi_page/version'
5
5
  require 'jekyll_i18n_multi_page/page_extension'
6
6
  require 'jekyll_i18n_multi_page/translate_tag'
7
+ require 'jekyll_i18n_multi_page/filters'
7
8
 
8
9
  module JekyllI18nMultiPage; end
9
10
 
@@ -46,4 +47,5 @@ Jekyll::Hooks.register :site, :post_read do |site|
46
47
  end
47
48
  end
48
49
 
49
- Liquid::Template.register_tag('t', JekyllI18nMultiPage::TranslateTag)
50
+ Liquid::Template.register_tag('t', JekyllI18nMultiPage::TranslateTag)
51
+ Liquid::Template.register_filter(JekyllI18nMultiPage::Filters)
@@ -0,0 +1,8 @@
1
+ module JekyllI18nMultiPage
2
+ module Filters
3
+ def i18n(path)
4
+ I18n.t(path, locale: @context['page']['i18n_locale'])
5
+ end
6
+ end
7
+ end
8
+
@@ -1,3 +1,3 @@
1
1
  module JekyllI18nMultiPage
2
- VERSION = "0.2.2"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll_i18n_multi_page
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yi Feng
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-24 00:00:00.000000000 Z
11
+ date: 2019-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -159,6 +159,7 @@ files:
159
159
  - gemfiles/jekyll_4.gemfile.lock
160
160
  - jekyll_i18n_multi_page.gemspec
161
161
  - lib/jekyll_i18n_multi_page.rb
162
+ - lib/jekyll_i18n_multi_page/filters.rb
162
163
  - lib/jekyll_i18n_multi_page/page_extension.rb
163
164
  - lib/jekyll_i18n_multi_page/translate_tag.rb
164
165
  - lib/jekyll_i18n_multi_page/version.rb