jekyll-multiple-languages-plugin 1.2.9 → 1.3.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
  SHA1:
3
- metadata.gz: 70d8b7b44997db4533f328c11895cc0135200cb2
4
- data.tar.gz: 697d1c42e3cbf710660f76bf6082d78257751294
3
+ metadata.gz: 3c1762c238a15c6006f3bb808443c5c8469f4506
4
+ data.tar.gz: 0b977d28c6f03539781add8bced23efa44abbe2a
5
5
  SHA512:
6
- metadata.gz: bba07c84820767d33bded5e4695f92064f93bff9168e7c058e5bd5cea05d18289fd63a758c233064fda25e6a5e29ca9555d9ddbda7cb2bb90f5c7f609d7b2a85
7
- data.tar.gz: 502bab34718f61702de75a4b0e9e6b6d0126633918426a38b226daaa9657264d6d0821d778dd71309e634666db1d0ed2051d8e4b84f88977159197dbe8f6637e
6
+ metadata.gz: 32e09219e49c549b07fc4f564c17b9febb42a481b6ea675757874bf4fc9f122b40493d8d0b11dc4e649db593ef21ec06424fb135cf42ac0920371fdbb0597546
7
+ data.tar.gz: d84b61a05fc8073699c1a5168bba537734efde40bb4702ac918daa4552a38e4c2f6473d72660b8574d720aeadc7d6391ea6f422c0526ca504156320d4d8d4f94
data/README.md CHANGED
@@ -59,37 +59,6 @@ Copy or link the file `lib/jekyll/multiple/languages/plugin.rb` into your `_plug
59
59
  * Supports translated keys in YAML format
60
60
  * Supports translated template files
61
61
 
62
- ##Changelog
63
- * 1.2.9
64
- * Bug fix when excluding files from translation, again thanks to [@h6](https://github.com/H6)
65
- * 1.2.8
66
- * Support for excluding files from translation, thanks to [@h6](https://github.com/H6)
67
- * 1.2.7
68
- * Support for Jekyll 2.5+, thanks to [@caxy4](https://github.com/caxy4)
69
- * 1.2.6
70
- * Added fallback to default language, thanks to [@agramian](https://github.com/agramian)
71
- * 1.2.5
72
- * Fixed a bug when global variables wasn't as global as expected
73
- * 1.2.4
74
- * Fixed a bug when changes in .yml files got lost during live reload.
75
- * 1.2.3
76
- * Much, much, much faster compilation when lots of translated strings.
77
- * 1.2.2
78
- * Supports translated posts in Octopress
79
- * 1.2.1
80
- * Supports writing translated posts in Jekyll
81
- * Supports translated .yml files in Octopress
82
- * 1.2.0
83
- * Renamed the project to jekyll-multiple-languages-plugin
84
- * 1.1.2
85
- * Support for both variables and strings in ```translate_file```
86
- * 1.1.1
87
- * Fixed documentation
88
- * 1.1.0
89
- * Pull request that removed dirty forward slash from URLs
90
- * 1.0.0
91
- * First release
92
-
93
62
 
94
63
  ##Usage
95
64
  ###Configuration
@@ -101,12 +70,12 @@ languages: ["sv", "en", "de", "fr"]
101
70
 
102
71
  The first language in the array will be the default language, English, German and French will be added in to separate subfolders.
103
72
 
104
- To avoid redundancy, it is possible to exclude files and folders from beeing copied to the localization folders.
73
+ To avoid redundancy, it is possible to exclude files and folders from beeing copied to the localization folders.
105
74
 
106
75
  ```yaml
107
76
  exclude_from_localizations: ["javascript", "images", "css"]
108
77
  ```
109
- In code these specific files shoule be referenced via `baseurl_root`. E.g.
78
+ In code these specific files should be referenced via `baseurl_root`. E.g.
110
79
 
111
80
  ```
112
81
  <link rel="stylesheet" href="{{ "/css/bootstrap.css" | prepend: site.baseurl_root }}"/>
@@ -182,7 +151,7 @@ A perfect example is this:
182
151
  </html>
183
152
  ```
184
153
 
185
- So how can I add different translated titles to all pages? Don't worry, it's easy. The Multiple Languages plugin supports Liguid variables as well as strings so define a page variable in your page definition
154
+ So how can I add different translated titles to all pages? Don't worry, it's easy. The Multiple Languages plugin supports Liquid variables as well as strings so define a page variable in your page definition
186
155
 
187
156
  ```yaml
188
157
  ---
@@ -233,6 +202,42 @@ This snippet will create a link that will toggle between Swedish and English. A
233
202
  | site.baseurl_root | Points to the root of the page without the language path | ``` http://foo.bar ``` |
234
203
  | page.url | The current page's relative URL to the baseurl | ``` /a/sub/folder/page/ ```|
235
204
 
205
+
206
+ ##Changelog
207
+ * 1.3.0
208
+ * Support for localized links and custom permalinks, thanks to [@jasonlemay](https://github.com/screeninteraction/jekyll-multiple-languages-plugin/pull/53)
209
+ * Support for excluding posts from translation, thanks to [ctruelson](https://github.com/screeninteraction/jekyll-multiple-languages-plugin/pull/51)
210
+ * 1.2.9
211
+ * Bug fix when excluding files from translation, again thanks to [@h6](https://github.com/H6)
212
+ * 1.2.8
213
+ * Support for excluding files from translation, thanks to [@h6](https://github.com/H6)
214
+ * 1.2.7
215
+ * Support for Jekyll 2.5+, thanks to [@caxy4](https://github.com/caxy4)
216
+ * 1.2.6
217
+ * Added fallback to default language, thanks to [@agramian](https://github.com/agramian)
218
+ * 1.2.5
219
+ * Fixed a bug when global variables wasn't as global as expected
220
+ * 1.2.4
221
+ * Fixed a bug when changes in .yml files got lost during live reload.
222
+ * 1.2.3
223
+ * Much, much, much faster compilation when lots of translated strings.
224
+ * 1.2.2
225
+ * Supports translated posts in Octopress
226
+ * 1.2.1
227
+ * Supports writing translated posts in Jekyll
228
+ * Supports translated .yml files in Octopress
229
+ * 1.2.0
230
+ * Renamed the project to jekyll-multiple-languages-plugin
231
+ * 1.1.2
232
+ * Support for both variables and strings in ```translate_file```
233
+ * 1.1.1
234
+ * Fixed documentation
235
+ * 1.1.0
236
+ * Pull request that removed dirty forward slash from URLs
237
+ * 1.0.0
238
+ * First release
239
+
240
+
236
241
  ## Contributing
237
242
 
238
243
  1. Fork it
@@ -246,4 +251,4 @@ This snippet will create a link that will toggle between Swedish and English. A
246
251
  - [@Davrandom](https://github.com/davrandom), plugin usage example
247
252
  - [@agramian](https://github.com/agramian), fallback to default language
248
253
  - [@h6](https://github.com/H6), exclude files from translation
249
- - [@leoditommaso)(https://github.com/leoditommaso), update the example page
254
+ - [@leoditommaso](https://github.com/leoditommaso), update the example page
@@ -32,8 +32,8 @@ module Jekyll
32
32
  @dest = @dest + "/" + lang
33
33
  self.config['baseurl'] = self.config['baseurl'] + "/" + lang
34
34
  self.config['lang'] = lang
35
-
36
- # exclude folders or files from beeing copied to all the language folders
35
+
36
+ # exclude folders or files from being copied to all the language folders
37
37
  exclude_from_localizations = self.config['exclude_from_localizations'] || []
38
38
  @exclude = @exclude + exclude_from_localizations
39
39
 
@@ -52,7 +52,8 @@ module Jekyll
52
52
 
53
53
  alias :read_posts_org :read_posts
54
54
  def read_posts(dir)
55
- if dir == ''
55
+ translate_posts = !self.config['exclude_from_localizations'].include?("_posts")
56
+ if dir == '' && translate_posts
56
57
  read_posts("_i18n/#{self.config['lang']}/")
57
58
  else
58
59
  read_posts_org(dir)
@@ -60,6 +61,18 @@ module Jekyll
60
61
  end
61
62
  end
62
63
 
64
+ class Page
65
+ def permalink
66
+ return nil if data.nil? || data['permalink'].nil?
67
+ if site.config['relative_permalinks']
68
+ File.join(@dir, data['permalink'])
69
+ else
70
+ # Look if there's a permalink overwrite specified for this lang
71
+ data['permalink_'+site.config['lang']] || data['permalink']
72
+ end
73
+ end
74
+ end
75
+
63
76
  class LocalizeTag < Liquid::Tag
64
77
 
65
78
  def initialize(tag_name, key, tokens)
@@ -130,6 +143,44 @@ module Jekyll
130
143
  end
131
144
  end
132
145
  end
146
+
147
+ class LocalizeLink < Liquid::Tag
148
+
149
+ def initialize(tag_name, key, tokens)
150
+ super
151
+ @key = key
152
+ end
153
+
154
+ def render(context)
155
+ if "#{context[@key]}" != "" #Check for page variable
156
+ key = "#{context[@key]}"
157
+ else
158
+ key = @key
159
+ end
160
+ key = key.split
161
+ namespace = key[0]
162
+ lang = key[1] || context.registers[:site].config['lang']
163
+ default_lang = context.registers[:site].config['default_lang']
164
+ baseurl = context.registers[:site].baseurl
165
+ pages = context.registers[:site].pages
166
+ url = "";
167
+
168
+ if default_lang != lang
169
+ baseurl = baseurl + "/" + lang
170
+ end
171
+
172
+ for p in pages
173
+ unless p['namespace'].nil?
174
+ page_namespace = p['namespace']
175
+ if namespace == page_namespace
176
+ permalink = p['permalink_'+lang] || p['permalink']
177
+ url = baseurl + permalink
178
+ end
179
+ end
180
+ end
181
+ url
182
+ end
183
+ end
133
184
  end
134
185
 
135
186
  unless Hash.method_defined? :access
@@ -153,3 +204,5 @@ Liquid::Template.register_tag('t', Jekyll::LocalizeTag)
153
204
  Liquid::Template.register_tag('translate', Jekyll::LocalizeTag)
154
205
  Liquid::Template.register_tag('tf', Jekyll::Tags::LocalizeInclude)
155
206
  Liquid::Template.register_tag('translate_file', Jekyll::Tags::LocalizeInclude)
207
+ Liquid::Template.register_tag('tl', Jekyll::LocalizeLink)
208
+ Liquid::Template.register_tag('translate_link', Jekyll::LocalizeLink)
@@ -2,7 +2,7 @@ module Jekyll
2
2
  module Multiple
3
3
  module Languages
4
4
  module Plugin
5
- VERSION = "1.2.9"
5
+ VERSION = "1.3.0"
6
6
  end
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-multiple-languages-plugin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.9
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Kurtsson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-16 00:00:00.000000000 Z
11
+ date: 2015-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
100
  version: '0'
101
101
  requirements: []
102
102
  rubyforge_project:
103
- rubygems_version: 2.2.2
103
+ rubygems_version: 2.4.6
104
104
  signing_key:
105
105
  specification_version: 4
106
106
  summary: I18n plugin for Jekyll and Octopress