Skip to content
Browse files

Rack::Locale: retain the whole language code

  • Loading branch information...
1 parent 0c1a7ac commit a790c26e974cf3925b6f0f0ed0e92e9a332c1169 James A. Rosen committed
Showing with 5 additions and 1 deletion.
  1. +1 −1 lib/rack/contrib/locale.rb
  2. +4 −0 test/spec_rack_locale.rb
View
2 lib/rack/contrib/locale.rb
@@ -32,7 +32,7 @@ def accept_locale(env)
qvalue.to_f
}.last
- lang.first.split("-").first
+ lang.first
end
end
end
View
4 test/spec_rack_locale.rb
@@ -40,6 +40,10 @@ def response_with_languages(accept_languages)
response_with_languages('en;q=0.9,es;q=0.95').body.should.equal('es')
end
+ specify 'should retain full language codes' do
+ response_with_languages('en-gb,en-us;q=0.95;en').body.should.equal('en-gb')
+ end
+
specify 'should reset the I18n locale after the response' do
I18n.locale = 'es'
response_with_languages('en,de;q=0.8')

0 comments on commit a790c26

Please sign in to comment.
Something went wrong with that request. Please try again.