From f8cc1f6d009c3eb56a394ec05c85171de5f40947 Mon Sep 17 00:00:00 2001 From: Joan Date: Fri, 7 Aug 2015 15:02:55 +0200 Subject: [PATCH] locales with countries like en_GB or or en_US have the langauge at locale.split('-').first --- .../templates/cms/app/controllers/concerns/localizify.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/generators/foxinator/setup/templates/cms/app/controllers/concerns/localizify.rb b/lib/generators/foxinator/setup/templates/cms/app/controllers/concerns/localizify.rb index 3205613..2cd4a3a 100644 --- a/lib/generators/foxinator/setup/templates/cms/app/controllers/concerns/localizify.rb +++ b/lib/generators/foxinator/setup/templates/cms/app/controllers/concerns/localizify.rb @@ -79,8 +79,8 @@ def accept_locale if request.env['HTTP_ACCEPT_LANGUAGE'].present? parsed_locale = request.env['HTTP_ACCEPT_LANGUAGE'].gsub(/\s+/, '').split(',').first parsed_locale = parsed_locale.scan(/^[a-z]{2}-[a-z]{2}|[a-z]{2}/i).first if parsed_locale - parsed_locale = parsed_locale.split('-').last.try(:downcase).try(:to_sym) if parsed_locale - + parsed_locale = parsed_locale.split('-').first.try(:downcase).try(:to_sym) if parsed_locale + locale_available?(parsed_locale) ? parsed_locale.try(:to_sym) : nil end end