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