Welcome to mirror list, hosted at ThFree Co, Russian Federation.

i18n_interpolation_fallbacks.rb « lib - github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: cdf2480191ffb6d0e7d630da91776c52f37b8db6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
module I18n
  module Backend
    module InterpolationFallbacks

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

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

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