Module: I18n::Backend::Cascade

Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/i18n-1.12.0/lib/i18n/backend/cascade.rb

Instance Method Summary collapse

Instance Method Details

#lookup(locale, key, scope = [], options = EMPTY_HASH) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/i18n-1.12.0/lib/i18n/backend/cascade.rb', line 36

def lookup(locale, key, scope = [], options = EMPTY_HASH)
  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