This commit is contained in:
2015-07-12 09:44:32 +02:00
2 changed files with 11 additions and 4 deletions

View File

@@ -1,19 +1,24 @@
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :set_i18n_locale_from_params
protected
theme :get_theme
def set_i18n_locale_from_params
if params[:locale]
if I18n.available_locales.include?(params[:locale].to_sym)
I18n.locale=params[:locale].to_sym
session[:locale] = params[:locale]
else
flash.now[:notice]= "#{params[:locale]} translation not available"
logger.error flash.now[:notice]
end
else
I18n.locale = session[:locale] || :de
end
I18n.locale = session[:locale] || request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^de|en/).first || I18n.default_locale
session[:locale] = I18n.locale
end

View File

@@ -95,7 +95,9 @@ class HomeController < ApplicationController
end
end
def language
redirect_to request.referer || root_path
redirect_to :back
rescue ActionController::RedirectBackError
redirect_to :root
end
def choose_contact_topics
authorize! :doadmin, User