Only pull in gem if it is being used, remove middleware
This commit is contained in:
parent
8b1772ac0f
commit
7598037080
2
Gemfile
2
Gemfile
|
@ -45,7 +45,7 @@ gem 'active_model_serializers', '~> 0.8.3'
|
|||
|
||||
gem 'onebox'
|
||||
|
||||
gem 'http_accept_language', '~>2.0.5'
|
||||
gem 'http_accept_language', '~>2.0.5', require: false
|
||||
|
||||
gem 'ember-rails'
|
||||
gem 'ember-source', '1.12.2'
|
||||
|
|
|
@ -321,8 +321,10 @@ class ApplicationController < ActionController::Base
|
|||
begin
|
||||
# Rails I18n uses underscores between the locale and the region; the request
|
||||
# headers use hyphens.
|
||||
require 'http_accept_language' unless defined? HttpAcceptLanguage
|
||||
available_locales = I18n.available_locales.map { |locale| locale.to_s.gsub(/_/, '-') }
|
||||
http_accept_language.language_region_compatible_from(available_locales).gsub(/-/, '_')
|
||||
parser = HttpAcceptLanguage::Parser.new(request.env["HTTP_ACCEPT_LANGUAGE"])
|
||||
parser.language_region_compatible_from(available_locales).gsub(/-/, '_')
|
||||
rescue
|
||||
# If Accept-Language headers are not set.
|
||||
I18n.default_locale
|
||||
|
|
Loading…
Reference in New Issue