Replace locale middleware with http_accept_language
This commit is contained in:
parent
8a87f19cd0
commit
31cefcd2d0
2
Gemfile
2
Gemfile
|
@ -6,9 +6,9 @@ gem 'arel'
|
||||||
gem 'devise'
|
gem 'devise'
|
||||||
gem 'geokit'
|
gem 'geokit'
|
||||||
gem 'haml', '~> 3.2.0.alpha'
|
gem 'haml', '~> 3.2.0.alpha'
|
||||||
|
gem 'http_accept_language'
|
||||||
gem 'pg'
|
gem 'pg'
|
||||||
gem 'rails_admin', :git => 'git://github.com/sferik/rails_admin.git'
|
gem 'rails_admin', :git => 'git://github.com/sferik/rails_admin.git'
|
||||||
gem 'rack-contrib'
|
|
||||||
gem 'validates_formatting_of'
|
gem 'validates_formatting_of'
|
||||||
|
|
||||||
platforms :ruby_18 do
|
platforms :ruby_18 do
|
||||||
|
|
|
@ -74,6 +74,7 @@ GEM
|
||||||
haml (3.2.0.alpha.10)
|
haml (3.2.0.alpha.10)
|
||||||
hike (1.2.1)
|
hike (1.2.1)
|
||||||
hpricot (0.8.6)
|
hpricot (0.8.6)
|
||||||
|
http_accept_language (1.0.2)
|
||||||
i18n (0.6.0)
|
i18n (0.6.0)
|
||||||
journey (1.0.0)
|
journey (1.0.0)
|
||||||
jquery-rails (2.0.0)
|
jquery-rails (2.0.0)
|
||||||
|
@ -96,8 +97,6 @@ GEM
|
||||||
rack (1.4.1)
|
rack (1.4.1)
|
||||||
rack-cache (1.1)
|
rack-cache (1.1)
|
||||||
rack (>= 0.4)
|
rack (>= 0.4)
|
||||||
rack-contrib (1.1.0)
|
|
||||||
rack (>= 0.9.1)
|
|
||||||
rack-pjax (0.5.7)
|
rack-pjax (0.5.7)
|
||||||
hpricot (~> 0.8.6)
|
hpricot (~> 0.8.6)
|
||||||
rack (~> 1.3)
|
rack (~> 1.3)
|
||||||
|
@ -168,8 +167,8 @@ DEPENDENCIES
|
||||||
fastercsv
|
fastercsv
|
||||||
geokit
|
geokit
|
||||||
haml (~> 3.2.0.alpha)
|
haml (~> 3.2.0.alpha)
|
||||||
|
http_accept_language
|
||||||
pg
|
pg
|
||||||
rack-contrib
|
|
||||||
rails (~> 3.2)
|
rails (~> 3.2)
|
||||||
rails_admin!
|
rails_admin!
|
||||||
sass-rails
|
sass-rails
|
||||||
|
|
|
@ -14,6 +14,9 @@ protected
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_locale
|
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
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
require 'rack'
|
|
||||||
require 'rack/contrib'
|
|
||||||
|
|
||||||
Rails.application.config.middleware.use Rack::Locale
|
|
Loading…
Reference in New Issue