Class: ActionDispatch::Routing::RouteSet

Inherits:
Object
  • Object
show all
Defined in:
lib/route_translator/extensions/route_set.rb

Instance Method Summary collapse

Instance Method Details

#add_localized_route(mapping, name, anchor, scope, path, controller, default_action, to, via, formatted, options_constraints, options) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/route_translator/extensions/route_set.rb', line 8

def add_localized_route(mapping, name, anchor, scope, path, controller, default_action, to, via, formatted, options_constraints, options)
  route = RouteTranslator::Route.new(self, path, name, options_constraints, options, mapping)

  RouteTranslator::Translator.translations_for(route) do |locale, translated_name, translated_path, translated_options_constraints, translated_options|
    translated_path_ast = ::ActionDispatch::Journey::Parser.parse(translated_path)
    translated_mapping  = translate_mapping(locale, self, translated_options, translated_path_ast, scope, controller, default_action, to, formatted, via, translated_options_constraints, anchor)

    add_route translated_mapping, translated_name
  end

  if RouteTranslator.config.generate_unnamed_unlocalized_routes
    add_route mapping, nil
  elsif RouteTranslator.config.generate_unlocalized_routes
    add_route mapping, name
  end
end