Module: Rosetta::I18nWithStoredPhrases

Included in:
I18n
Defined in:
lib/rosetta/i18n_with_stored_phrases.rb

Instance Method Summary collapse

Instance Method Details

#translate(*args) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/rosetta/i18n_with_stored_phrases.rb', line 3

def translate(*args)
  output = super
  return output unless Rosetta.enabled?

  keys = normalize_keys('', args.dig(0), args.dig(1, :scope))
  code = keys.join('.')

  Rosetta.add_phrase(keys: keys, phrase: output.to_s) if exists?(code, config.locale)

  output
end