Fix compatible_language_from in the http_accept_language plugin to
correctly follow the RFC 2616 language selection algorithm and then revert to the previous way of selecting languages.
This commit is contained in:
parent
1368f194da
commit
25d0017b18
2 changed files with 3 additions and 5 deletions
|
@ -110,9 +110,8 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
I18n.locale = request.preferred_language_from(I18n.available_locales) ||
|
I18n.locale = request.compatible_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(',')}")
|
|
||||||
response.headers['Content-Language'] = I18n.locale.to_s
|
response.headers['Content-Language'] = I18n.locale.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -48,9 +48,8 @@ module HttpAcceptLanguage
|
||||||
#
|
#
|
||||||
def compatible_language_from(array)
|
def compatible_language_from(array)
|
||||||
user_preferred_languages.map do |x|
|
user_preferred_languages.map do |x|
|
||||||
x = x.to_s.split("-")[0]
|
|
||||||
array.find do |y|
|
array.find do |y|
|
||||||
y.to_s.split("-")[0] == x
|
y.to_s =~ /^#{x.to_s}(-|$)/
|
||||||
end
|
end
|
||||||
end.compact.first
|
end.compact.first
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue