Skip to content
This repository was archived by the owner on Jan 15, 2024. It is now read-only.

Commit e548a01

Browse files
authored
Merge pull request #122 from satzz/master
Build translations in `pre_render` hook
2 parents 38f8860 + 57f86c0 commit e548a01

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lib/jekyll-multiple-languages-plugin.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ module Jekyll
1919
#*****************************************************************************
2020
# :site, :post_render hook
2121
#*****************************************************************************
22+
Jekyll::Hooks.register :site, :pre_render do |site, payload|
23+
lang = site.config['lang']
24+
unless site.parsed_translations.has_key?(lang)
25+
puts "Loading translation from file #{site.source}/_i18n/#{lang}.yml"
26+
site.parsed_translations[lang] = YAML.load_file("#{site.source}/_i18n/#{lang}.yml")
27+
end
28+
end
2229
Jekyll::Hooks.register :site, :post_render do |site, payload|
2330

2431
# Removes all static files that should not be copied to translated sites.
@@ -309,11 +316,6 @@ def render(context)
309316

310317
lang = site.config['lang']
311318

312-
unless site.parsed_translations.has_key?(lang)
313-
puts "Loading translation from file #{site.source}/_i18n/#{lang}.yml"
314-
site.parsed_translations[lang] = YAML.load_file("#{site.source}/_i18n/#{lang}.yml")
315-
end
316-
317319
translation = site.parsed_translations[lang].access(key) if key.is_a?(String)
318320

319321
if translation.nil? or translation.empty?

0 commit comments

Comments
 (0)