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

Includes:
Base, Flatten
Included in:
I18n::Backend::ActiveRecord
Defined in:
lib/active_support/vendor/i18n-0.4.1/i18n/backend/active_record.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

Constants included from Flatten

Flatten::FLATTEN_SEPARATOR, Flatten::SEPARATOR_ESCAPE_CHAR

Instance Method Summary collapse

Methods included from Base

#load_translations, #localize, #reload!, #translate

Methods included from Transliterator

get, #transliterate

Methods included from Flatten

escape_default_separator, #flatten_keys, #flatten_translations, #links, normalize_flat_keys, #normalize_flat_keys

Instance Method Details

#available_localesObject



14
15
16
17
18
19
20
# File 'lib/active_support/vendor/i18n-0.4.1/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/active_support/vendor/i18n-0.4.1/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