Use HTTP Accept-Language to detect locale (#1166)

* Use HTTP Accept-Language to detect locale

* Fix gem order to comply with codeclimate

* Sort gem to comply with rubocop

* I18n.default_locale fallback when there is no accept-language header
signup-info-prompt
David Authier 2017-04-09 18:40:24 +02:00 committed by Eugen
parent b16fbd52b2
commit f0bd439486
3 changed files with 25 additions and 20 deletions

37
Gemfile
View File

@ -21,37 +21,38 @@ gem 'paperclip', '~> 5.1'
gem 'paperclip-av-transcoder'
gem 'aws-sdk', '>= 2.0'
gem 'http'
gem 'httplog'
gem 'addressable'
gem 'nokogiri'
gem 'link_header'
gem 'ostatus2'
gem 'goldfinger'
gem 'devise'
gem 'devise-two-factor'
gem 'doorkeeper'
gem 'rabl'
gem 'rqrcode'
gem 'twitter-text'
gem 'ox'
gem 'oj'
gem 'hiredis'
gem 'redis', '~>3.2', require: ['redis', 'redis/connection/hiredis']
gem 'fast_blank'
gem 'goldfinger'
gem 'hiredis'
gem 'htmlentities'
gem 'simple_form'
gem 'will_paginate'
gem 'http'
gem 'http_accept_language'
gem 'httplog'
gem 'link_header'
gem 'nokogiri'
gem 'oj'
gem 'ostatus2'
gem 'ox'
gem 'rabl'
gem 'rack-attack'
gem 'rack-cors', require: 'rack/cors'
gem 'rack-timeout'
gem 'rails-settings-cached'
gem 'redis', '~>3.2', require: ['redis', 'redis/connection/hiredis']
gem 'rqrcode'
gem 'ruby-oembed', require: 'oembed'
gem 'sidekiq'
gem 'sidekiq-unique-jobs'
gem 'rails-settings-cached'
gem 'simple-navigation'
gem 'simple_form'
gem 'statsd-instrument'
gem 'ruby-oembed', require: 'oembed'
gem 'rack-timeout'
gem 'twitter-text'
gem 'tzinfo-data'
gem 'will_paginate'
gem 'react-rails'
gem 'browserify-rails'

View File

@ -184,6 +184,7 @@ GEM
http-cookie (1.0.3)
domain_name (~> 0.5)
http-form_data (1.0.1)
http_accept_language (2.1.0)
http_parser.rb (0.6.0)
httplog (0.3.2)
colorize
@ -473,6 +474,7 @@ DEPENDENCIES
hiredis
htmlentities
http
http_accept_language
httplog
i18n-tasks (~> 0.9.6)
jquery-rails
@ -522,4 +524,4 @@ RUBY VERSION
ruby 2.3.1p112
BUNDLED WITH
1.14.3
1.14.5

View File

@ -26,6 +26,8 @@ module Localized
end
def default_locale
ENV.fetch('DEFAULT_LOCALE') { I18n.default_locale }
ENV.fetch('DEFAULT_LOCALE') {
http_accept_language.compatible_language_from(I18n.available_locales) || I18n.default_locale
}
end
end