Minimalistic toolkit to translate routes in rails.
Put this line in your Gemfile:
gem 'translatable_routes'
Then bundle:
$ bundle
In your config/routes.rb use the localized method to decide wich routes will be localized:
localized do
get 'about' => 'pages#about'
end
Put your translations inside the routes key in your locales yamls:
es:
routes:
users: "usuarios"
profile: "perfil"
about: "nosotros"
NOTE: There is no need to put the full path, just translate each part individually.
Helpers will continue working the same but I18n.locale will be use as default locale:
about_path # Will output /en/about in case I18n.locale is :en
Here is an example of what you may want to add to your controllers to select the current locale:
before_action :select_locale
protected
def select_locale
I18n.locale = params[:locale]
end
This gem is maintained and funded by museways.
It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.