{}[http://badge.fury.io/rb/translatable_routes] {}[https://codeclimate.com/github/museways/translatable_routes] {}[https://travis-ci.org/museways/translatable_routes] {}[https://gemnasium.com/museways/translatable_routes]
= Translatable Routes
Minimalistic toolkit to translate routes.
= Install
Put this line in your Gemfile:
gem 'translatable_routes'
Then bundle:
$ bundle
= Usage
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"
(There is no need to put the full path "users/1/profile", just translate each slug individually)
Helpers will continue working the same but I18n.locale will be use as default locale:
about_path # /en/about in case I18n.locale is :en
This gem will not provide a default locale selection, since you may be interested in differente types of logics, you should add it manually. Here it's a very simple example:
before_action :select_locale
protected
def select_locale
I18n.locale = params[:locale]
end