Only pull in gem if it is being used, remove middleware

This commit is contained in:
Sam Saffron 2016-03-04 23:17:14 +11:00
parent 8b1772ac0f
commit 7598037080
2 changed files with 4 additions and 2 deletions

View File

@ -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'

View File

@ -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