Class: Locale::Middleware
- Inherits:
-
Object
- Object
- Locale::Middleware
- Defined in:
- lib/locale/middleware.rb
Instance Method Summary collapse
- #call(environment) ⇒ Object
-
#initialize(application, options = {}) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(application, options = {}) ⇒ Middleware
Returns a new instance of Middleware.
22 23 24 25 26 |
# File 'lib/locale/middleware.rb', line 22 def initialize(application, ={}) @application = application @options = Locale.init(:driver => :cgi) end |
Instance Method Details
#call(environment) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/locale/middleware.rb', line 28 def call(environment) request = Rack::Request.new(environment) Locale.set_request([request["lang"]], [request.["lang"]], environment["HTTP_ACCEPT_LANGUAGE"], environment["HTTP_ACCEPT_CHARSET"]) @application.call(environment) end |