Parent

I18n::Locale::Fallbacks

Attributes

defaults[R]

Public Class Methods

new(*mappings) click to toggle source
    # File lib/i18n/locale/fallbacks.rb, line 58
58:       def initialize(*mappings)
59:         @map = {}
60:         map(mappings.pop) if mappings.last.is_a?(Hash)
61:         self.defaults = mappings.empty? ? [I18n.default_locale.to_sym] : mappings
62:       end

Public Instance Methods

[](locale) click to toggle source
    # File lib/i18n/locale/fallbacks.rb, line 69
69:       def [](locale)
70:         raise InvalidLocale.new(locale) if locale.nil?
71:         locale = locale.to_sym
72:         super || store(locale, compute(locale))
73:       end
defaults=(defaults) click to toggle source
    # File lib/i18n/locale/fallbacks.rb, line 64
64:       def defaults=(defaults)
65:         @defaults = defaults.map { |default| compute(default, false) }.flatten
66:       end
map(mappings) click to toggle source
    # File lib/i18n/locale/fallbacks.rb, line 75
75:       def map(mappings)
76:         mappings.each do |from, to|
77:           from, to = from.to_sym, Array(to)
78:           to.each do |to|
79:             @map[from] ||= []
80:             @map[from] << to.to_sym
81:           end
82:         end
83:       end

Protected Instance Methods

compute(tags, include_defaults = true) click to toggle source
    # File lib/i18n/locale/fallbacks.rb, line 87
87:       def compute(tags, include_defaults = true)
88:         result = Array(tags).collect do |tag|
89:           tags = I18n::Locale::Tag.tag(tag).self_and_parents.map! { |t| t.to_sym }
90:           tags.each { |tag| tags += compute(@map[tag]) if @map[tag] }
91:           tags
92:         end.flatten
93:         result.push(*defaults) if include_defaults
94:         result.uniq
95:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.