instance method
translate
Ruby on Rails 2.3.18
Since v2.3.18 Last seen in v2.3.18Signature
translate(locale, key, options = {})
No documentation comment.
Parameters
-
localereq -
keyreq -
optionsopt = {}
Source
# File activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/base.rb, line 30
def translate(locale, key, options = {})
raise InvalidLocale.new(locale) unless locale
return key.map { |k| translate(locale, k, options) } if key.is_a?(Array)
entry = key && lookup(locale, key, options[:scope], options)
if options.empty?
entry = resolve(locale, key, entry, options)
else
count, default = options.values_at(:count, :default)
values = options.except(*RESERVED_KEYS)
entry = entry.nil? && default ?
default(locale, key, default, options) : resolve(locale, key, entry, options)
end
raise(I18n::MissingTranslationData.new(locale, key, options)) if entry.nil?
entry = entry.dup if entry.is_a?(String)
entry = pluralize(locale, entry, count) if count
entry = interpolate(locale, entry, values) if values
entry
end
Defined in activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/base.rb line 30
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in I18n::Backend::Base