How can I make Rails 3 router to localize url's using localization files?
Posted
by edgerunner
on Stack Overflow
See other posts from Stack Overflow
or by edgerunner
Published on 2010-04-08T15:41:29Z
Indexed on
2010/04/08
15:43 UTC
Read the original article
Hit count: 370
What I'd like to be able to do is:
in config/routes.rb
resources :posts
in config/locale/en.yml
en:
resources:
posts: "posts"
new: "new"
edit: "edit"
in config/locale/tr.yml
tr:
resources:
posts: "yazilar"
new: "yeni"
edit: "duzenle"
and get
I18n.locale = :en
edit_post_path(3) #=> /posts/3/edit
I18n.locale = :tr
edit_post_path(3) #=> /yazilar/3/duzenle
I'd also like rails to match any of these routes anytime and pass the associated locale in the params hash such that when I navigate to /yazilar , the request should be routed to the posts#index action.
Any simple way of doing that?
© Stack Overflow or respective owner