I'm fooling around with Ruby and basically I have
@trans = { :links => {
:quick_notes => "aaaaaaa"
}
}
I want to call something like
def t
#...something
end
t('links.quick_notes')
to access
trans[:links][:quick_notes]
I'm basically trying to achieve the same functionality like when using Internationalizations
I18n.t('something.other.foo')
sofar I came up with this approach
def t(key)
a=''
key.to_s.split('.').each{|key| a+="[:#{key}]" }
#now a == "[:links][:quick_notes]"
#but I cant figure out how can I call it on @trans variable
end
t('links.quick_notes')
Any ideas ? thanx
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…