Module: Noticed::Translation
- Extended by:
- ActiveSupport::Concern
- Included in:
- Ephemeral, Ephemeral::Notification, Event, Notification
- Defined in:
- lib/noticed/translation.rb
Instance Method Summary collapse
- #class_scope ⇒ Object
-
#i18n_scope ⇒ Object
Returns the
i18n_scope
for the class. - #scope_translation_key(key) ⇒ Object
- #translate(key, **options) ⇒ Object (also: #t)
Instance Method Details
#class_scope ⇒ Object
10 11 12 |
# File 'lib/noticed/translation.rb', line 10 def class_scope self.class.name.underscore.tr("/", ".") end |
#i18n_scope ⇒ Object
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 :notifiers end |
#scope_translation_key(key) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/noticed/translation.rb', line 23 def scope_translation_key(key) if key.to_s.start_with?(".") [i18n_scope, class_scope].compact.join(".") + key else key end end |
#translate(key, **options) ⇒ Object Also known as: t
14 15 16 17 18 19 20 |
# File 'lib/noticed/translation.rb', line 14 def translate(key, **) if defined?(::ActiveSupport::HtmlSafeTranslation) ActiveSupport::HtmlSafeTranslation.translate scope_translation_key(key), ** else I18n.translate scope_translation_key(key), ** end end |