module I18n::Backend::Cascade - i18n-0.6.11 Documentation

# module I18n::Backend::Cascade

### Public Instance Methods

lookup(locale, key, scope = [], options = {}) click to toggle source
Calls superclass method

    # File lib/i18n/backend/cascade.rb, line 34
    def lookup(locale, key, scope = [], options = {})
      return super unless cascade = options[:cascade]

      cascade   = { :step => 1 } unless cascade.is_a?(Hash)
      step      = cascade[:step]   || 1
      offset    = cascade[:offset] || 1
      separator = options[:separator] || I18n.default_separator
      skip_root = cascade.has_key?(:skip_root) ? cascade[:skip_root] : true

      scope = I18n.normalize_keys(nil, key, scope, separator)
      key   = (scope.slice!(-offset, offset) || []).join(separator)

      begin
        result = super
        return result unless result.nil?
        scope = scope.dup
      end while (!scope.empty? || !skip_root) && scope.slice!(-step, step)
    end