Module: Profiler::I18nLookupTracker

Defined in:
lib/profiler/collectors/i18n_collector.rb

Instance Method Summary collapse

Instance Method Details

#translate(key, **options) ⇒ Object Also known as: t



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/profiler/collectors/i18n_collector.rb', line 7

def translate(key, **options)
  result = super
  if (collector = Thread.current[:profiler_i18n_collector])
    missing = result.is_a?(String) && result.downcase.include?("translation missing:")
    collector.record_lookup(key, options[:locale] || I18n.locale, result, missing)
  end
  result
rescue I18n::MissingTranslationData => e
  if (collector = Thread.current[:profiler_i18n_collector])
    collector.record_lookup(key, options[:locale] || I18n.locale, nil, true)
  end
  raise
end