Class: ActionDispatch::Routing::Mapper::MappingLocalized
- Inherits:
-
Mapping
- Object
- Mapping
- ActionDispatch::Routing::Mapper::MappingLocalized
- Defined in:
- lib/i18n_url/routes/mapper.rb
Instance Method Summary collapse
-
#initialize(locale, set, scope, path, options) ⇒ MappingLocalized
constructor
A new instance of MappingLocalized.
- #localized_name_route ⇒ Object
- #translate_route(path) ⇒ Object
Constructor Details
#initialize(locale, set, scope, path, options) ⇒ MappingLocalized
Returns a new instance of MappingLocalized.
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/i18n_url/routes/mapper.rb', line 30 def initialize(locale, set, scope, path, ) @locale = locale I18n.locale = locale path.gsub!(/^\//, '') format = '(.:format)' path.gsub!( format, '') translate_route path path = "/#{@locale}/" + @localized_path.join("/") super(set, scope, path, ) localized_name_route end |
Instance Method Details
#localized_name_route ⇒ Object
42 43 44 45 |
# File 'lib/i18n_url/routes/mapper.rb', line 42 def localized_name_route original_name = [:as] [:as] = "#{@locale}_#{original_name}" if original_name end |
#translate_route(path) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/i18n_url/routes/mapper.rb', line 47 def translate_route path path.split("/").each do |word| next if word[0] == ":" (@localized_path ||= []) << I18n.t(word,:scope => :routes, :default => word) end end |