Arnau Sanchez
unread,Sep 15, 2011, 1:11:17 PM9/15/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to I18n Routing
Hi,
After some time using translate_routes I am giving i18n_routing a try.
I'd like to get routes that look like this:
/route1
/route2
/es/ruta1
/es/ruta2
That's it, the default locale has no locale scope while all the others
language have (that's how translate_routes does it and I think it's
very pretty nice). So, with i18n_routing that's what I got so far
(trying to be DRY, repeating the routes is out of the question):
XYZ::Application.routes.draw do
localizable_routes = proc do
# routes here
end
localizable_routes.call
locales = (I18n.available_locales-[I18n.default_locale])
localized locales do
scope "/:i18n_locale", :constraints => {:i18n_locale =>
Regexp.new(locales.join('|')}) do
localizable_routes.call
end
end
end
Is there are better way or it's ok?