Last active
December 24, 2015 23:48
-
-
Save coop/6882489 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/routes.rb | |
get '/:country/welcome' => 'welcome#show' | |
# app/controllers/welcome_controller.rb | |
class WelcomeController < ApplicationController | |
around_filter :set_preferred_locale | |
private | |
def set_preferred_locale | |
I18n.locale = header_locale || params.fetch(:country, I18n.default_locale) | |
end | |
def header_locale | |
headers['Accept-Language'] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment