Module: Mova::I18nConfig

Defined in:
lib/mova-i18n/config.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.interpolatorObject



25
26
27
# File 'lib/mova-i18n/config.rb', line 25

def interpolator
  @interpolator ||= I18nInterpolator.new
end

.translatorObject



21
22
23
# File 'lib/mova-i18n/config.rb', line 21

def translator
  @translator ||= I18nTranslator.new
end

Class Method Details

.pluralizer(locale) ⇒ Object



29
30
31
32
33
# File 'lib/mova-i18n/config.rb', line 29

def pluralizer(locale)
  @pluralizers ||= {}
  @pluralizers[locale] ||= translator.storage.read("#{locale}.i18n.plural.rule") ||
                           ->(count){ count == 1 ? :one : :other }
end

.transfer_translations!Object

Note:

Clears all current translations in ‘I18n.mova.translator.storage`. Use Storage::Readonly to protect certain storages if you have a chain of them.

Transfer translations from ‘I18n::Backend::Simple`, since we can have enumerate all keys here. Other key-value storages should be passed to `I18n.mova.translator` directly.



11
12
13
14
15
16
17
18
19
# File 'lib/mova-i18n/config.rb', line 11

def transfer_translations!
  # calling protected methods
  I18n.backend.send(:init_translations) if I18n.backend.respond_to?(:init_translations, true)
  if I18n.backend.respond_to?(:translations, true)
    translations = I18n.backend.send(:translations)
    translator.storage.clear
    translator.put(translations)
  end
end