Switchman for your i18n railroad.
This is a Rack middleware that redirects user from site root to language prefix. Preferred language of user is determined by HTTP header "Accept-Language". Otherwise first configured language will be used for redirecting.
Add this line to your application's Gemfile:
gem 'switchman'
And then execute:
$ bundle
Or install it yourself as:
$ gem install switchman
Connect Gem as Rack middleware.
- languages: - prioritized list of languages
- except: - prefixes that not be redirected. Useful for admin path
Add to your application.rb:
config.middleware.insert_after(
Rails::Rack::Logger,
Switchman::Middleware,
languages: %w(en ru), except: %w(admin)
)
Add to your sinatra application:
use Switchman::Middleware, languages: %(en ru), except: %w(admin)
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
- ???
- PROFIT!!!