Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
32 lines (21 sloc) 1.1 KB

Rack::LocaleSelector is designed to provided locale detection settings through the middleware stack with I18n.

The behaviour is quite similar to google's locale settings: It tries first to fetch locale value from URI, cookie, HTTP_LANGUAGE_HEADERS or fallback to I18n default's value.

Rack::LocaleSelector sets the I18n.locale to the matching value or redirects the user to the proper locale in URI, here is how redirection work: (with cookie set to :fr) => (with HTTP_ACCEPT_HEADERS set to :fr) =>

tricky ones: (with cookie set to :fr) => (sets a cookie to :es)

You can choose to not use locale as subdomain but as a value in URI ( by setting :use_subdomain to false


script/plugin install git:// 

# config/environments/development.rb
config.middleware.use "Rack::LocaleSelector"

 :white_list # Buggy
 :black_list # Buggy

Thanks to: