diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index bded1cb3..5ce9657e 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -147,6 +147,7 @@ class ApplicationController < ActionController::Base session[:locale] = params[:locale] if params[:locale] browser_locale = condition = nil default_locale = condition = nil + backup_locale = condition = nil # check if locale is valid for non site pages if LIST[:forbidden_item_names].include?(env['PATH_INFO'].split('/')[1].to_s) @@ -161,9 +162,11 @@ 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)) + condition = @site.valid_locales.first end - session[:locale] = condition ? (browser_locale || session[:locale] || default_locale) : I18n.default_locale.to_s + session[:locale] = condition ? (browser_locale || session[:locale] || default_locale || backup_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 85f71f59..cc4525a7 100644 --- a/app/views/admin/items/_site_bar.html.erb +++ b/app/views/admin/items/_site_bar.html.erb @@ -14,7 +14,7 @@