Sha256: 4b2ea4128170586ebae33023daf3e9000ccffa58658345b31c348e7322b89d7f
Contents?: true
Size: 728 Bytes
Versions: 5
Compression:
Stored size: 728 Bytes
Contents
module RailsCoreExtensions module Translations def self.included(base) base.extend ClassMethods end module ClassMethods def translate(key, options = {}) I18n.translate key, **options.merge(scope: translation_key) end def translation_key @translation_key ||= base_translation_class.name.tableize.singularize.gsub('/', '.') end def base_translation_class return base_class if defined?(ActiveRecord) && ancestors.include?(ActiveRecord::Base) self end def t(key, options = {}) self.translate(key, options) end end private def t(key, options = {}) self.class.translate(key, options) end end end
Version data entries
5 entries across 5 versions & 1 rubygems