-
-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support of i18n engines paths with route_translator gem #51
base: master
Are you sure you want to change the base?
Conversation
Can you show us some example how to translate routes in engines now? |
Of course @simi :) # config/routes.rb of refinerycms-inquiries engine
Refinery::Core::Engine.routes.draw do
# Frontend routes
namespace :inquiries, :path => '' do
localized do
get Refinery::Inquiries.page_path_new, :to => 'inquiries#new', :as => 'new_inquiry'
resources :contact, :path => Refinery::Inquiries.post_path, :only => [:create],
:as => :inquiries, :controller => 'inquiries'
resources :contact, :path => '', :only => [], :as => :inquiries, :controller => 'inquiries' do
get :thank_you, :path => Refinery::Inquiries.page_path_thank_you, :on => :collection
end
end
end
# Admin routes
namespace :inquiries, :path => '' do
namespace :admin, :path => Refinery::Core.backend_route do
resources :inquiries, :only => [:index, :show, :destroy] do
get :spam, :on => :collection
get :toggle_spam, :on => :member
end
scope :path => 'inquiries' do
resources :settings, :only => [:edit, :update]
end
end
end
end # config/locales/en.yml of refinerycms-inquiries engine
en:
routes:
contact: contact-us
thank_you: thank-you # config/locales/fr.yml of refinerycms-inquiries engine
fr:
routes:
contact: nous-joindre
thank_you: merci with this approach, we have to require refinerycms-i18n in every engine we localized, it would be better if we could test if this method exist or not. With route_translator, we doesn't need custom paths like I don't want to translate admin paths, i prefer to have the same admins paths on every refinerycms sites |
At this time, i can do this : # config/routes.rb of refinerycms-inquiries engine
Refinery::Core::Engine.routes.draw do
# Frontend routes
namespace :inquiries, :path => '' do
def routes
get Refinery::Inquiries.page_path_new, :to => 'inquiries#new', :as => 'new_inquiry'
resources :contact, :path => Refinery::Inquiries.post_path, :only => [:create],
:as => :inquiries, :controller => 'inquiries'
resources :contact, :path => '', :only => [], :as => :inquiries, :controller => 'inquiries' do
get :thank_you, :path => Refinery::Inquiries.page_path_thank_you, :on => :collection
end
end
if defined? localized
localized do
routes
end
else
routes
end
end
# Admin routes
namespace :inquiries, :path => '' do
namespace :admin, :path => Refinery::Core.backend_route do
resources :inquiries, :only => [:index, :show, :destroy] do
get :spam, :on => :collection
get :toggle_spam, :on => :member
end
scope :path => 'inquiries' do
resources :settings, :only => [:edit, :update]
end
end
end
end With this approach, it works and there is no need to require refinerycms-i18n in the refinerycms-inquiries gem, it's a small change in the code base, but it's not the nicer code... any idea ? help ? |
Can you post rake routes? I think if you're doing this outside inquiry gem, you're defining routes twice. |
I'm always in config/routes.rb of inquiries Routes for Refinery::Core::Engine:
wymiframe GET /wymiframe(/:id)(.:format) refinery/fast#wymiframe
fans_fans GET /fans(.:format) refinery/fans/fans#index
fans_fan GET /fans/:id(.:format) refinery/fans/fans#show
update_positions_fans_admin_fans POST /refinery/fans/update_positions(.:format) refinery/fans/admin/fans#update_positions
fans_admin_fans GET /refinery/fans(.:format) refinery/fans/admin/fans#index
POST /refinery/fans(.:format) refinery/fans/admin/fans#create
new_fans_admin_fan GET /refinery/fans/new(.:format) refinery/fans/admin/fans#new
edit_fans_admin_fan GET /refinery/fans/:id/edit(.:format) refinery/fans/admin/fans#edit
fans_admin_fan PATCH /refinery/fans/:id(.:format) refinery/fans/admin/fans#update
PUT /refinery/fans/:id(.:format) refinery/fans/admin/fans#update
DELETE /refinery/fans/:id(.:format) refinery/fans/admin/fans#destroy
copywriting_admin_phrases GET /refinery/copywriting/phrases(.:format) refinery/copywriting/admin/phrases#index
edit_copywriting_admin_phrase GET /refinery/copywriting/phrases/:id/edit(.:format) refinery/copywriting/admin/phrases#edit
copywriting_admin_phrase PATCH /refinery/copywriting/phrases/:id(.:format) refinery/copywriting/admin/phrases#update
PUT /refinery/copywriting/phrases/:id(.:format) refinery/copywriting/admin/phrases#update
DELETE /refinery/copywriting/phrases/:id(.:format) refinery/copywriting/admin/phrases#destroy
inquiries_new_inquiry_en GET /contact-us(.:format) refinery/inquiries/inquiries#new {:locale=>"en"}
inquiries_new_inquiry_fr GET /nous-joindre(.:format) refinery/inquiries/inquiries#new {:locale=>"fr"}
inquiries_inquiries_en POST /contact-us(.:format) refinery/inquiries/inquiries#create {:locale=>"en"}
inquiries_inquiries_fr POST /nous-joindre(.:format) refinery/inquiries/inquiries#create {:locale=>"fr"}
thank_you_inquiries_inquiries_en GET /contact-us/thank-you(.:format) refinery/inquiries/inquiries#thank_you {:locale=>"en"}
thank_you_inquiries_inquiries_fr GET /nous-joindre/merci(.:format) refinery/inquiries/inquiries#thank_you {:locale=>"fr"}
spam_inquiries_admin_inquiries GET /refinery/inquiries/spam(.:format) refinery/inquiries/admin/inquiries#spam
toggle_spam_inquiries_admin_inquiry GET /refinery/inquiries/:id/toggle_spam(.:format) refinery/inquiries/admin/inquiries#toggle_spam
inquiries_admin_inquiries GET /refinery/inquiries(.:format) refinery/inquiries/admin/inquiries#index
inquiries_admin_inquiry GET /refinery/inquiries/:id(.:format) refinery/inquiries/admin/inquiries#show
DELETE /refinery/inquiries/:id(.:format) refinery/inquiries/admin/inquiries#destroy
edit_inquiries_admin_setting GET /refinery/inquiries/settings/:id/edit(.:format) refinery/inquiries/admin/settings#edit
inquiries_admin_setting PATCH /refinery/inquiries/settings/:id(.:format) refinery/inquiries/admin/settings#update
PUT /refinery/inquiries/settings/:id(.:format) refinery/inquiries/admin/settings#update
admin_settings GET /refinery/settings(.:format) refinery/admin/settings#index
POST /refinery/settings(.:format) refinery/admin/settings#create
new_admin_setting GET /refinery/settings/new(.:format) refinery/admin/settings#new
edit_admin_setting GET /refinery/settings/:id/edit(.:format) refinery/admin/settings#edit
admin_setting PATCH /refinery/settings/:id(.:format) refinery/admin/settings#update
PUT /refinery/settings/:id(.:format) refinery/admin/settings#update
DELETE /refinery/settings/:id(.:format) refinery/admin/settings#destroy
root GET / refinery/pages#home
page GET /pages/:id(.:format) refinery/pages#show
pages_admin_preview_pages POST /refinery/pages/preview(.:format) refinery/pages/admin/preview#show
pages_admin_preview_page PATCH /refinery/pages/preview/*path(.:format) refinery/pages/admin/preview#show
admin_edit_page GET /refinery/pages/*path/edit(.:format) refinery/admin/pages#edit
admin_children_pages GET /refinery/pages/*path/children(.:format) refinery/admin/pages#children
admin_update_page PATCH /refinery/pages/*path(.:format) refinery/admin/pages#update
admin_delete_page DELETE /refinery/pages/*path(.:format) refinery/admin/pages#destroy
update_positions_admin_pages POST /refinery/pages/update_positions(.:format) refinery/admin/pages#update_positions
admin_pages GET /refinery/pages(.:format) refinery/admin/pages#index
POST /refinery/pages(.:format) refinery/admin/pages#create
new_admin_page GET /refinery/pages/new(.:format) refinery/admin/pages#new
edit_admin_page GET /refinery/pages/:id/edit(.:format) refinery/admin/pages#edit
admin_page PATCH /refinery/pages/:id(.:format) refinery/admin/pages#update
PUT /refinery/pages/:id(.:format) refinery/admin/pages#update
DELETE /refinery/pages/:id(.:format) refinery/admin/pages#destroy
link_to_admin_pages_dialogs GET /refinery/pages_dialogs/link_to(.:format) refinery/admin/pages_dialogs#link_to
admin_page_parts POST /refinery/page_parts(.:format) refinery/admin/page_parts#create
new_admin_page_part GET /refinery/page_parts/new(.:format) refinery/admin/page_parts#new
admin_page_part DELETE /refinery/page_parts/:id(.:format) refinery/admin/page_parts#destroy
GET /system/resources/*dragonfly(.:format) <Dragonfly::App name=:refinery_resources >
insert_admin_resources GET /refinery/resources/insert(.:format) refinery/admin/resources#insert
admin_resources GET /refinery/resources(.:format) refinery/admin/resources#index
POST /refinery/resources(.:format) refinery/admin/resources#create
new_admin_resource GET /refinery/resources/new(.:format) refinery/admin/resources#new
edit_admin_resource GET /refinery/resources/:id/edit(.:format) refinery/admin/resources#edit
admin_resource PATCH /refinery/resources/:id(.:format) refinery/admin/resources#update
PUT /refinery/resources/:id(.:format) refinery/admin/resources#update
DELETE /refinery/resources/:id(.:format) refinery/admin/resources#destroy
GET /system/images/*dragonfly(.:format) <Dragonfly::App name=:refinery_images >
insert_admin_images GET /refinery/images/insert(.:format) refinery/admin/images#insert
admin_images GET /refinery/images(.:format) refinery/admin/images#index
POST /refinery/images(.:format) refinery/admin/images#create
new_admin_image GET /refinery/images/new(.:format) refinery/admin/images#new
edit_admin_image GET /refinery/images/:id/edit(.:format) refinery/admin/images#edit
admin_image PATCH /refinery/images/:id(.:format) refinery/admin/images#update
PUT /refinery/images/:id(.:format) refinery/admin/images#update
DELETE /refinery/images/:id(.:format) refinery/admin/images#destroy
login GET /refinery/login(.:format) refinery/sessions#new
logout GET /refinery/logout(.:format) refinery/sessions#destroy
new_signup GET /refinery/users/register(.:format) refinery/users#new
signup POST /refinery/users/register(.:format) refinery/users#create
new_refinery_user_session GET /refinery/users/login(.:format) refinery/sessions#new
refinery_user_session POST /refinery/users/login(.:format) refinery/sessions#create
destroy_refinery_user_session DELETE /refinery/users/logout(.:format) refinery/sessions#destroy
refinery_user_password POST /refinery/users/password(.:format) refinery/passwords#create
new_refinery_user_password GET /refinery/users/password/new(.:format) refinery/passwords#new
edit_refinery_user_password GET /refinery/users/password/edit(.:format) refinery/passwords#edit
PATCH /refinery/users/password(.:format) refinery/passwords#update
PUT /refinery/users/password(.:format) refinery/passwords#update
admin_users GET /refinery/users(.:format) refinery/admin/users#index
POST /refinery/users(.:format) refinery/admin/users#create
new_admin_user GET /refinery/users/new(.:format) refinery/admin/users#new
edit_admin_user GET /refinery/users/:id/edit(.:format) refinery/admin/users#edit
admin_user PATCH /refinery/users/:id(.:format) refinery/admin/users#update
PUT /refinery/users/:id(.:format) refinery/admin/users#update
DELETE /refinery/users/:id(.:format) refinery/admin/users#destroy
message GET /refinery/message(.:format) refinery/fast#message
admin_root GET /refinery(.:format) refinery/admin/core#index
admin_dialogs GET /refinery/dialogs(.:format) refinery/admin/dialogs#index
admin_dialog GET /refinery/dialogs/:id(.:format) refinery/admin/dialogs#show
refinery_update_menu_positions POST /refinery/update_menu_positions(.:format) refinery/admin/core#update_plugin_positions
GET /sitemap.xml(.:format) refinery/sitemap#index {:format=>"xml"}
GET /refinery/*path(.:format) refinery/admin#error_404
marketable_page GET /*path(.:format) refinery/pages#show |
Hello all !
I've to develop multi languages refinerycms websites. When i use or create an engine, the path is hardcoded and non translated.
I would like to add support of route_translator in this engine and to make change on every engines we could use with multi languages (inquiries, blog, ...)
Could we use this approach or to find a better?