Module: Copycat::Implementation
- Included in:
- I18n::Backend::Simple
- Defined in:
- lib/copycat/implementation.rb
Instance Method Summary collapse
-
#lookup(locale, key, scope = [], options = {}) ⇒ Object
this method overrides part of the i18n gem, lib/i18n/backend/simple.rb.
Instance Method Details
#lookup(locale, key, scope = [], options = {}) ⇒ Object
this method overrides part of the i18n gem, lib/i18n/backend/simple.rb
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/copycat/implementation.rb', line 4 def lookup(locale, key, scope = [], = {}) return super unless ActiveRecord::Base.connected? && CopycatTranslation.table_exists? cct = CopycatTranslation.where(locale: locale.to_s, key: key.to_s).first return cct.value if cct value = super(locale, key, scope, ) if value.is_a?(String) || value.nil? CopycatTranslation.create(locale: locale.to_s, key: key.to_s, value: value) end value end |