Fixed browser locale issue occuring due to zh

This commit is contained in:
saurabhbhatia 2013-12-09 12:37:52 +08:00
parent b1936fcae9
commit 050f2dedff
1 changed files with 6 additions and 2 deletions

View File

@ -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)