named_routes_path not working

80 views
Skip to first unread message

Chack

unread,
Apr 1, 2011, 3:48:00 PM4/1/11
to I18n Routing
Hello,

I have a problem translating a match route in rails 3.0.3. The
something match route just wont get translated. I tried everything
possible, upgrading to 3.0.5, get instead of match, different quotes,
no quotes, no :as, :as => :something etc etc. As you can see
translations are working for routes, just not for the match.

Any idea why it isnt working is greatly apreciated.

#routes.rb
Multilang::Application.routes.draw do
scope "(:locale)", :locale => /en|de/ do
localized(I18n.available_locales, :verbose => true) do
match 'something', :to => 'projects#index', :as => 'something'
resources :projects, :only => [:index]
resources :users, :only => [:show]
root :to => 'home#index'
end
end
end

#de.yml
de:
hello: Hallo world
path_names:
new: neu
edit: bearbeiten
named_routes_path:
something: etwas
resources:
users: benutzer
projects: projekte

#rake routes
konstantin@localhost:~/Rails/multilang$ rake routes
(in /Users/konstantin/Rails/multilang)
[I18n] > localize resources : projects
(en) => /projects
[I18n] > localize resources : projects
(de) => /projekte
[I18n] > localize resources : projects
(fr) => /projets
[I18n] > localize resources : users
(de) => /benutzer
[I18n] > localize resources : users
(fr) => /membre
[I18n] > localize resources : projects
(en) => /projects
[I18n] > localize resources : projects
(de) => /projekte
[I18n] > localize resources : projects
(fr) => /projets
[I18n] > localize resources : users
(de) => /benutzer
[I18n] > localize resources : users
(fr) => /membre
something (/:locale)/something(.:format) {:locale=>/en|
de/, :action=>"index", :controller=>"projects"}
en_projects GET (/:locale)/projects(.:format)
{:i18n_locale=>"en", :locale=>/en|
de/, :action=>"index", :controller=>"projects"}
de_projects GET (/:locale)/projekte(.:format)
{:i18n_locale=>"de", :locale=>/en|
de/, :action=>"index", :controller=>"projects"}
fr_projects GET (/:locale)/projets(.:format)
{:i18n_locale=>"fr", :locale=>/en|
de/, :action=>"index", :controller=>"projects"}
projects GET (/:locale)/projects(.:format) {:locale=>/en|
de/, :action=>"index", :controller=>"projects"}
de_user GET (/:locale)/benutzer/:id(.:format)
{:i18n_locale=>"de", :locale=>/en|
de/, :action=>"show", :controller=>"users"}
fr_user GET (/:locale)/membre/:id(.:format)
{:i18n_locale=>"fr", :locale=>/en|
de/, :action=>"show", :controller=>"users"}
user GET (/:locale)/users/:id(.:format) {:locale=>/en|
de/, :action=>"show", :controller=>"users"}
root /(:locale)(.:format) {:locale=>/en|
de/, :controller=>"home", :action=>"index"}

Nico_Arbogast

unread,
Apr 1, 2011, 4:55:03 PM4/1/11
to I18n Routing
Hi,

I'm sorry I don't have time to dive into details tonight but have you
tried writing your something route without the ", :to =>", like this:

Multilang::Application.routes.draw do
>   scope "(:locale)", :locale => /en|de/ do
>     localized(I18n.available_locales, :verbose => true) do
>       match 'something' => 'projects#index', :as => 'something'
>       resources :projects, :only => [:index]
>       resources :users, :only => [:show]
>       root :to => 'home#index'
>     end
>   end
> end

Tell us if it works
Good luck
Nico

Chack

unread,
Apr 1, 2011, 5:48:26 PM4/1/11
to I18n Routing
Yes this did indeed fix it, cheers!

Guillaume Luccisano

unread,
Apr 1, 2011, 5:49:43 PM4/1/11
to i18n-r...@googlegroups.com, Chack
Great ! Good to know :)
Thanks Nico for the response !

2011/4/1 Chack <ch...@clan-fwd.com>

Nicolas Arbogast | Weezic.com

unread,
Apr 1, 2011, 6:14:58 PM4/1/11
to i18n-r...@googlegroups.com, Guillaume Luccisano, Chack
Great ! Happy to help !

2011/4/1 Guillaume Luccisano <guillaume...@gmail.com>
Reply all
Reply to author
Forward
0 new messages