Skip to content

Commit

Permalink
Fix parallel_localization always true #21
Browse files Browse the repository at this point in the history
* Fix parallel_localization always true

`hash[key] || default` could be replaced with `hash.fetch(key, default)`
for robust code.

* Fix work under parallel_localization=false

Under parallel_localizationi is false, process_active_language should
undo all side effects after every process_orig call.

* Fix typo
  • Loading branch information
veblush authored and untra committed May 9, 2016
1 parent 05fdd9b commit 3280a2d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -12,7 +12,7 @@ Jekyll doesn't provide native support for multi-language blogs. This plugin was
`gem install jekyll-polyglot` and add jekyll-polyglot to your `_config.yml` like the following:
```yml
gems:
- jekyll-assets
- jekyll-polyglot
```

## Configuration
Expand Down
13 changes: 9 additions & 4 deletions lib/jekyll/polyglot/patches/jekyll/site.rb
Expand Up @@ -6,11 +6,11 @@ class Site

def prepare
@file_langs = {}
@default_lang = config['default_lang'] || 'en'
@languages = config['languages'] || ['en']
@parallel_localization = config['parallel_localization'] || true
@default_lang = config.fetch('default_lang', 'en')
@languages = config.fetch('languages', ['en'])
@parallel_localization = config.fetch('parallel_localization', true)
(@keep_files << @languages - [@default_lang]).flatten!
@exclude_from_localization = config['exclude_from_localization'] || []
@exclude_from_localization = config.fetch('exclude_from_localization', [])
@active_lang = @default_lang
end

Expand Down Expand Up @@ -58,9 +58,14 @@ def process_language(lang)
end

def process_active_language
old_dest = @dest
old_exclude = @exclude
@file_langs = {}
@dest = @dest + '/' + @active_lang
@exclude += @exclude_from_localization
process_orig
@dest = old_dest
@exclude = old_exclude
end

# assigns natural permalinks to documents and prioritizes documents with
Expand Down

0 comments on commit 3280a2d

Please sign in to comment.