instance method
translate
Ruby on Rails 2.2.3
Since v2.2.3 Last seen in v2.2.3Signature
translate(locale, key, options = {})
No documentation comment.
Parameters
-
localereq -
keyreq -
optionsopt = {}
Source
# File activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb, line 24
def translate(locale, key, options = {})
raise InvalidLocale.new(locale) if locale.nil?
return key.map { |k| translate(locale, k, options) } if key.is_a? Array
reserved = :scope, :default
count, scope, default = options.values_at(:count, *reserved)
options.delete(:default)
values = options.reject { |name, value| reserved.include?(name) }
entry = lookup(locale, key, scope)
if entry.nil?
entry = default(locale, default, options)
if entry.nil?
raise(I18n::MissingTranslationData.new(locale, key, options))
end
end
entry = pluralize(locale, entry, count)
entry = interpolate(locale, entry, values)
entry
end
Defined in activesupport/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb line 24
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in I18n::Backend::Simple