jekyll-multiple-languages-plugin 1.2.0 → 1.2.1

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: 7b82f848f59fd42778adc49bc185a780936778b0
4
- data.tar.gz: 7bc74540378b2818dd3540726e9bbf149fc7f7ea
3
+ metadata.gz: 437382c6919e0f607b4bb0d5b98d514704b1fd17
4
+ data.tar.gz: 36b3c661881ae56a5d12f6d8fe3ddaa3bc835c9a
5
5
  SHA512:
6
- metadata.gz: 2e6d1ebea84906ebbc8c92dd89fb414286a224a85bfab497826fc672650d09c63ac8affa47b72a20eaa9e8d00806e3d59175141df9ec8fd712cc96f8a6eed7b6
7
- data.tar.gz: 5bebf75a7bf024197f0524b24ced3460a5d76087af8dd3c578c336fcf7007c2c28d19dd8afe5d6f6dfc28b561d688a8fd21ce0f0c1c7affc35810fe4108d52ca
6
+ metadata.gz: eb3a7852cbb502d63aedf98ca78ed2c23fd1c9979699f507f82a3b82cf22fcffc3d9f5118dbe60e3ef2f999f74a945d7f387c7c37eae8e5abf1bcf320bc5101d
7
+ data.tar.gz: fa407baf34ff429f22fc13830d826046abcba230995f8ba3c72981f7f5df1c5a7db1721ffc97293ab404d35c184ed2d998934d97f23f7c7cdf8ca681acfbabf8
data/README.md CHANGED
@@ -1,27 +1,10 @@
1
1
  # Multiple Languages in Jekyll
2
2
 
3
- Jekyll Multiple Languages is an internationalization plugin for [Jekyll](https://github.com/mojombo/jekyll). It compiles your Jekyll site for one or more languages with a similar approach as Rails does. The different sites will be stored in sub folders with the same name as the language it contains.
3
+ Jekyll Multiple Languages is an internationalization plugin for [Jekyll](https://github.com/mojombo/jekyll). It compiles your Jekyll site for one or more languages with a similar approach as Rails does. The different sites will be stored in sub folders with the same name as the language it contains. Version 1.2.1 and later also supports Octopress.
4
4
 
5
5
  The plugin is developed as an utility at [Screen Interaction](http://www.screeninteraction.com)
6
6
 
7
7
  ##Installation
8
- ### Submodule
9
- If your Jekyll project is in a git repository, you can easily
10
- manage your plugins by utilizing git submodules.
11
-
12
- To install this plugin as a git submodule:
13
-
14
- git submodule add git://github.com/screeninteraction/jekyll-multiple-languages-plugin.git _plugins/multiple-languages
15
-
16
- To update:
17
-
18
- cd _plugins/multiple-languages
19
- git pull origin master
20
-
21
-
22
- ### Copy file
23
- Copy or link the file `lib/jekyll/multiple/languages/plugin.rb` into your `_plugins` folder for your Jekyll project.
24
-
25
8
 
26
9
  ### Gem [![Gem Version](https://badge.fury.io/rb/jekyll-multiple-languages-plugin.png)](http://badge.fury.io/rb/jekyll-multiple-languages-plugin)
27
10
 
@@ -43,8 +26,26 @@ To activate the plugin add this line in to a *.rb file in the _plugins directory
43
26
 
44
27
  require 'jekyll/multiple/languages/plugin'
45
28
 
29
+
30
+ ### Submodule
31
+ If your Jekyll project is in a git repository, you can easily
32
+ manage your plugins by utilizing git submodules.
33
+
34
+ To install this plugin as a git submodule:
35
+
36
+ git submodule add git://github.com/screeninteraction/jekyll-multiple-languages-plugin.git _plugins/multiple-languages
37
+
38
+ To update:
39
+
40
+ cd _plugins/multiple-languages
41
+ git pull origin master
42
+
43
+
44
+ ### Copy file
45
+ Copy or link the file `lib/jekyll/multiple/languages/plugin.rb` into your `_plugins` folder for your Jekyll project.
46
+
46
47
 
47
- ###Features
48
+ ##Features
48
49
  * Supports multiple languages with the same code base.
49
50
  * Supports all template languages that your Liquid pipeline supports.
50
51
  * Uses [Liquid tags](https://github.com/Shopify/liquid) in your HTML for including translated strings.
@@ -53,7 +54,8 @@ To activate the plugin add this line in to a *.rb file in the _plugins directory
53
54
  * Contains an example web site thanks to [@davrandom](https://github.com/davrandom/)
54
55
  * Supports translated keys in YAML format
55
56
  * Supports translated template files
56
- * _NEW!_ Supports writing translated posts
57
+ * *NEW!* Supports writing translated posts
58
+ * *NEW!* Supports Octopress
57
59
 
58
60
  ##Usage
59
61
  ###Configuration
@@ -1,5 +1,4 @@
1
1
  source 'https://rubygems.org'
2
- gem 'github-pages'
3
- #gem 'multiple-languages-plugin'
4
2
  gem "jekyll"
3
+ gem 'jekyll-multiple-languages-plugin'
5
4
 
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Jekyll::Multiple::Languages::Plugin::VERSION
9
9
  spec.authors = ["Martin Kurtsson"]
10
10
  spec.email = ["martin.kurtsson@screeninteraction.com"]
11
- spec.description = %q{I18n plugin for Jekyll}
12
- spec.summary = %q{I18n plugin for Jekyll}
11
+ spec.description = %q{Plugin for Jekyll and Octopress that adds support for translated keys, templates and posts.}
12
+ spec.summary = %q{I18n plugin for Jekyll and Octopress}
13
13
  spec.homepage = "https://github.com/screeninteraction/jekyll-multiple-languages-plugin/"
14
14
  spec.license = "MPL2"
15
15
 
@@ -4,11 +4,14 @@ module Jekyll
4
4
  class Site
5
5
  alias :process_org :process
6
6
  def process
7
+ if !self.config['baseurl']
8
+ self.config['baseurl'] = ""
9
+ end
7
10
  #Variables
8
- self.config['baseurl_root'] = self.config['baseurl']
9
- dest_org = self.dest
10
- baseurl_org = self.baseurl
11
+ config['baseurl_root'] = self.config['baseurl']
12
+ baseurl_org = self.config['baseurl']
11
13
  languages = self.config['languages']
14
+ dest_org = self.dest
12
15
 
13
16
  #Loop
14
17
  self.config['lang'] = languages.first
@@ -19,15 +22,13 @@ module Jekyll
19
22
 
20
23
  # Build site for language lang
21
24
  self.dest = self.dest + "/" + lang
22
- self.baseurl = self.baseurl + "/" + lang
23
- self.config['baseurl'] = self.baseurl
25
+ self.config['baseurl'] = self.config['baseurl'] + "/" + lang
24
26
  self.config['lang'] = lang
25
27
  puts "Building site for language: \"#{self.config['lang']}\" to: " + self.dest
26
28
  process_org
27
29
 
28
30
  #Reset variables for next language
29
31
  self.dest = dest_org
30
- self.baseurl = baseurl_org
31
32
  self.config['baseurl'] = baseurl_org
32
33
  end
33
34
  puts 'Build complete'
@@ -51,47 +52,6 @@ module Jekyll
51
52
  end
52
53
  end
53
54
 
54
- class LocalizeInclude < Jekyll::Tags::IncludeTag
55
- def render(context)
56
- if "#{context[@file]}" != "" #Check for page variable
57
- file = "#{context[@file]}"
58
- else
59
- file = @file
60
- end
61
-
62
- includes_dir = File.join(context.registers[:site].source, '_i18n/' + context.registers[:site].config['lang'])
63
-
64
- if File.symlink?(includes_dir)
65
- return "Includes directory '#{includes_dir}' cannot be a symlink"
66
- end
67
- if file !~ /^[a-zA-Z0-9_\/\.-]+$/ || file =~ /\.\// || file =~ /\/\./
68
- return "Include file '#{file}' contains invalid characters or sequences"
69
- end
70
-
71
- Dir.chdir(includes_dir) do
72
- choices = Dir['**/*'].reject { |x| File.symlink?(x) }
73
- if choices.include?(file)
74
- source = File.read(file)
75
- partial = Liquid::Template.parse(source)
76
-
77
- context.stack do
78
- context['include'] = parse_params(context) if @params
79
- contents = partial.render(context)
80
- site = context.registers[:site]
81
- ext = File.extname(file)
82
-
83
- converter = site.converters.find { |c| c.matches(ext) }
84
- contents = converter.convert(contents) unless converter.nil?
85
-
86
- contents
87
- end
88
- else
89
- "Included file '#{file}' not found in #{includes_dir} directory"
90
- end
91
- end
92
- end
93
- end
94
-
95
55
  class LocalizeTag < Liquid::Tag
96
56
 
97
57
  def initialize(tag_name, key, tokens)
@@ -124,9 +84,52 @@ module Jekyll
124
84
  end
125
85
  end
126
86
  end
87
+
88
+ module Tags
89
+ class LocalizeInclude < IncludeTag
90
+ def render(context)
91
+ if "#{context[@file]}" != "" #Check for page variable
92
+ file = "#{context[@file]}"
93
+ else
94
+ file = @file
95
+ end
96
+
97
+ includes_dir = File.join(context.registers[:site].source, '_i18n/' + context.registers[:site].config['lang'])
98
+
99
+ if File.symlink?(includes_dir)
100
+ return "Includes directory '#{includes_dir}' cannot be a symlink"
101
+ end
102
+ if file !~ /^[a-zA-Z0-9_\/\.-]+$/ || file =~ /\.\// || file =~ /\/\./
103
+ return "Include file '#{file}' contains invalid characters or sequences"
104
+ end
105
+
106
+ Dir.chdir(includes_dir) do
107
+ choices = Dir['**/*'].reject { |x| File.symlink?(x) }
108
+ if choices.include?(file)
109
+ source = File.read(file)
110
+ partial = Liquid::Template.parse(source)
111
+
112
+ context.stack do
113
+ context['include'] = parse_params(context) if @params
114
+ contents = partial.render(context)
115
+ site = context.registers[:site]
116
+ ext = File.extname(file)
117
+
118
+ converter = site.converters.find { |c| c.matches(ext) }
119
+ contents = converter.convert(contents) unless converter.nil?
120
+
121
+ contents
122
+ end
123
+ else
124
+ "Included file '#{file}' not found in #{includes_dir} directory"
125
+ end
126
+ end
127
+ end
128
+ end
129
+ end
127
130
  end
128
131
 
129
132
  Liquid::Template.register_tag('t', Jekyll::LocalizeTag)
130
- Liquid::Template.register_tag('tf', Jekyll::LocalizeInclude)
131
133
  Liquid::Template.register_tag('translate', Jekyll::LocalizeTag)
132
- Liquid::Template.register_tag('translate_file', Jekyll::LocalizeInclude)
134
+ Liquid::Template.register_tag('tf', Jekyll::Tags::LocalizeInclude)
135
+ Liquid::Template.register_tag('translate_file', Jekyll::Tags::LocalizeInclude)
@@ -2,7 +2,7 @@ module Jekyll
2
2
  module Multiple
3
3
  module Languages
4
4
  module Plugin
5
- VERSION = "1.2.0"
5
+ VERSION = "1.2.1"
6
6
  end
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-multiple-languages-plugin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Kurtsson
@@ -38,7 +38,8 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- description: I18n plugin for Jekyll
41
+ description: Plugin for Jekyll and Octopress that adds support for translated keys,
42
+ templates and posts.
42
43
  email:
43
44
  - martin.kurtsson@screeninteraction.com
44
45
  executables: []
@@ -96,8 +97,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
97
  version: '0'
97
98
  requirements: []
98
99
  rubyforge_project:
99
- rubygems_version: 2.1.11
100
+ rubygems_version: 2.2.0
100
101
  signing_key:
101
102
  specification_version: 4
102
- summary: I18n plugin for Jekyll
103
+ summary: I18n plugin for Jekyll and Octopress
103
104
  test_files: []