Module: I18n::Debug::Hook

Defined in:
lib/i18n/debug.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



25
26
27
28
29
30
# File 'lib/i18n/debug.rb', line 25

def self.included(klass)
  klass.class_eval do
    alias_method :lookup_without_debug, :lookup
    alias_method :lookup, :lookup_with_debug
  end
end

Instance Method Details

#lookup_with_debug(*args) ⇒ Object



32
33
34
35
36
37
38
39
# File 'lib/i18n/debug.rb', line 32

def lookup_with_debug(*args)
  lookup_without_debug(*args).tap do |result|
    options = args.last.is_a?(Hash) ? args.pop : {}
    separator = options[:separator] || I18n.default_separator
    key = I18n.normalize_keys(*args, separator).join(separator)
    Debug.on_lookup[key, result]
  end
end