11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/i18nema.rb', line 11
def translate(locale, key, options = {})
raise I18n::InvalidLocale.new(locale) unless locale
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.reject { |key, value| RESERVED_KEY_MAP.key?(key) }
entry = entry.nil? && default ?
default(locale, key, default, options) : resolve(locale, key, entry, options)
end
throw(:exception, I18n::MissingTranslation.new(locale, key, options)) if entry.nil?
entry = pluralize(locale, entry, count) if count
entry = interpolate(locale, entry, values) if values
entry
end
|