Make translate.rb plugin fallback to English by default

Display English content in outdated translated templates when this doesn't cause too much issues
This commit is contained in:
Saivann 2014-06-14 17:21:01 -04:00
parent 5f2d32d134
commit 78b04ea0ee
13 changed files with 21 additions and 77 deletions

View file

@ -63,6 +63,18 @@ module Jekyll
if ar.has_key?(id) && ar[id].is_a?(String)
text = ar[id]
end
#fallback to English if string is empty
if text == ''
lang = 'en'
ar = site['loc'][lang]
for key in keys do
break if !ar.is_a?(Hash) || !ar.has_key?(key) || !ar[key].is_a?(Hash)
ar = ar[key]
end
if ar.has_key?(id) && ar[id].is_a?(String)
text = ar[id]
end
end
#replace urls and anchors in string
url = site['loc'][lang]['url']
url.each do |key,value|