Module: I18nFeedback::Marking::Backend

Defined in:
lib/i18n_feedback/marking.rb

Overview

Prepended onto the active I18n backend class.

Instance Method Summary collapse

Instance Method Details

#translate(locale, key, options = {}) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/i18n_feedback/marking.rb', line 29

def translate(locale, key, options = {})
  result = super
  return result unless Marking.enabled? && result.is_a?(String)

  full = [*options[:scope], key].join('.')
  return result if full.match?(SKIP)

  # `super` returns a plain String even for _html keys (ActionView marks the
  # helper's output safe after the backend returns), so the marker lands
  # inside that buffer without changing any html_safe status.
  "#{result} #{LEFT}#{full}#{RIGHT}"
end