app/controllers/alchemy/base_controller.rb in alchemy_cms-2.4.1 vs app/controllers/alchemy/base_controller.rb in alchemy_cms-2.5.0.b2

- old
+ new

@@ -4,10 +4,11 @@ include Alchemy::Modules protect_from_forgery + before_filter :set_current_site before_filter :set_language before_filter :mailer_set_url_options helper_method :current_server, :t @@ -43,10 +44,15 @@ ::Alchemy::I18n.t(key, *args) end private + # Sets the current site. + def set_current_site + Site.current = Site.where(host: request.host).first || Site.default + end + # Sets Alchemy's GUI translation to users preffered language and stores it in the session. # # Guesses the language from browser locale. If not successful it takes the default. # # You can set the default translation in your +config/application.rb+ file, via Rails +default_locale+ config option. @@ -58,9 +64,11 @@ ::I18n.locale = session[:current_locale] elsif params[:locale].present? && ::I18n.available_locales.include?(params[:locale].to_sym) session[:current_locale] = ::I18n.locale = params[:locale] elsif current_user && current_user.language.present? ::I18n.locale = current_user.language + elsif Rails.env == 'test' # OMG I hate to do this. But it helps... + ::I18n.locale = 'en' else ::I18n.locale = request.env['HTTP_ACCEPT_LANGUAGE'].try(:scan, /^[a-z]{2}/).try(:first) end end