Skip to content

Instantly share code, notes, and snippets.

@lunks
Last active August 29, 2015 14:05
Show Gist options
  • Save lunks/187a2c0f7a0db593e22e to your computer and use it in GitHub Desktop.
Save lunks/187a2c0f7a0db593e22e to your computer and use it in GitHub Desktop.
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_filter :set_locale
private
def set_locale
if params[:locale]
I18n.locale = params[:locale]
session[:locale] = params[:locale]
elsif session[:locale]
I18n.locale = session[:locale]
else
I18n.locale = http_accept_language
.compatible_language_from(I18n.available_locales)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment