class I18n::Locale::Fallbacks

def [](locale)

def [](locale)
  raise InvalidLocale.new(locale) if locale.nil?
  locale = locale.to_sym
  super || store(locale, compute(locale))
end

def compute(tags, include_defaults = true)

def compute(tags, include_defaults = true)
  result = Array(tags).collect do |tag|
    tags = I18n::Locale::Tag.tag(tag).self_and_parents.map! { |t| t.to_sym }
    tags.each { |tag| tags += compute(@map[tag]) if @map[tag] }
    tags
  end.flatten
  result.push(*defaults) if include_defaults
  result.uniq
end

def defaults=(defaults)

def defaults=(defaults)
  @defaults = defaults.map { |default| compute(default, false) }.flatten
end

def initialize(*mappings)

def initialize(*mappings)
  @map = {}
  map(mappings.pop) if mappings.last.is_a?(Hash)
  self.defaults = mappings.empty? ? [I18n.default_locale.to_sym] : mappings
end

def map(mappings)

def map(mappings)
  mappings.each do |from, to|
    from, to = from.to_sym, Array(to)
    to.each do |to|
      @map[from] ||= []
      @map[from] << to.to_sym
    end
  end
end