{}[https://codeclimate.com/github/mattways/translatable_routes] {}[https://travis-ci.org/mattways/translatable_routes] {}[https://gemnasium.com/mattways/translatable_routes]
= Translatable Routes
Minimalistic toolkit to handle translatable routes and detect locale from subdomain or prefix.
= Install
Put this line in your Gemfile:
gem 'translatable_routes'
Then bundle:
$ bundle
= Usage
Choose how the language would be selected in your application.rb:
To use prefix (default):
config.translatable_routes.selection = :prefix
To use subdomain:
config.translatable_routes.selection = :subdomain
config.translatable_routes.mapping = {
es: [:ar, :uy]
pt: [:br]
}
In the case of subdomains you need to name the yml file in your locales dir using this format:
es-UY.yml
es-AR.yml
pt-BR.yml
Inside each yaml file:
es-UY:
routes:
users: "usuarios"
profile: "perfil"
login: "entrar"
(Please note each part of the path it's translated individually, you don't have to put translations for paths like "users/1/profile" just translate "users" and "profile", the plugin will do the rest)
Finally in your routes.rb pass the routes you want to be localized to localize method:
localized do
get 'contact', to: 'static#contact', as: 'contact'
end