correctly follow the RFC 2616 language selection algorithm and then
revert to the previous way of selecting languages.
- I18n.locale = request.preferred_language_from(I18n.available_locales) ||
- request.compatible_language_from(I18n.available_locales)
- logger.info("Select #{I18n.locale} matching #{request.user_preferred_languages.join(',')} against #{I18n.available_locales.join(',')}")
+ I18n.locale = request.compatible_language_from(I18n.available_locales)
+
response.headers['Content-Language'] = I18n.locale.to_s
end
response.headers['Content-Language'] = I18n.locale.to_s
end
#
def compatible_language_from(array)
user_preferred_languages.map do |x|
#
def compatible_language_from(array)
user_preferred_languages.map do |x|
- x = x.to_s.split("-")[0]
- y.to_s.split("-")[0] == x
+ y.to_s =~ /^#{x.to_s}(-|$)/
end
end.compact.first
end
end
end.compact.first
end