You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

19 lines
409 B

class SiteController < ApplicationController
def index
language = parse_accept_language(request.env['HTTP_ACCEPT_LANGUAGE'])
render plain: "Language preference: #{language}"
end
private
def parse_accept_language(header)
header.to_s.split(',').map { |l|
lang, q_factor = l.split(';q=')
[lang, (q_factor || '1').to_f]
}.sort_by { |_, q| -q }.map(&:first).first
end
end