3
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
|
# File 'lib/rails-localization/url_helper.rb', line 3
def handle_positional_args(controller_options, inner_options, args, result, path_params)
options = super
if options[:_recall] && options[:_recall].has_key?(:locale) && path_params.include?(:locale)
if inner_options.has_key?(:locale) && inner_options[:locale].blank?
options.delete(:locale)
else
if inner_options[:locale] && ::I18n.config.available_locales.include?(inner_options[:locale].to_sym)
if inner_options[:locale].to_s != ::I18n.default_locale.to_s
options[:locale] = inner_options[:locale]
else
options.delete(:locale)
end
else
if ::I18n.locale.to_s != ::I18n.default_locale.to_s
options[:locale] = ::I18n.locale.to_s
else
options.delete(:locale)
end
end
end
end
if options.has_key?(:locale) && !inner_options.has_key?(:locale) && !path_params.include?(:locale)
options.delete(:locale)
end
if options.has_key?(:_positional_keys) && options[:_positional_keys].includes?(:locale)
i = options[:_positional_keys].index(:locale)
options[:_positional_args].insert(i, (options.delete(:locale) || ::I18n.locale.to_s))
end
options
end
|