From 050f2dedffa345e765bf6c4efa79976643959e59 Mon Sep 17 00:00:00 2001 From: saurabhbhatia Date: Mon, 9 Dec 2013 12:37:52 +0800 Subject: [PATCH] Fixed browser locale issue occuring due to zh --- app/controllers/application_controller.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 275d854b..b137fd23 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -158,10 +158,14 @@ class ApplicationController < ActionController::Base elsif (@site.default_locale.present? && @site.enable_language_detection.eql?(false)) default_locale = @site.default_locale condition = @site.in_use_locales.include?(default_locale) - elsif (@site.enable_language_detection.eql?(true)) + elsif (@site.enable_language_detection.eql?(true) && @site.default_locale.nil?) #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) + if browser_locale.eql?("zh") + condition = @site.in_use_locales.include?("zh_tw") + else + condition = @site.in_use_locales.include?(browser_locale) + end 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)