diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 1b87254bb..b959d85c9 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -146,17 +146,18 @@ class ApplicationController < ActionController::Base if LIST[:forbidden_item_names].include?(env['PATH_INFO'].split('/')[1].to_s) condition = VALID_LOCALES.include?(session[:locale]) #check if the default locale is present or not - elsif @site.default_locale.present? - default_locale = @site.default_locale - condition = @site.in_use_locales.include?(default_locale) - elsif !@site.enable_language_detection + elsif session[:locale] + condition = @site.in_use_locales.include?(session[:locale]) + elsif @site.enable_language_detection #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 session[:locale] - condition = @site.in_use_locales.include?(session[:locale]) + elsif @site.default_locale.present? + default_locale = @site.default_locale + condition = @site.in_use_locales.include?(default_locale) end - session[:locale] = condition ? (default_locale || browser_locale || session[:locale]) : I18n.default_locale.to_s + + session[:locale] = condition ? (browser_locale || session[:locale] || default_locale) : I18n.default_locale.to_s I18n.locale = session[:locale].to_sym @site_in_use_locales = @site.in_use_locales @site_valid_locales = site_locales_default_head(@site.valid_locales) diff --git a/app/views/admin/items/_site_bar.html.erb b/app/views/admin/items/_site_bar.html.erb index 0a83994bd..1397a3d4a 100644 --- a/app/views/admin/items/_site_bar.html.erb +++ b/app/views/admin/items/_site_bar.html.erb @@ -1,14 +1,3 @@ - - \ No newline at end of file diff --git a/app/views/admin/sites/_side_bar.html.erb b/app/views/admin/sites/_side_bar.html.erb index 5ddb07e5c..9ab39fa41 100644 --- a/app/views/admin/sites/_side_bar.html.erb +++ b/app/views/admin/sites/_side_bar.html.erb @@ -21,6 +21,6 @@ +
- \ No newline at end of file diff --git a/app/views/admin/sites/preference.html.erb b/app/views/admin/sites/preference.html.erb index eec4f860e..cbcc290d1 100644 --- a/app/views/admin/sites/preference.html.erb +++ b/app/views/admin/sites/preference.html.erb @@ -121,14 +121,14 @@