We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 71db8cc + 2f39311 commit e886ad8Copy full SHA for e886ad8
lib/phlex/rails/helpers.rb
@@ -1156,8 +1156,25 @@ module SubmitTag
1156
module T
1157
extend Phlex::Rails::HelperMacros
1158
1159
- # @!method t(...)
1160
- define_value_helper :t
+ def self.included(base)
+ base.extend(ClassMethods)
1161
+ end
1162
+
1163
+ module ClassMethods
1164
+ def translation_path
1165
+ @translation_path ||= name&.dup.tap do |n|
1166
+ n.gsub!("::", ".")
1167
+ n.gsub!(/([a-z])([A-Z])/, '\1_\2')
1168
+ n.downcase!
1169
1170
1171
1172
1173
+ def t(key, **options)
1174
+ key = "#{self.class.translation_path}#{key}" if key.start_with?(".")
1175
1176
+ helpers.t(key, **options)
1177
1178
end
1179
1180
module TelephoneField
0 commit comments