Class: Locale::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/locale/middleware.rb

Instance Method Summary collapse

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, options={})
  @application = application
  @options = 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.cookies["lang"]],
                     environment["HTTP_ACCEPT_LANGUAGE"],
                     environment["HTTP_ACCEPT_CHARSET"])
  @application.call(environment)
end