Module: Noticed::Translation

Extended by:
ActiveSupport::Concern
Included in:
Base
Defined in:
lib/noticed/translation.rb

Instance Method Summary collapse

Instance Method Details

#class_scopeObject



10
11
12
# File 'lib/noticed/translation.rb', line 10

def class_scope
  self.class.name.underscore.tr("/", ".")
end

#i18n_scopeObject

Returns the i18n_scope for the class. Overwrite if you want custom lookup.



6
7
8
# File 'lib/noticed/translation.rb', line 6

def i18n_scope
  :notifications
end

#scope_translation_key(key) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/noticed/translation.rb', line 19

def scope_translation_key(key)
  if key.to_s.start_with?(".")
    "#{i18n_scope}.#{class_scope}#{key}"
  else
    key
  end
end

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



14
15
16
# File 'lib/noticed/translation.rb', line 14

def translate(key, **options)
  I18n.translate(scope_translation_key(key), **options)
end