Class: SourcedConfig::Locale::I18nBackend

Inherits:
I18n::Backend::Simple
  • Object
show all
Defined in:
lib/sourced_config/locale/i18n_backend.rb

Instance Method Summary collapse

Instance Method Details

#load_translationsObject



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/sourced_config/locale/i18n_backend.rb', line 9

def load_translations
  return unless ::SourcedConfig.loaded? && ::SourcedConfig[:locales].present?
  type = ::SourcedConfig[:locales][:load_from_type]
  source = ::SourcedConfig[:locales][:load_from_source]
  null_client = Rails.env.test? ? NullClient.new : nil
  loader = Loader.new(type, source, client: null_client)
  ::SourcedConfig[:locales][:supported].each do |locale|
    Rails.logger.info "Load I18n: for supported locale #{locale}"
    store_translations(locale, loader.load(locale.to_sym)[locale])
  end
end