forked from bofh/fetsite
fix locale 2
This commit is contained in:
@@ -1,19 +1,24 @@
|
|||||||
class ApplicationController < ActionController::Base
|
class ApplicationController < ActionController::Base
|
||||||
protect_from_forgery
|
protect_from_forgery
|
||||||
before_filter :set_i18n_locale_from_params
|
before_filter :set_i18n_locale_from_params
|
||||||
|
|
||||||
protected
|
protected
|
||||||
theme :get_theme
|
theme :get_theme
|
||||||
|
|
||||||
def set_i18n_locale_from_params
|
def set_i18n_locale_from_params
|
||||||
if params[:locale]
|
if params[:locale]
|
||||||
if I18n.available_locales.include?(params[:locale].to_sym)
|
if I18n.available_locales.include?(params[:locale].to_sym)
|
||||||
I18n.locale=params[:locale].to_sym
|
session[:locale] = params[:locale]
|
||||||
|
|
||||||
else
|
else
|
||||||
flash.now[:notice]= "#{params[:locale]} translation not available"
|
flash.now[:notice]= "#{params[:locale]} translation not available"
|
||||||
logger.error flash.now[:notice]
|
logger.error flash.now[:notice]
|
||||||
|
|
||||||
end
|
end
|
||||||
else
|
|
||||||
I18n.locale = session[:locale] || :de
|
|
||||||
end
|
end
|
||||||
|
I18n.locale = session[:locale] || request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^de|en/).first || I18n.default_locale
|
||||||
|
|
||||||
|
|
||||||
session[:locale] = I18n.locale
|
session[:locale] = I18n.locale
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,9 @@ class HomeController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
def language
|
def language
|
||||||
redirect_to request.referer || root_path
|
redirect_to :back
|
||||||
|
rescue ActionController::RedirectBackError
|
||||||
|
redirect_to :root
|
||||||
end
|
end
|
||||||
def choose_contact_topics
|
def choose_contact_topics
|
||||||
authorize! :doadmin, User
|
authorize! :doadmin, User
|
||||||
|
|||||||
Reference in New Issue
Block a user