Skip to content

Commit

Permalink
Parallel localization
Browse files Browse the repository at this point in the history
* simple method for parallizing localization

* updated readme and gem
  • Loading branch information
untra committed Apr 4, 2016
1 parent b984b2a commit abf0579
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 18 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
:abc: Polyglot
---
version 1.1.1
version 1.1.2

__Polyglot__ is a fast, painless, open-source internationalization plugin for [Jekyll](http://jekyllrb.com) blogs. Polyglot is easy to setup and use with any Jekyll project, and it scales to the languages you want to support. With fallback support for missing content, automatic url relativization, and powerful SEO recipes, Polyglot allows any multi-language blog to focus on content without the cruft.

Expand All @@ -10,7 +10,7 @@ Jekyll doesn't provide native support for multi-language blogs. This plugin was
## Installation
*Jekyll 3.0:*
```
gem 'jekyll-polyglot', '~> 1.1.1'
gem 'jekyll-polyglot', '~> 1.1.2'
```
You can also just copy the [polyglot.rb](https://github.com/untra/polyglot/blob/master/lib/polyglot.rb) file into your project's `_plugins` folder.

Expand Down Expand Up @@ -144,7 +144,7 @@ Check out the example project website [here](https://untra.github.io/polyglot)
Currently supports Jekyll 3.0 .
The gem v1.0.1 works just fine with Jekyll version 2.5.3 .

Polyglot currently [does not support](https://github.com/untra/polyglot/issues/11) Windows operating systems. This is being corrected.
Windows users will need to disable parallel_localization on their machines by setting `parallel_localization: false` in the `_config.yml`

## Copyright
Copyright (c) Samuel Volin 2015. License: MIT
1 change: 1 addition & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ github:
languages: ["en", "es", "de", "fr"]
default_lang: "en"
exclude_from_localization: ["javascript", "images", "css", "public"]
parallel_localization: true
4 changes: 2 additions & 2 deletions jekyll-polyglot.gemspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Gem::Specification.new do |s|
s.name = 'jekyll-polyglot'
s.version = '1.1.1'
s.date = '2015-12-20'
s.version = '1.1.2'
s.date = '2016-04-04'
s.summary = "I18n plugin for Jekyll Blogs"
s.description = "Fast open source internationalization plugin for Jekyll blogs."
s.authors = ["Samuel Volin"]
Expand Down
33 changes: 20 additions & 13 deletions lib/polyglot.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Jekyll Polyglot v1.1.1
# Jekyll Polyglot v1.1.2
# Fast, painless, open source i18n plugin for Jekyll 3.0 Blogs.
# author: Samuel Volin (@untra)
# github: https://github.com/untra/polyglot
Expand All @@ -16,6 +16,7 @@ def prepare
@file_langs = {}
@default_lang = config['default_lang'] || 'en'
@languages = config['languages'] || ['en']
@parallel_localization = config['parallel_localization'] || true
(@keep_files << @languages - [@default_lang]).flatten!
@exclude_from_localization = config['exclude_from_localization'] || []
@active_lang = @default_lang
Expand All @@ -24,21 +25,27 @@ def prepare
alias_method :process_orig, :process
def process
prepare
pids = {}
languages.each do |lang|
pids[lang] = fork do
process_language lang
if @parallel_localization
pids = {}
languages.each do |lang|
pids[lang] = fork do
process_language lang
end
end
Signal.trap('INT') do
languages.each do |lang|
puts "Killing #{pids[lang]} : #{lang}"
kill('INT', pids[lang])
end
end
end
Signal.trap('INT') do
languages.each do |lang|
puts "Killing #{pids[lang]} : #{lang}"
kill('INT', pids[lang])
waitpid pids[lang]
detach pids[lang]
end
else
languages.each do |lang|
process_language lang
end
end
languages.each do |lang|
waitpid pids[lang]
detach pids[lang]
end
end

Expand Down
12 changes: 12 additions & 0 deletions test/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
@config['langs'] = @langs
@config['default_lang'] = @default_lang
@config['exclude_from_localization'] = @exclude_from_localization
@parallel_localization = @config['parallel_localization'] || true
@site = Site.new(
Jekyll.configuration(
'langs' => @langs,
Expand All @@ -31,6 +32,17 @@
@baseurls = ['/polyglot', '/big-brother', '/bas3url2']
end

describe 'parallel_localization' do
it 'should default to true if parallel_localization if not set' do
assert(@parallel_localization)
end
it 'should be false if explicitly set' do
@config['parallel_localization'] = false
@parallel_localization = @config['parallel_localization'] || true
assert(@parallel_localization)
end
end

describe 'Convertible relative_url_regex' do
it 'must match certain strings with any simple baseurl' do
@baseurls.each do |baseurl|
Expand Down

0 comments on commit abf0579

Please sign in to comment.