Replace locale middleware with http_accept_language

This commit is contained in:
Erik Michaels-Ober 2012-01-24 11:26:39 -08:00
parent 8a87f19cd0
commit 31cefcd2d0
4 changed files with 7 additions and 9 deletions

View File

@ -6,9 +6,9 @@ gem 'arel'
gem 'devise'
gem 'geokit'
gem 'haml', '~> 3.2.0.alpha'
gem 'http_accept_language'
gem 'pg'
gem 'rails_admin', :git => 'git://github.com/sferik/rails_admin.git'
gem 'rack-contrib'
gem 'validates_formatting_of'
platforms :ruby_18 do

View File

@ -74,6 +74,7 @@ GEM
haml (3.2.0.alpha.10)
hike (1.2.1)
hpricot (0.8.6)
http_accept_language (1.0.2)
i18n (0.6.0)
journey (1.0.0)
jquery-rails (2.0.0)
@ -96,8 +97,6 @@ GEM
rack (1.4.1)
rack-cache (1.1)
rack (>= 0.4)
rack-contrib (1.1.0)
rack (>= 0.9.1)
rack-pjax (0.5.7)
hpricot (~> 0.8.6)
rack (~> 1.3)
@ -168,8 +167,8 @@ DEPENDENCIES
fastercsv
geokit
haml (~> 3.2.0.alpha)
http_accept_language
pg
rack-contrib
rails (~> 3.2)
rails_admin!
sass-rails

View File

@ -14,6 +14,9 @@ protected
end
def set_locale
I18n.locale = env['rack.locale'] || I18n.default_locale
available_languages = Dir.glob(Rails.root + "config/locales/??.yml").map do |file|
File.basename(file, ".yml")
end
I18n.locale = request.compatible_language_from(available_languages) || I18n.default_locale
end
end

View File

@ -1,4 +0,0 @@
require 'rack'
require 'rack/contrib'
Rails.application.config.middleware.use Rack::Locale