4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/copy_tuner_client/helper_extension.rb', line 4
def hook_translation_helper(mod, middleware_enabled:)
mod.class_eval do
def (key, **options)
source = (key, **options)
if controller && CopyTunerClient::Rails.controller_of_rails_engine?(controller)
return source
end
if options.key?(:default)
I18n.t(key.to_s.first == '.' ? scope_key_by_partial(key) : key, **options)
end
if CopyTunerClient.configuration.
source
else
separator = options[:separator] || I18n.default_separator
scope = options[:scope]
scope_key =
if key.to_s.first == '.'
scope_key_by_partial(key)
else
I18n.normalize_keys(nil, key, scope, separator).compact.join(separator)
end
CopyTunerClient::Copyray.augment_template(source, scope_key)
end
end
if middleware_enabled
alias_method :translate_without_copyray_comment, :translate
alias_method :translate, :translate_with_copyray_comment
alias :t :translate
alias :tt :translate_without_copyray_comment
else
alias :tt :translate
end
end
end
|