Module: RailsCoreExtensions::Translations::ClassMethods
- Defined in:
- lib/rails_core_extensions/translations.rb
Instance Method Summary collapse
- #base_translation_class ⇒ Object
- #t(key, options = {}) ⇒ Object
- #translate(key, options = {}) ⇒ Object
- #translation_key ⇒ Object
Instance Method Details
#base_translation_class ⇒ Object
14 15 16 17 |
# File 'lib/rails_core_extensions/translations.rb', line 14 def base_translation_class return base_class if defined?(ActiveRecord) && ancestors.include?(ActiveRecord::Base) self end |
#t(key, options = {}) ⇒ Object
19 20 21 |
# File 'lib/rails_core_extensions/translations.rb', line 19 def t(key, = {}) self.translate(key, ) end |
#translate(key, options = {}) ⇒ Object
6 7 8 |
# File 'lib/rails_core_extensions/translations.rb', line 6 def translate(key, = {}) I18n.translate key, **.merge(scope: translation_key) end |
#translation_key ⇒ Object
10 11 12 |
# File 'lib/rails_core_extensions/translations.rb', line 10 def translation_key @translation_key ||= base_translation_class.name.tableize.singularize.gsub('/', '.') end |