From e62f91d3fdb2a2f865a62fc22a685bc613f06718 Mon Sep 17 00:00:00 2001 From: saurabhbhatia Date: Fri, 22 Nov 2013 17:14:47 +0800 Subject: [PATCH] Sub Menu and Language Fix --- app/controllers/application_controller.rb | 10 +++++----- app/views/front/show_page_sub_menu.html.erb | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 18f33a2c0..a950b9353 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -153,15 +153,15 @@ 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 session[:locale] - condition = @site.in_use_locales.include?(session[:locale]) + elsif params[:locale] + condition = @site.in_use_locales.include?(params[:locale]) + elsif @site.default_locale.present? + default_locale = @site.default_locale + condition = @site.in_use_locales.include?(default_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 @site.default_locale.present? - default_locale = @site.default_locale - condition = @site.in_use_locales.include?(default_locale) end session[:locale] = condition ? (browser_locale || session[:locale] || default_locale) : I18n.default_locale.to_s diff --git a/app/views/front/show_page_sub_menu.html.erb b/app/views/front/show_page_sub_menu.html.erb index 58b1ceaa7..bb6d3d9f3 100644 --- a/app/views/front/show_page_sub_menu.html.erb +++ b/app/views/front/show_page_sub_menu.html.erb @@ -14,7 +14,7 @@