jekyll_i18n_multi_page 0.3.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cc15195366f3e13dff04ccd852c7eeccc3b74a336cb2ddb72123ae5eabdee393
4
- data.tar.gz: cf8ce3341b846ab30b32bc0ef770f151f5034f55b746af7f6698dca2629377b2
3
+ metadata.gz: 5c79225623ed064544bc010b460ee08e667144283fef20cc2cd00c86697b0e50
4
+ data.tar.gz: 3a5dfc7706ecc2419cac3b769c66e444af65f541f9044993e941575e8aee75aa
5
5
  SHA512:
6
- metadata.gz: 9a3b637ee575ceb7957e1e4d5ac9bbdf1356ea5383de01507a0a2f17c26229de035e2fcf6ca47f1baeaef4f6e6dd84d96d6c3612255198d5f7dd9c92a19aa54c
7
- data.tar.gz: e0126cc13b5dc2a8899779dd0ba028ec66307d127156bbf8fbbbc5bf76257be7f2a3a639072d44ef693f1657fa8a1722d00f9052d680739237d2bd07d20b415c
6
+ metadata.gz: 2e3f036128eff2eda001bab2788c17c5618f5ec0138cf87297248fb69841c8a43422cf50cb1ee84f75ac0b180e6369bbc1c06adc9f99ca719d6f41c0e7956bed
7
+ data.tar.gz: 937ad4b530fb5a29b7b35a7d3721f53d248147205121611ec2b91a65a1e8af3c7e2b1256fa85ad0b65a6c2f658b6fc826a98fb844e78651de454fdbfd5e749d9
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jekyll_i18n_multi_page (0.3.1)
4
+ jekyll_i18n_multi_page (0.4.0)
5
5
  activesupport (~> 6.0)
6
6
  i18n
7
7
  jekyll (>= 3.0)
@@ -64,7 +64,7 @@ GEM
64
64
  rb-inotify (~> 0.9, >= 0.9.10)
65
65
  mercenary (0.3.6)
66
66
  method_source (0.9.2)
67
- minitest (5.12.2)
67
+ minitest (5.13.0)
68
68
  pathutil (0.16.2)
69
69
  forwardable-extended (~> 2.6)
70
70
  pry (0.12.2)
@@ -104,7 +104,7 @@ GEM
104
104
  tzinfo (1.2.5)
105
105
  thread_safe (~> 0.1)
106
106
  unicode-display_width (1.6.0)
107
- zeitwerk (2.2.0)
107
+ zeitwerk (2.2.1)
108
108
 
109
109
  PLATFORMS
110
110
  ruby
data/README.md CHANGED
@@ -118,17 +118,19 @@ You will see me only in the en page.
118
118
  ```
119
119
  `t` tag provides a way to translate content. When you take this way, you must write a full path.
120
120
 
121
- **i18n Filter**
121
+ **i18n global variable**
122
122
 
123
- the filter is useful for forlooop in the case of page.i18n being unavailable. For example:
123
+ `i18n` is a global variable provides you a way to access the root of localization.
124
124
 
125
125
  ```
126
126
  ---
127
127
  i18n_disabled: true
128
128
  i18n_locale: zh-TW
129
129
  ---
130
- {% t my.array %} <!-- the result from tags can not be reused like variable. -->
131
- {% assign items = 'my.array' | i18n %}
130
+ {{ i18n.some.page.title }}
131
+ {% for item in i18n.some.array %}
132
+ ...
133
+ {% endfor %}
132
134
  ```
133
135
 
134
136
  ## Contributing
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- jekyll_i18n_multi_page (0.3.1)
4
+ jekyll_i18n_multi_page (0.4.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.12.2)
64
+ minitest (5.13.0)
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.2.0)
105
+ zeitwerk (2.2.1)
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.3.1)
4
+ jekyll_i18n_multi_page (0.4.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.12.2)
68
+ minitest (5.13.0)
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.2.0)
109
+ zeitwerk (2.2.1)
110
110
 
111
111
  PLATFORMS
112
112
  ruby
@@ -4,7 +4,6 @@ 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'
8
7
 
9
8
  module JekyllI18nMultiPage; end
10
9
 
@@ -13,10 +12,18 @@ Jekyll::Page.class_eval do
13
12
  prepend JekyllI18nMultiPage::PageExtension
14
13
  end
15
14
 
15
+
16
16
  Jekyll::Hooks.register :site, :after_init do |site|
17
17
  I18n.load_path << Dir[File.join(site.config['source'], '_i18n', '**/*.{yml,yaml}')]
18
18
  end
19
19
 
20
+ Jekyll::Hooks.register :pages, :pre_render do |page, payload|
21
+ if page.i18n_locale
22
+ result = I18n.t('.', locale: page.i18n_locale)
23
+ payload['i18n'] = { result: result }.with_indifferent_access[:result]
24
+ end
25
+ end
26
+
20
27
  Jekyll::Hooks.register :site, :post_read do |site|
21
28
  config = site.config['i18n']
22
29
  return unless config
@@ -47,5 +54,4 @@ Jekyll::Hooks.register :site, :post_read do |site|
47
54
  end
48
55
  end
49
56
 
50
- Liquid::Template.register_tag('t', JekyllI18nMultiPage::TranslateTag)
51
- Liquid::Template.register_filter(JekyllI18nMultiPage::Filters)
57
+ Liquid::Template.register_tag('t', JekyllI18nMultiPage::TranslateTag)
@@ -9,6 +9,10 @@ module JekyllI18nMultiPage
9
9
  data['i18n_disabled']
10
10
  end
11
11
 
12
+ def i18n_locale
13
+ data['i18n_locale']
14
+ end
15
+
12
16
  def template
13
17
  return super if i18n_disabled
14
18
  "/:i18n_path#{super}"
@@ -1,3 +1,3 @@
1
1
  module JekyllI18nMultiPage
2
- VERSION = "0.3.1"
2
+ VERSION = "0.4.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.3.1
4
+ version: 0.4.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-10-29 00:00:00.000000000 Z
11
+ date: 2019-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -159,7 +159,6 @@ 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
163
162
  - lib/jekyll_i18n_multi_page/page_extension.rb
164
163
  - lib/jekyll_i18n_multi_page/translate_tag.rb
165
164
  - lib/jekyll_i18n_multi_page/version.rb
@@ -1,9 +0,0 @@
1
- module JekyllI18nMultiPage
2
- module Filters
3
- def i18n(path)
4
- result = I18n.t(path, locale: @context['page']['i18n_locale'])
5
- { result: result }.with_indifferent_access[:result]
6
- end
7
- end
8
- end
9
-