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
|
# File 'lib/split_tester/translation_helper.rb', line 5
def self.included(base)
base.class_eval {
def translate(key, options = {})
key = scope_key_by_partial(key)
if is_split_test?
scope = options.delete(:scope)
keys = I18n.normalize_keys(I18n.locale, key, scope)
keys.shift
key = keys.join('.')
if options[:default]
options[:default] = [options[:default]] unless options[:default].is_a?(Array)
options[:default].unshift(key.to_sym)
else
options[:default] = [key.to_sym]
end
key = "#{current_split_test_key}.#{key}"
end
translation = I18n.translate(key, options.merge!(:raise => true))
if html_safe_translation_key?(key) && translation.respond_to?(:html_safe)
translation.html_safe
else
translation
end
rescue I18n::MissingTranslationData => e
keys = I18n.normalize_keys(e.locale, e.key, e.options[:scope])
content_tag('span', keys.join(', '), :class => 'translation_missing')
end
alias t translate
}
end
|