Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

app.new_user_session_path(locale: I18n.locale) should read "/es/users/sign_in", not "/users/sign_in?locale=es" #6

tute opened this Issue · 5 comments

2 participants

Tute Costa Enric Lluelles
Tute Costa

Like your gem, and finding many issues while implementing it. How can we make app.new_user_session_path(locale: I18n.locale) generate /es/users/sign_in instead of /users/sign_in?locale=es?

Thank you again.

Enric Lluelles

When route_translator adds the locale parameter to url hashes(which is why url_for uses for the matching) it adds the locale parameter as a string instead of a symbol. Running rake routes will show you what I'm talking about. And I18n.locale outputs a symbol

So, you should do:

    app.new_user_session_path(locale: I18n.locale.to_s)

I know that right now this is a bit cumbersome but I've yet to find a workaround for this. You're welcome to try :)

Tute Costa

Thank you @enriclluelles. However it doesn't change the behaviour:

> app.new_user_session_path(locale: :en)
 => "/users/sign_in?locale=en" 
> app.new_user_session_path(locale: 'en')
 => "/users/sign_in?locale=en" 

More over, if all URL helpers are trapped by route_translator we may be able to normalize parameters before actually building the URL, right? In that case I'll be able to help. :-)

Enric Lluelles

This is weird... Can you show me the routes.rb file so I can investigate?

Tute Costa

Oh, seems like it has to do with devise. Built a minimal application with following routes.rb file:

TranslateDeviseRoutes::Application.routes.draw do
  localized do
    devise_for :users, controllers: { sessions: 'sessions' }
    root :to => 'sessions#new'

And rake routes shows:

        new_user_session GET    /users/sign_in(.:format)       sessions#new
            user_session POST   /users/sign_in(.:format)       sessions#create
    destroy_user_session DELETE /users/sign_out(.:format)      sessions#destroy
           user_password POST   /users/password(.:format)      devise/passwords#create
       new_user_password GET    /users/password/new(.:format)  devise/passwords#new
      edit_user_password GET    /users/password/edit(.:format) devise/passwords#edit
                         PUT    /users/password(.:format)      devise/passwords#update
cancel_user_registration GET    /users/cancel(.:format)        devise/registrations#cancel
       user_registration POST   /users(.:format)               devise/registrations#create
   new_user_registration GET    /users/sign_up(.:format)       devise/registrations#new
  edit_user_registration GET    /users/edit(.:format)          devise/registrations#edit
                         PUT    /users(.:format)               devise/registrations#update
                         DELETE /users(.:format)               devise/registrations#destroy
                    root        /                              sessions#new

I guess I'll have to route without using devise_for block?


Enric Lluelles
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.