mirror of
https://github.com/seigler/dash-docs
synced 2025-07-27 01:36:13 +00:00
Allow recursive keys as category in translate.rb
This commit is contained in:
parent
f00bd18c7c
commit
67679b3893
1 changed files with 9 additions and 2 deletions
|
@ -50,8 +50,15 @@ module Jekyll
|
|||
end
|
||||
#get translated string
|
||||
text = ''
|
||||
if site['loc'][lang].has_key?(cat) && site['loc'][lang][cat].has_key?(id) && !site['loc'][lang][cat][id].nil?
|
||||
text = site['loc'][lang][cat][id]
|
||||
keys = cat.split('.')
|
||||
ar = site['loc'][lang]
|
||||
#recursive loop to handle cases where category is like "anchor.vocabulary"
|
||||
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
|
||||
#urlencode if string is a url
|
||||
if cat == 'url'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue