I have a multi-language website and I'm puting the language in the URL like domain.com/en/. When the user doesn't put the language in the URL I want to redirect him to the page in the main language like "domain.com/posts" to "domain.com/en/posts". Is there an easy way to do this with Sinatra?
I have more than one hundred routes. So doing this for every route is not a very good option.
get "/:locale/posts" do... end
get "/posts" do... end
Can someone help me?
Thanks
Use a before filter, somewhat like this:
With the upcoming release of Sinatra, you will be able to do this: