ruby on rails - I18n_routing, empty path + nested resource -


i have rails website using gem i18n_routing. have path such this:

domain.com/<place>/bookings 

where place "new-york". goal routes translated this:

domain.com/<place>/bokningar 

i trying translate through i18n_routing so:

  resources :places, :path => '', :except => [:index, :create, :new]      #resources :flight_pages, :path => 'flyg', :only => [:show, :index]     #resources :hotel_pages, :path => 'hotell', :only => [:show, :index]         localized       resources :bookings, :except => [:edit, :update]         :get_method_desc, :on => :collection         :get_image_path, :on => :collection             end     end       :autocomplete_place_name, :on => :collection        end    localized     resources :places, :only => [:index, :create, :new]   end 

with translation file this:

  resources:      places: 'plats'     bookings: 'bokningar' 

i run problem if have above, i18n_routing not recognize "bookings" need translated.

if change setup put localized outside whole resoure:

    localized   resources :places, :path => '', :except => [:index, :create, :new]      #resources :flight_pages, :path => 'flyg', :only => [:show, :index]     #resources :hotel_pages, :path => 'hotell', :only => [:show, :index]            resources :bookings, :except => [:edit, :update]         :get_method_desc, :on => :collection         :get_image_path, :on => :collection             end      :autocomplete_place_name, :on => :collection        end     end   localized     resources :places, :only => [:index, :create, :new]   end 

i empty path "places" translated route turns into:

domain.com/plats/<place>/bokningar 

i tried set places: "" in translation file i18n_routing skips it.

what should translation this:

domain.com/<place>/bokningar (:se) domain.com/<place>/bookings (:en) 

i.e. keeping empty path , translated nested resource "bookings"?

edit in response aman garg: paths use these are

new_place_booking_path(@place) #=> domain.com/<place>/bookings/new place_bookings_path(@place) #=> domain.com/<place>/bookings 

there gem providing dynamic translated routes according language. generate url on basis of locale i18n. there easy implementation this:

https://github.com/francesc/rails-translate-routes

follow steps mentioned in documention on github. can define translations route in yml files. e.g: in config/locales/routes.yml

en:   routes:     # can leave empty locales, example default 1 se:   routes:     places: 'plats'     bookings: 'bokningar' 

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -