title: Rails routes based on locale
body: <p>I'm working on a multilingual rails app and I need the routes to be different for each locale. It's difficult to explain it like this for me, so I'll use an example:</p>
  
  <ul>
  <li>en: /en/pricing</li>
  <li>es: /es/precios</li>
  </ul>
  
  <p>I found this answer: <a href="https://stackoverflow.com/questions/20469439/rails-4-i18n-how-to-translate-routes-where-subdomain-is-used-for-the-locale">Rails 4 i18n, how to translate routes where subdomain is used for the locale</a></p>
  
  <p>Therefore my routes.rb looks like this:</p>
  
  <pre><code>scope "/:locale" do            
    get "/", to: "pages#index", as: "index"
    get "/#{I18n.t("pricing")}", :to =&gt; "pages#pricing", :as =&gt; "pricing"
  end
  </code></pre>
  
  <p>I'm also using <code>AppName::Application.reload_routes!</code> on app loading (application controller before_action), but just right after a locale change the rest of URI after /locale stays the same - that makes a problem when user tries to reload the page because that is non-existent any more. Other clicks are okay, with new locale URIs.</p>
  
  <p>I'm thinking of a system to find out whether my current URI is the correct one and if not, redirect it there, but I think this is suboptimal. Do you have any suggestions?</p>
  
  <p>Thank you in advance.</p>