6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/i18n_namespace/fallbacks.rb', line 6
def translate(locale, key, options = {})
namespaced = options.fetch(:namespaced, false)
return super if !namespaced || ::I18n.namespace.blank?
scope = to_a(options.delete(:scope))
namespace = to_a(::I18n.namespace)
(namespace.size + 1).times do |part|
catch(:exception) do
options[:scope] = (namespace | scope).reject(&:nil?)
result = super(locale, key, options)
return result unless result.nil?
end
namespace.pop
end
throw(:exception, ::I18n::MissingTranslation.new(locale, key, options))
end
|