Accept-Language header support

This commit is contained in:
Yuki 2015-05-27 07:06:18 +05:30
parent 52890707c5
commit 50e1186e79
2 changed files with 3 additions and 0 deletions

View File

@ -39,6 +39,7 @@ gem 'fog'
gem 'fog-aws'
gem 'momentjs-rails', '>= 2.9.0'
gem 'bootstrap3-datetimepicker-rails', '~> 4.7.14'
gem 'http_accept_language'
gem 'ruby-progressbar'

View File

@ -14,6 +14,8 @@ class ApplicationController < ActionController::Base
I18n.locale = current_user.locale
elsif not cookies[:hl].nil?
I18n.locale = cookies[:hl]
elsif not http_accept_language.user_preferred_languages.length > 0
I18n.locale = http_accept_language.compatible_language_from(I18n.available_locales) or "en"
end
else
I18n.locale = params[:hl]