X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/53b4d645d80cbe4ac397cfc004e8985317aed6a8..dc35b597a2210d77e3d3e6996138dfdeb3add4a3:/vendor/plugins/http_accept_language/lib/http_accept_language.rb diff --git a/vendor/plugins/http_accept_language/lib/http_accept_language.rb b/vendor/plugins/http_accept_language/lib/http_accept_language.rb index bf34935d4..1266a3e64 100644 --- a/vendor/plugins/http_accept_language/lib/http_accept_language.rb +++ b/vendor/plugins/http_accept_language/lib/http_accept_language.rb @@ -22,6 +22,12 @@ module HttpAcceptLanguage [] end + # Sets the user languages preference, overiding the browser + # + def user_preferred_languages=(languages) + @user_preferred_languages = languages + end + # Finds the locale specifically requested by the browser. # # Example: @@ -42,9 +48,8 @@ module HttpAcceptLanguage # 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