8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/dragoman/route_set.rb', line 8
def add_route_with_localization(app, conditions = {}, requirements = {}, defaults = {}, name = nil, anchor = true)
dragoman_options = defaults.delete :dragoman_options
path_helpers, url_helpers = helper_modules
if dragoman_options
Dragoman::UrlHelpers.add_untranslated_helpers name, path_helpers, url_helpers if name
dragoman_options[:locales].each do |locale|
new_conditions = conditions.dup
new_requirements = requirements.dup
new_name = name ? "#{name}_#{locale}" : nil
new_name = nil if new_name && named_routes.routes[new_name.to_sym]
if new_path = new_conditions.delete(:path_info)
new_path = Dragoman::Translator.translate_path new_path, locale
new_conditions[:path_info] = new_path
new_conditions[:parsed_path_info] = Dragoman::Journey::Parser.new.parse new_path if new_conditions[:parsed_path_info]
end
new_requirements[:locale] = locale
add_route_without_localization app, new_conditions, new_requirements, defaults.dup, new_name, anchor
end
else
add_route_without_localization app, conditions, requirements, defaults, name, anchor
end
end
|