Module: I18n::Backend::ActiveRecord::Missing
- Defined in:
- lib/active_support/vendor/i18n-0.4.1/i18n/backend/active_record/missing.rb
Instance Method Summary collapse
- #store_default_translation(locale, key, interpolations) ⇒ Object
- #store_default_translations(locale, key, options = {}) ⇒ Object
- #translate(locale, key, options = {}) ⇒ Object
Instance Method Details
#store_default_translation(locale, key, interpolations) ⇒ Object
50 51 52 53 54 |
# File 'lib/active_support/vendor/i18n-0.4.1/i18n/backend/active_record/missing.rb', line 50 def store_default_translation(locale, key, interpolations) translation = ActiveRecord::Translation.new :locale => locale.to_s, :key => key translation.interpolations = interpolations translation.save end |
#store_default_translations(locale, key, options = {}) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/active_support/vendor/i18n-0.4.1/i18n/backend/active_record/missing.rb', line 36 def store_default_translations(locale, key, = {}) count, scope, default, separator = .values_at(:count, *Base::RESERVED_KEYS) separator ||= I18n.default_separator keys = I18n.normalize_keys(locale, key, scope, separator)[1..-1] key = keys.join(separator || I18n.default_separator) unless ActiveRecord::Translation.locale(locale).lookup(key).exists? interpolations = .reject { |name, value| Base::RESERVED_KEYS.include?(name) }.keys keys = count ? I18n.t('i18n.plural.keys', :locale => locale).map { |k| [key, k].join(separator) } : [key] keys.each { |key| store_default_translation(locale, key, interpolations) } end end |
#translate(locale, key, options = {}) ⇒ Object
56 57 58 59 60 61 |
# File 'lib/active_support/vendor/i18n-0.4.1/i18n/backend/active_record/missing.rb', line 56 def translate(locale, key, = {}) super rescue I18n::MissingTranslationData => e self.store_default_translations(locale, key, ) raise e end |