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.



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

def i18n_verbose
  @i18n_verbose
end

#localesObject

Returns the value of attribute locales.



35
36
37
# File 'lib/i18n_routing_rails2.rb', line 35

def locales
  @locales
end

Instance Method Details

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

:nodoc:



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

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

    stored_locale = I18n.locale
    @locales.each do |l|
      I18n.locale = l
      nt = "#{I18nRouting.locale_escaped(l)}_#{name}"
      t = I18nRouting.translation_for(name, :named_routes) || I18nRouting.translation_for(path, :named_routes_path)
      if nt != name and !t.blank?
        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
    I18n.locale = stored_locale

    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



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

alias_method :gl_add_named_route, :add_named_route