# Sets the user languages preference, overiding the browser
#
def user_preferred_languages=(languages)
- @user_preferred_languages = languages.join(",")
+ @user_preferred_languages = languages
end
# Finds the locale specifically requested by the browser.
#
def compatible_language_from(array)
user_preferred_languages.map do |x|
- x = x.to_s.split("-")[0]
array.find do |y|
- y.to_s.split("-")[0] == x
+ y.to_s =~ /^#{Regexp.escape(x.to_s)}(-|$)/
end
end.compact.first
end