Module: I18nAutoScoping::BackendExtension

Defined in:
lib/i18n_auto_scoping.rb

Class Method Summary collapse

Class Method Details

.extended(k) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/i18n_auto_scoping.rb', line 40

def self.extended(k)
  k.class_eval do
    alias_method :i18n_auto_scoping_translate, :translate
    
    # Override translate method in order to set autoscoping
    def translate(locale, key, options = {})
      # Set the default scope if needed
      if !options.has_key?(:scope) or options[:scope] == :autoscoping
        options[:scope] = I18n::Scope.default 
      end
      i18n_auto_scoping_translate(locale, key, options)
    end
  end
end