Class: Isomorfeus::I18n::Middleware
- Inherits:
-
Object
- Object
- Isomorfeus::I18n::Middleware
- Defined in:
- lib/isomorfeus/i18n/middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app) ⇒ Middleware
Returns a new instance of Middleware.
6 7 8 |
# File 'lib/isomorfeus/i18n/middleware.rb', line 6 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/isomorfeus/i18n/middleware.rb', line 10 def call(env) locale = env.http_accept_language.preferred_language_from(Isomorfeus.available_locales) || env.http_accept_language.compatible_language_from(Isomorfeus.available_locales) || Isomorfeus.default_locale Isomorfeus.current_locale = locale if Isomorfeus.current_locale != locale @app.call(env) end |