Module: I18n::Backend::ActiveRecord::Implementation

Includes:
Base, Flatten
Included in:
I18n::Backend::ActiveRecord
Defined in:
lib/i18n/backend/active_record.rb

Instance Method Summary collapse

Instance Method Details

#available_localesObject



14
15
16
17
18
19
20
# File 'lib/i18n/backend/active_record.rb', line 14

def available_locales
  begin
    Translation.available_locales
  rescue ::ActiveRecord::StatementInvalid
    []
  end
end

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



22
23
24
25
26
27
28
# File 'lib/i18n/backend/active_record.rb', line 22

def store_translations(locale, data, options = {})
  escape = options.fetch(:escape, true)
  flatten_translations(locale, data, escape, false).each do |key, value|
    Translation.locale(locale).lookup(expand_keys(key)).delete_all
    Translation.create(:locale => locale.to_s, :key => key.to_s, :value => value)
  end
end