Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The given example shows a locale with an underscore, but the code is splitting by dash. maybe it's better to split by both. Like:

parsed_locale.split(Regexp.new('-|_')).first


locale_available?(parsed_locale) ? parsed_locale.try(:to_sym) : nil
end
end
Expand Down