Parent

Class Index [+]

Quicksearch

I18n::Locale::Fallbacks

Attributes

defaults[R]

Public Class Methods

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

Public Instance Methods

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

Protected Instance Methods

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

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.