Hi,
What kind of edition can we do to add a language parameter in thoses
routes:
ActionController::Routing::Routes.draw do |map|
map.resource :user_session
map.resources :users
map.resources :posts, :has_many => :comments
end
For example, if the current language is english,
http://localhost:3000/posts
should become:
http://localhost:3000/en/posts
And
http://localhost:3000/posts/1/comments/1
should become:
http://localhost:3000/en/posts/1/comments/1
If possible, this new parameter should not modify my current paths, such
as posts_path.
Thanks for any ideas!
Denis
In case you haven’t read this yet:
Tom
(Shameless self-promotion) You can also use my translate_routes plugin:
GitHub - raul/translate_routes: Rails plugin to translate your URLs and routing helpers on an clean way.
which not only adds a locale parameter and prefix:
http://localhost:3000/en/articles/1/comments/1
http://localhost:3000/es/articulos/1/comentarios/1
But also allows you to translate the static fragments of your routes,
improving your SEO performance. Your current xxxxx_path and xxxxx_url
helpers will be transparently converted to the current request’s
locale, so you just need to add a .yml translations file and one line
to your config/routes.rb.
Hope it helps!
–
Raul M. - Freelance Web D.
http://raul.murciano.net
On Sat, Sep 19, 2009 at 1:51 PM, Denis D.