kwi / i18n_routing

I18n routing module for Rails 2.3.x and Rails 3. Translate your routes with ease !
MIT License
228 stars 48 forks source link

translations of named routes by name (not path) #11

Closed rudionrails closed 14 years ago

rudionrails commented 14 years ago

Hi all,

I've added the option to match the route translation for named routes by their name and not the path. I found it a little cumbersome for a project with existing routes to add all of them by their path and not the actual route name. Routes may change a lot during development, but the name usually does not.

Example:

routes.rb

ActionController::Routing::Routes.draw do |map|
  map.localized do
    map.welcome 'welcome/to/our/page', :controller => 'welcome', :action => 'index'
  end
end
# locales
en:
  named_routes:
    welcome: 'welcome-to-our-page'

fr:
  named_routes_path:
    'welcome/to/our/page': 'bienvenue'

The defaults still apply. When a named route can't be found in :named_routes then look for it in :named_routes_path. The example above shows the case for :en, when a named route is present, as well as for :fr, when named_routes_path is defined.

Best, Rudi

kwi commented 14 years ago

Hi Rudi,

This looks very good, thanks for your contribution, I will merge it into master as soon as I have a little moment :)

Best, Kwi

kwi commented 14 years ago

Merged in master ! Thanks again and sorry for the delay :)