instance method
lookup
Ruby on Rails 2.3.18
Since v2.3.18 Last seen in v2.3.18Signature
lookup(locale, key, scope = [], options = {})
No documentation comment.
Parameters
-
localereq -
keyreq -
scopeopt = [] -
optionsopt = {}
Source
# File activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/active_record.rb, line 32
def lookup(locale, key, scope = [], options = {})
key = normalize_flat_keys(locale, key, scope, options[:separator])
result = Translation.locale(locale).lookup(key).all
if result.empty?
nil
elsif result.first.key == key
result.first.value
else
chop_range = (key.size + FLATTEN_SEPARATOR.size)..-1
result = result.inject({}) do |hash, r|
hash[r.key.slice(chop_range)] = r.value
hash
end
result.deep_symbolize_keys
end
end
Defined in activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/active_record.rb line 32
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in I18n::Backend::ActiveRecord::Implementation