jekyll-locale 0.2.0 → 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
  SHA1:
3
- metadata.gz: 95f578476bc1531c27696fd1218bc914ec176686
4
- data.tar.gz: e3723615a5e94829370795bcc51a4d70c27b20db
3
+ metadata.gz: d4e9bb6b38af90f2abe329414e61479a0afb06bb
4
+ data.tar.gz: 531866e46d63671cafc32c233f64ec263bfb3744
5
5
  SHA512:
6
- metadata.gz: 8cd1ed64b59d8f5f8f308abba21bc6d1cbf29ed54f79d317dcd6741d1b73c37ebed95a12e2349c0bf65e5d3531394fcefb83c6a0edde6c40dac85e606a93080b
7
- data.tar.gz: d37d608b72baff43775909273f1ebe3cf73452d1dcac35baa7bf168174d379fccc8fa4cd4d5266260a654cbb14e9292acad2f854a440c1b320c43f661b96ed79
6
+ metadata.gz: c817b57303dd42dca2f76aa8f7bc7e5349c63879afbb2382268ecc91da1fe199f0135fd0d468d2d35a769a29a7dd6c8bb2eb77eb8383a5fd4b1467fac670f789
7
+ data.tar.gz: bb6c4a7712ce0d12e130231179b49a813f4e7fdd37ceff9d298f6d5799330b9f35549c0cd2c856562148b19a2a32f0f50fe665c775cd06b90786f4e0cbeef60e
data/README.md CHANGED
@@ -5,28 +5,94 @@ A localization plugin for Jekyll.
5
5
 
6
6
  ## Features
7
7
 
8
- * Exposes a `{{ locale }}` object for your Liquid templates. The *payload* for this object is derived from data files and
9
- has been *preconfigured* with the following:
8
+ * Exposes a `{{ locale }}` object for your Liquid templates that can be used to "translate" strings in your site easily.
9
+ * Depending on configured `mode`, the plugin either generates a *copy* of every page that renders into a HTML file, and
10
+ every document set to be written, and renders them into dedicated urls prepended by a supported locale, or, the plugin
11
+ "processes" only those files placed inside the plugin's configured **`content_dir`** .
10
12
 
11
- ```yaml
12
- locale : en # Sets the 'default locale' for the site
13
- locales_dir : locales # Sets the base location for translation data, within your configured `data_dir`.
14
- # Therefore, this setting implies that the plugin looks for translation data in
15
- # either `_data/locales/` or a data file named `locales`. e.g. `_data/locales.yml`.
16
- ```
17
- Ergo, `{{ locale }}` is simply a *syntactic sugar* for the construct `{{ site.data[site.locales_dir][site.locale] }}`.
18
- * Generates a *copy* of every page that renders into a HTML file, and every document set to be written, and renders
19
- them into dedicated urls prepended by a supported locale.
20
- For example, if one were to configure the plugin with `available_locales: ["de", "fr", "en", "es"]`, then a file
21
- named `about.md` with custom permalink set to `/about/` will result in the following files:
22
- * `_site/about/index.html`
23
- * `_site/de/about/index.html`
24
- * `_site/es/about/index.html`
25
- * `_site/fr/about/index.html`
13
+
14
+ ## Configuration
15
+
16
+ The plugin has been *preconfigured* with the following:
17
+
18
+ ```yaml
19
+ localization:
20
+ mode : manual # Sets the 'handler mode'
21
+ locale : en-US # Sets the 'default locale' for the site
22
+ data_dir : locales # Sets the base location for *translation data*, within your *site's `data_dir`*.
23
+ content_dir: _locales # Sets the base location for placing files to be re-rendered. Ignored in "auto mode".
24
+ locales_set: [] # A list of locales the site will re-render files into
25
+ exclude_set: [] # A list of file paths the site will not re-render in "auto" mode.
26
+ ```
27
+
28
+ ### `data_dir`
29
+
30
+ This setting defines the base location for *the translation data*, within your site's configured `data_dir`. The value
31
+ defaults to `"locales"`. This implies that the plugin looks for "translation data" in either `_data/locales/` or a data
32
+ file named `locales`. e.g. `_data/locales.yml` or `_data/locales.json`, etc.
33
+
34
+ Irrespective of the format, the data should be a Hash table / dictionary of key-value pairs where the main key should
35
+ correspond to locale defined in the `locales_set` array or the default locale `en-US`, and the subkeys set to string
36
+ values.
37
+
38
+ ### `content_dir`
39
+
40
+ Ignored in "auto mode", this setting defines the base location for placing "the physical copies" of the canonical pages
41
+ and documents. Refer `mode` sub-section below for further details.
42
+
43
+ The default setting is `_locales`
44
+
45
+ ### `locales_set`
46
+
47
+ Empty by default, this setting defines what locales to be used when "localizing" a site. Listing a locale (other than
48
+ the default locale) will cause the entire site to render for that locale and the default locale while in "auto mode".
49
+
50
+ ### `locale`
51
+
52
+ Set to `en-US` by default, this setting defines the default locale of the site and will not be prepended to the URL of
53
+ the generated files.
54
+
55
+ ### `exclude_set`
56
+
57
+ Empty by default, this setting defines what files to be *excluded* from being duplicated and re-rendered in the "auto"
58
+ mode. Ignored in "manual" mode.
59
+
60
+ ### `mode`
61
+
62
+ This setting defines the plugin's operation strategy.
63
+
64
+ When set to **`auto`**, the plugin will initialize a generator that will simply duplicate *every page and document set
65
+ to be written to destination*, and re-render them into destination, for every locale listed in the `locales_set:`
66
+ array.
67
+
68
+ This mode will increase your build times in proportion to the total number pages, writable-documents and locales listed
69
+ but will result in simply the same canonical output and the canonical url prepended with an iterated locale.
70
+
71
+ For example, if one were to configure the plugin with `locales_set: ["de", "fr", "en-US", "es"]`, then a file named
72
+ `about.md` will result in the following files:
73
+ * `_site/about.html`
74
+ * `_site/de/about.html`
75
+ * `_site/es/about.html`
76
+ * `_site/fr/about.html`
77
+
78
+ Setting `mode` to any other value will automatically default to `"manual"` which **requires** you to create physical
79
+ files in a special directory (as configured under `localization["content_dir"]`) to render localized copies. The
80
+ salient features of this mode are:
81
+ * The physical files are handled like any other file in the site, but, they **should partially mirror** their
82
+ counterpart — **their relative_paths should match**. Additionally, if an original file contains front matter,
83
+ the physical copy should contain front matter as well.
84
+ * The physical files should reside inside sub-folders that match the desired locale. For example, to "localize" a post
85
+ at path `movies/_posts/2018-09-24-hello.markdown` with locale `fr`, you should create the physical copy at path
86
+ `_locales/fr/movies/_posts/2018-09-24-hello.markdown`.
87
+ * Physical copies can render different content and into a different layout, if desired.
88
+ * Physical copies of posts and other writable *documents* can be rendered to a different `slug` by defining the `slug`
89
+ key in the front matter.
26
90
 
27
91
 
28
92
  ## Usage
29
93
 
94
+ ### Auto Mode
95
+
30
96
  1. Add plugin to the `:jekyll_plugins` group in your Gemfile:
31
97
 
32
98
  ```ruby
@@ -37,22 +103,27 @@ A localization plugin for Jekyll.
37
103
 
38
104
  2. Decide what the default locale for your site is going to be, what other locales need to be rendered, and where you'd
39
105
  place the translation data files. Then edit your config file to override the default plugin configuration, as required.
40
- (See above section for default settings). For example, to render the site with data for just the custom `fr` locale:
106
+ (See above section for default settings). For example, to render the entire site with data for just the custom `fr`
107
+ locale:
41
108
 
42
109
  ```yaml
43
110
  # _config.yml
44
111
 
45
112
  author: John Doe
46
- locale: "fr"
113
+ localization:
114
+ mode: auto
115
+ locale: fr
47
116
  ```
48
117
 
49
- But if you'd like the site to be rendered using both the default `en` and custom `fr` locales, then
118
+ But if you'd like the entire site to be rendered using both the default `en-US` and custom `fr` locales, then
50
119
 
51
120
  ```yaml
52
121
  # _config.yml
53
122
 
54
123
  author: John Doe
55
- available_locales: ["fr"] # or ["fr", "en"] if you want
124
+ localization:
125
+ mode: auto
126
+ locales_set: ["fr"] # or ["fr", "en-US"] if you want
56
127
  ```
57
128
 
58
129
  3. Prepare your locale data file(s) with appropriate key-value pairs. For example,
@@ -90,6 +161,44 @@ A localization plugin for Jekyll.
90
161
  <html lang="{{ page.locale }}">
91
162
  ```
92
163
 
164
+ ### Manual Mode
165
+
166
+ Similar to the *auto mode*, but requires the user to provide physical files in the configured `content_dir` with
167
+ sub-directories that match the defined locales.
168
+
169
+ For example, the following directory structure
170
+
171
+ ```
172
+ .
173
+ ├── _config.yml
174
+ ├── _locales
175
+ | ├── es
176
+ | | ├── tips/
177
+ | | | └── optimized-site.md
178
+ | | ├── _posts/
179
+ | | ├──└── 2018-09-30-hello-world.md
180
+ | ├── fr
181
+ | | ├── _posts/
182
+ | └──└──└── 2018-09-30-hello-world.md
183
+ ├── _posts
184
+ | └── 2018-09-30-hello-world.md
185
+ ├── english
186
+ | └── its-a-new-day.md
187
+ ├── tips
188
+ | ├── optimized-site.md
189
+ └──└── url-filters-in-templates.md
190
+ ```
191
+ will result in the generation of just the following files:
192
+
193
+ ```
194
+ _site/2018-09-30-hello-world.html
195
+ _site/english/its-a-new-day.html
196
+ _site/es/2018-09-30-hello-world.html
197
+ _site/es/tips/optimized-site.html
198
+ _site/fr/2018-09-30-hello-world.html
199
+ _site/tips/optimized-site.html
200
+ _site/tips/url-filters-in-templates.html
201
+ ```
93
202
 
94
203
  ## Advanced Usage
95
204
 
@@ -105,11 +214,11 @@ pages are related to each other:
105
214
  {% endfor %}
106
215
  ```
107
216
 
108
- For example, `about.md` page with `permalink: /about/` in a site setup to render for locales `["en", "es", "fr"]`
217
+ For example, `about.md` page with `permalink: /about/` in a site setup to render for locales `["en-US", "es", "fr"]`
109
218
  and hosted at `http://example.com` will render with the following:
110
219
 
111
220
  ```html
112
- <link rel="canonical" hreflang="en" href="http://example.com/about/" />
221
+ <link rel="canonical" hreflang="en-US" href="http://example.com/about/" />
113
222
  <link rel="alternate" hreflang="es" href="http://example.com/es/about/" />
114
223
  <link rel="alternate" hreflang="fr" href="http://example.com/fr/about/" />
115
224
  ```
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ class Locale::AutoPage < Page
5
+ extend Forwardable
6
+ include Locale::Helper
7
+
8
+ attr_accessor :data, :content, :output
9
+ def_delegators :@canon, :site, :extname, :relative_path
10
+
11
+ def initialize(canon, locale)
12
+ setup(canon, locale)
13
+ @path = canon.path
14
+ @content = canon.content
15
+ @data = canon.data
16
+ end
17
+
18
+ def url
19
+ @url ||= File.join("", locale, canon.url)
20
+ end
21
+
22
+ def to_liquid
23
+ @to_liquid ||= Locale::PageDrop.new(self)
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ class Locale::Document < Document
5
+ include Locale::Helper
6
+
7
+ def initialize(canon, locale)
8
+ setup(canon, locale)
9
+ @collection = canon.collection
10
+ @extname = File.extname(relative_path)
11
+ @has_yaml_header = nil
12
+ read
13
+
14
+ special_dir = draft? ? "_drafts" : @collection.relative_directory
15
+ categories_from_path(special_dir)
16
+
17
+ configure_data
18
+ end
19
+
20
+ def url_template
21
+ @url_template ||= File.join("", locale, super)
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ class Locale::Generator < Generator
5
+ safe true
6
+ priority :lowest
7
+
8
+ def generate(site)
9
+ @site = site
10
+ handler = site.locale_handler
11
+ return if handler.available_locales.empty?
12
+
13
+ handler.available_locales.each do |locale|
14
+ handler.filtered_portfolio.each do |canon_doc|
15
+ handler.append_document(Locale::AutoPage, canon_doc, locale, site.pages)
16
+ end
17
+ end
18
+ end
19
+
20
+ def inspect
21
+ "#<#{self.class} @site=#{@site}>"
22
+ end
23
+ end
24
+ end
@@ -4,9 +4,23 @@ module Jekyll
4
4
  class Locale::Handler
5
5
  attr_writer :current_locale
6
6
 
7
+ DEFAULT_CONFIG = {
8
+ "mode" => "manual",
9
+ "locale" => "en-US",
10
+ "data_dir" => "locales",
11
+ "content_dir" => "_locales",
12
+ "locales_set" => [],
13
+ "exclude_set" => [],
14
+ }.freeze
15
+
7
16
  def initialize(site)
8
17
  @site = site
9
- @config = site.config
18
+ config = site.config["localization"]
19
+ @config = if config.is_a?(Hash)
20
+ Jekyll::Utils.deep_merge_hashes(DEFAULT_CONFIG, config)
21
+ else
22
+ DEFAULT_CONFIG
23
+ end
10
24
  end
11
25
 
12
26
  def reset
@@ -15,16 +29,47 @@ module Jekyll
15
29
  end
16
30
 
17
31
  def data
18
- locale_data[current_locale] || locale_data[default_locale]
32
+ locale_data[current_locale] || locale_data[default_locale] || {}
19
33
  end
20
34
 
21
35
  def portfolio
22
36
  @portfolio ||= (site.docs_to_write + html_pages)
23
37
  end
24
38
 
39
+ def filtered_portfolio
40
+ @filtered_portfolio ||= begin
41
+ portfolio.reject do |item|
42
+ item.relative_path =~ exclusion_regex
43
+ end
44
+ end
45
+ end
46
+
47
+ def read
48
+ available_locales.each do |locale|
49
+ portfolio.each do |canon_doc|
50
+ loc_page_path = site.in_source_dir(content_dirname, locale, canon_doc.relative_path)
51
+ next unless File.exist?(loc_page_path)
52
+ next unless Jekyll::Utils.has_yaml_header?(loc_page_path)
53
+
54
+ case canon_doc
55
+ when Jekyll::Page
56
+ append_document(Locale::Page, canon_doc, locale, site.pages)
57
+ when Jekyll::Document
58
+ append_document(Locale::Document, canon_doc, locale, site.docs_to_write)
59
+ end
60
+ end
61
+ end
62
+ end
63
+
64
+ def append_document(klass, canon_doc, locale, base_array)
65
+ locale_page = klass.new(canon_doc, locale)
66
+ canon_doc.locale_pages << locale_page
67
+ base_array << locale_page
68
+ end
69
+
25
70
  def available_locales
26
71
  @available_locales ||= begin
27
- locales = Array(config["available_locales"]) - [default_locale]
72
+ locales = Array(config["locales_set"]) - [default_locale]
28
73
  locales.compact!
29
74
  locales
30
75
  end
@@ -35,9 +80,17 @@ module Jekyll
35
80
  end
36
81
 
37
82
  def default_locale
38
- @default_locale ||= begin
39
- value = config["locale"]
40
- value.to_s.empty? ? "en" : value
83
+ @default_locale ||= fetch("locale")
84
+ end
85
+
86
+ def content_dirname
87
+ @content_dirname ||= fetch("content_dir")
88
+ end
89
+
90
+ def mode
91
+ @mode ||= begin
92
+ value = config["mode"]
93
+ value == "auto" ? value : DEFAULT_CONFIG["mode"]
41
94
  end
42
95
  end
43
96
 
@@ -57,10 +110,7 @@ module Jekyll
57
110
  end
58
111
 
59
112
  def locales_dir
60
- @locales_dir ||= begin
61
- value = config["locales_dir"]
62
- value.to_s.empty? ? "locales" : value
63
- end
113
+ @locales_dir ||= fetch("data_dir")
64
114
  end
65
115
 
66
116
  def locale_data
@@ -72,5 +122,18 @@ module Jekyll
72
122
  Jekyll::Utils.snake_case_keys(ldata)
73
123
  end
74
124
  end
125
+
126
+ def fetch(key)
127
+ value = config[key]
128
+ default = DEFAULT_CONFIG[key]
129
+ return default unless value.class == default.class
130
+ return default if value.to_s.empty?
131
+
132
+ value
133
+ end
134
+
135
+ def exclusion_regex
136
+ @exclusion_regex ||= Regexp.new("\\A(?:#{Regexp.union(Array(config["exclude_set"]))})")
137
+ end
75
138
  end
76
139
  end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ module Locale::Helper
5
+ attr_reader :canon, :relative_path
6
+
7
+ def setup_hreflangs?
8
+ true
9
+ end
10
+
11
+ def setup_hreflangs
12
+ @hreflangs = (canon.locale_pages + [canon] - [self]).map do |locale_page|
13
+ {
14
+ "locale" => locale_page.locale || site.locale_handler.default_locale,
15
+ "relation" => locale_page.locale ? "alternate" : "canonical",
16
+ "url" => locale_page.url,
17
+ }
18
+ end
19
+ end
20
+
21
+ def permalink
22
+ canon_link = super
23
+ File.join(locale, canon_link) if canon_link
24
+ end
25
+
26
+ def inspect
27
+ "#<#{self.class} @canon=#{canon.inspect} @locale=#{locale.inspect}>"
28
+ end
29
+ alias_method :to_s, :inspect
30
+
31
+ private
32
+
33
+ def setup(canon, locale)
34
+ @locale = locale
35
+ @canon = canon
36
+ @site = canon.site
37
+ @extname = canon.extname
38
+ @relative_path = canon.relative_path
39
+ @path = site.in_source_dir(site.locale_handler.content_dirname, locale, relative_path)
40
+ end
41
+
42
+ def configure_data
43
+ Jekyll::Utils.deep_merge_hashes(canon.data, @data)
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ module Locale::Support
5
+ attr_reader :locale
6
+
7
+ def setup_hreflangs?
8
+ false
9
+ end
10
+
11
+ def hreflangs
12
+ @hreflangs ||= locale_pages.map do |locale_page|
13
+ {
14
+ "locale" => locale_page.locale,
15
+ "relation" => "alternate",
16
+ "url" => locale_page.url,
17
+ }
18
+ end
19
+ end
20
+
21
+ def locale_pages
22
+ @locale_pages ||= []
23
+ end
24
+ end
25
+ end
@@ -2,39 +2,20 @@
2
2
 
3
3
  module Jekyll
4
4
  class Locale::Page < Page
5
- extend Forwardable
6
-
7
- attr_reader :canon, :locale
8
- attr_accessor :data, :content, :output
9
-
10
- def_delegators :@canon, :site, :extname, :relative_path
5
+ include Locale::Helper
11
6
 
12
7
  def initialize(canon, locale)
13
- @canon = canon
14
- @locale = locale
15
- end
16
-
17
- def url
18
- @url ||= File.join(locale, canon.url)
19
- end
20
-
21
- def to_liquid
22
- @to_liquid ||= Locale::PageDrop.new(self)
23
- end
24
-
25
- def setup_hreflangs
26
- @hreflangs = (canon.locale_pages + [canon] - [self]).map do |locale_page|
27
- {
28
- "locale" => locale_page.locale || site.locale_handler.default_locale,
29
- "relation" => locale_page.locale ? "alternate" : "canonical",
30
- "url" => locale_page.url,
31
- }
32
- end
8
+ setup(canon, locale)
9
+ @dir, @name = File.split(relative_path)
10
+ @dir = "" if @dir == "."
11
+ @base = site.source
12
+ process(@name)
13
+ read_yaml(@dir, @name)
14
+ configure_data
33
15
  end
34
16
 
35
- def inspect
36
- "#<#{self.class} @canon=#{canon.inspect} @locale=#{locale.inspect}>"
17
+ def template
18
+ @template ||= File.join("", locale, super)
37
19
  end
38
- alias_method :to_s, :inspect
39
20
  end
40
21
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Jekyll
4
4
  module Locale
5
- VERSION = "0.2.0"
5
+ VERSION = "0.3.0"
6
6
  end
7
7
  end
data/lib/jekyll-locale.rb CHANGED
@@ -2,47 +2,40 @@
2
2
 
3
3
  module Jekyll
4
4
  module Locale
5
- autoload :Drop, "jekyll/locale/drop"
6
- autoload :Page, "jekyll/locale/page"
7
- autoload :Handler, "jekyll/locale/handler"
5
+ autoload :Drop, "jekyll/locale/drop"
6
+ autoload :Document, "jekyll/locale/document"
7
+ autoload :AutoPage, "jekyll/locale/auto_page"
8
+ autoload :Page, "jekyll/locale/page"
9
+ autoload :Handler, "jekyll/locale/handler"
8
10
  end
9
-
10
- #
11
-
12
- module LocaleSupport
13
- attr_reader :locale
14
-
15
- def hreflangs
16
- @hreflangs ||= locale_pages.map do |locale_page|
17
- {
18
- "locale" => locale_page.locale,
19
- "relation" => "alternate",
20
- "url" => locale_page.url,
21
- }
22
- end
23
- end
24
-
25
- def locale_pages
26
- @locale_pages ||= []
27
- end
28
- end
29
-
30
- # Enhance Jekyll::Page and Jekyll::Document classes
31
- [Page, Document].each { |klass| klass.include LocaleSupport }
32
11
  end
33
12
 
34
- require_relative "jekyll/locale/page_generator"
35
-
36
13
  require_relative "jekyll/patches/site"
37
14
  require_relative "jekyll/patches/utils"
38
15
 
16
+ require_relative "jekyll/locale/mixins/support"
17
+ require_relative "jekyll/locale/mixins/helper"
18
+
19
+ # Enhance Jekyll::Page and Jekyll::Document classes
20
+ [Jekyll::Page, Jekyll::Document].each do |klass|
21
+ klass.include Jekyll::Locale::Support
22
+ end
23
+
24
+ # Load Locale::Generator if requested
39
25
  Jekyll::Hooks.register :site, :after_reset do |site|
40
- site.locale_handler.reset
26
+ handler = site.locale_handler
27
+ handler.reset
28
+ require_relative "jekyll/locale/generator" if handler.mode == "auto"
29
+ end
30
+
31
+ Jekyll::Hooks.register :site, :post_read do |site|
32
+ handler = site.locale_handler
33
+ handler.read unless handler.mode == "auto"
41
34
  end
42
35
 
43
36
  Jekyll::Hooks.register [:pages, :documents], :pre_render do |document, payload|
44
37
  handler = document.site.locale_handler
45
38
  handler.current_locale = document.locale
46
- document.setup_hreflangs if document.is_a?(Jekyll::Locale::Page)
39
+ document.setup_hreflangs if document.setup_hreflangs?
47
40
  payload["page"]["hreflangs"] = document.hreflangs
48
41
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-locale
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ashwin Maroli
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-24 00:00:00.000000000 Z
11
+ date: 2018-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -34,10 +34,14 @@ files:
34
34
  - LICENSE.txt
35
35
  - README.md
36
36
  - lib/jekyll-locale.rb
37
+ - lib/jekyll/locale/auto_page.rb
38
+ - lib/jekyll/locale/document.rb
37
39
  - lib/jekyll/locale/drop.rb
40
+ - lib/jekyll/locale/generator.rb
38
41
  - lib/jekyll/locale/handler.rb
42
+ - lib/jekyll/locale/mixins/helper.rb
43
+ - lib/jekyll/locale/mixins/support.rb
39
44
  - lib/jekyll/locale/page.rb
40
- - lib/jekyll/locale/page_generator.rb
41
45
  - lib/jekyll/locale/version.rb
42
46
  - lib/jekyll/patches/site.rb
43
47
  - lib/jekyll/patches/utils.rb
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Jekyll
4
- class Locale::PageGenerator < Generator
5
- safe true
6
- priority :lowest
7
-
8
- def generate(site)
9
- @site = site
10
- handler = site.locale_handler
11
- return if handler.available_locales.empty?
12
-
13
- handler.available_locales.each do |locale|
14
- handler.portfolio.each do |canon_doc|
15
- locale_page = Locale::Page.new(canon_doc, locale)
16
- locale_page.content = canon_doc.content
17
- locale_page.data = canon_doc.data
18
-
19
- # add locale_page to parent document and base array of pages
20
- canon_doc.locale_pages << locale_page
21
- site.pages << locale_page
22
- end
23
- end
24
- end
25
-
26
- def inspect
27
- "#<#{self.class} @site=#{@site}>"
28
- end
29
- end
30
- end