instance method
lookup
Ruby on Rails 2.3.18
Since v2.3.18 Last seen in v2.3.18Signature
lookup(locale, key, scope = [], options = {})
Looks up a translation from the translations hash. Returns nil if eiher key is nil, or locale, scope or key do not exist as a key in the nested translations hash. Splits keys or scopes containing dots into multiple keys, i.e. currency.format is regarded the same as %w(currency format).
Parameters
-
localereq -
keyreq -
scopeopt = [] -
optionsopt = {}
Source
# File activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/simple.rb, line 70
def lookup(locale, key, scope = [], options = {})
init_translations unless initialized?
keys = I18n.normalize_keys(locale, key, scope, options[:separator])
keys.inject(translations) do |result, key|
key = key.to_sym
return nil unless result.is_a?(Hash) && result.has_key?(key)
result = result[key]
result = resolve(locale, key, result, options.merge(:scope => nil)) if result.is_a?(Symbol)
result
end
end
Defined in activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/simple.rb line 70
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in I18n::Backend::Simple::Implementation