59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/ree_lib/packages/ree_i18n/package/ree_i18n/functions/t.rb', line 59
def call(key = nil, context = {}, **options)
context.each do |k, _|
if RESERVED_KEYS.include?(k)
raise ArgumentError, "translation context contains reserved key :#{k}"
end
end
opts = context.merge(options)
default_by_locale = opts.delete(:default_by_locale)
if default_by_locale && !opts[:default]
opts[:default] = DEFAULT_BY_LOCALE
end
opts[:throw] ||= false
opts[:raise] ||= false
opts[:locale] ||= nil
result = I18n.t(key, **opts)
if result == DEFAULT_BY_LOCALE
result = call(
key, context,
**except(
options.merge(locale: default_by_locale), [:default_by_locale]
)
)
end
result
end
|