Class: ActionController::Routing::RouteSet

Inherits:
Object
  • Object
show all
Defined in:
lib/i18n_routing_rails2.rb

Overview

:nodoc:

Defined Under Namespace

Classes: Mapper, NamedRouteCollection

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#i18n_verboseObject

Returns the value of attribute i18n_verbose.



38
39
40
# File 'lib/i18n_routing_rails2.rb', line 38

def i18n_verbose
  @i18n_verbose
end

#localesObject

Returns the value of attribute locales.



37
38
39
# File 'lib/i18n_routing_rails2.rb', line 37

def locales
  @locales
end

Instance Method Details

#add_named_route(name, path, options = {}) ⇒ Object

:nodoc:



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/i18n_routing_rails2.rb', line 94

def add_named_route(name, path, options = {}) #:nodoc:
  if @locales and !path.blank? and !Thread.current[:i18n_no_named_localization]
    # Here, try to translate standard named routes
    name = name.to_s

    @locales.each do |l|
      I18n.locale = l
      nt = "#{l}_#{name}"
      if nt != name and (t = I18nRouting.translation_for(path, :named_routes_path))
        gl_add_named_route(nt, t, options.merge(:glang => l))
        puts("[I18n] > localize %-10s: %40s (%s) => %s" % ['route', name, l, t]) if @i18n_verbose
      end
    end

    old_v = Thread.current[:globalized]
    Thread.current[:globalized] = true
    gl_add_named_route(name, path, options)
    Thread.current[:globalized] = old_v
    return
  end

  gl_add_named_route(name, path, options)
end

#gl_add_named_routeObject



93
# File 'lib/i18n_routing_rails2.rb', line 93

alias_method :gl_add_named_route, :add_named_route