diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0b8ab3e3..4b2a310b 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -162,9 +162,9 @@ class ApplicationController < ActionController::Base #check enable langauge detection browser_locale = request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first rescue nil condition = @site.in_use_locales.include?(browser_locale) - elsif (@site.default_locale.nil? && @site.enable_language_detection.eql?(false) && session[:locale].nil?) - session[:locale] = @site.valid_locales.first - condition = @site.in_use_locales.include?(params[:locale]) + elsif (@site.default_locale.nil? && @site.enable_language_detection.eql?(false)) + backup_locale = @site.valid_locales.first + condition = @site.in_use_locales.include?(backup_locale) end session[:locale] = condition ? ( session[:locale] || default_locale || browser_locale || backup_locale) : I18n.default_locale.to_s