Class: Mobility::Fallbacks

Inherits:
I18n::Locale::Fallbacks
  • Object
show all
Defined in:
lib/mobility/fallbacks.rb

Overview

Subclasses I18n::Locale::Fallbacks such that instances of this class fall through to fallbacks defined in I18n.fallbacks. This allows models to customize fallbacks while still falling through to any fallbacks defined globally.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.build(fallbacks) ⇒ I18n::Locale::Fallbacks, Mobility::Fallbacks

For this set of fallbacks, return a new fallbacks hash.


20
21
22
23
24
25
26
# File 'lib/mobility/fallbacks.rb', line 20

def self.build(fallbacks)
  if I18n.respond_to?(:fallbacks)
    new(fallbacks)
  else
    I18n::Locale::Fallbacks.new(fallbacks)
  end
end

Instance Method Details

#[](locale) ⇒ Array


13
14
15
# File 'lib/mobility/fallbacks.rb', line 13

def [](locale)
  super | I18n.fallbacks[locale]
end