Module: I18n::Backend::Simple::Implementation

Includes:
Base
Included in:
I18n::Backend::Simple
Defined in:
lib/active_support/vendor/i18n-0.4.1/i18n/backend/simple.rb

Constant Summary

Constants included from Base

Base::DEPRECATED_INTERPOLATION_SYNTAX_PATTERN, Base::INTERPOLATION_SYNTAX_PATTERN, Base::RESERVED_KEYS, Base::RESERVED_KEYS_PATTERN

Constants included from Transliterator

Transliterator::DEFAULT_REPLACEMENT_CHAR

Instance Method Summary collapse

Methods included from Base

#load_translations, #localize, #translate

Methods included from Transliterator

get, #transliterate

Instance Method Details

#available_localesObject

Get available locales from the translations hash



39
40
41
42
43
44
45
# File 'lib/active_support/vendor/i18n-0.4.1/i18n/backend/simple.rb', line 39

def available_locales
  init_translations unless initialized?
  translations.inject([]) do |locales, (locale, data)|
    locales << locale unless (data.keys - [:i18n]).empty?
    locales
  end
end

#initialized?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/active_support/vendor/i18n-0.4.1/i18n/backend/simple.rb', line 23

def initialized?
  @initialized ||= false
end

#reload!Object

Clean up translations hash and set initialized to false on reload!



48
49
50
51
52
# File 'lib/active_support/vendor/i18n-0.4.1/i18n/backend/simple.rb', line 48

def reload!
  @initialized = false
  @translations = nil
  super
end

#store_translations(locale, data, options = {}) ⇒ Object

Stores translations for the given locale in memory. This uses a deep merge for the translations hash, so existing translations will be overwritten by new ones only at the deepest level of the hash.



31
32
33
34
35
36
# File 'lib/active_support/vendor/i18n-0.4.1/i18n/backend/simple.rb', line 31

def store_translations(locale, data, options = {})
  locale = locale.to_sym
  translations[locale] ||= {}
  data = data.deep_symbolize_keys
  translations[locale].deep_merge!(data)
end