Class: I18n::JS::FallbackLocales
- Inherits:
-
Object
- Object
- I18n::JS::FallbackLocales
- Defined in:
- lib/i18n/js/fallback_locales.rb
Instance Attribute Summary collapse
-
#fallbacks ⇒ Object
readonly
Returns the value of attribute fallbacks.
-
#locale ⇒ Object
readonly
Returns the value of attribute locale.
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(fallbacks, locale) ⇒ FallbackLocales
constructor
A new instance of FallbackLocales.
-
#locales ⇒ Array<String, Symbol>
An Array of locales to use as fallbacks for given locale.
Constructor Details
#initialize(fallbacks, locale) ⇒ FallbackLocales
Returns a new instance of FallbackLocales.
6 7 8 9 |
# File 'lib/i18n/js/fallback_locales.rb', line 6 def initialize(fallbacks, locale) @fallbacks = fallbacks @locale = locale end |
Instance Attribute Details
#fallbacks ⇒ Object (readonly)
Returns the value of attribute fallbacks.
4 5 6 |
# File 'lib/i18n/js/fallback_locales.rb', line 4 def fallbacks @fallbacks end |
#locale ⇒ Object (readonly)
Returns the value of attribute locale.
4 5 6 |
# File 'lib/i18n/js/fallback_locales.rb', line 4 def locale @locale end |
Instance Method Details
#each ⇒ Object
11 12 13 |
# File 'lib/i18n/js/fallback_locales.rb', line 11 def each locales.each { |locale| yield(locale) } end |
#locales ⇒ Array<String, Symbol>
Returns An Array of locales to use as fallbacks for given locale.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/i18n/js/fallback_locales.rb', line 17 def locales locales = case fallbacks when true default_fallbacks when :default_locale [::I18n.default_locale] when Symbol, String [fallbacks.to_sym] when Array ensure_valid_fallbacks_as_array! fallbacks when Hash Array(fallbacks[locale] || default_fallbacks) else fail ArgumentError, "fallbacks must be: true, :default_locale an Array or a Hash - given: #{fallbacks}" end locales.map! { |locale| locale.to_sym } locales end |