Sha256: fb627055501cf4065e29174f2d70ca87096083ace70c43ccaf20e096882ae1f5
Contents?: true
Size: 487 Bytes
Versions: 3
Compression:
Stored size: 487 Bytes
Contents
# frozen_string_literal: true module Phlex::Rails::Helpers::Translate module ClassMethods def translation_path @translation_path ||= name&.dup.tap do |n| n.gsub!("::", ".") n.gsub!(/([a-z])([A-Z])/, '\1_\2') n.downcase! end end end def self.included(base) base.extend(ClassMethods) end def translate(key, **options) key = "#{self.class.translation_path}#{key}" if key.start_with?(".") helpers.t(key, **options) end alias_method :t, :translate end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
phlex-rails-1.2.2 | lib/phlex/rails/helpers/translate.rb |
phlex-rails-1.2.1 | lib/phlex/rails/helpers/translate.rb |
phlex-rails-1.2.0 | lib/phlex/rails/helpers/translate.rb |