Module: I18n::Backend::InterpolationFallbacks

Defined in:
lib/i18n_interpolation_fallbacks.rb

Instance Method Summary collapse

Instance Method Details

#translate(locale, key, options = {}) ⇒ Object

Raises:

  • (I18n::MissingInterpolationArgument)


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/i18n_interpolation_fallbacks.rb', line 4

def translate(locale, key, options = {})
  default = extract_non_symbol_default!(options) if options[:default]
  options.merge!(:default => default) if default

  I18n.fallbacks[locale].each do |fallback|
    begin
      result = super(fallback, key, options)
      return result unless result.nil?
    rescue I18n::MissingInterpolationArgument
    end
  end

  return super(locale, nil, options) if default
  raise(I18n::MissingInterpolationArgument.new(options, "key: #{key} in locale: #{locale}"))
end