Module: RequestInfo::Detectors::LocaleDetector
- Defined in:
- lib/request_info/detectors/locale_detector.rb
Instance Method Summary collapse
Instance Method Details
#analyze(env) ⇒ Object
10 11 12 13 |
# File 'lib/request_info/detectors/locale_detector.rb', line 10 def analyze(env) super RequestInfo.results.locale = detect_locale end |
#wrap_app ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/request_info/detectors/locale_detector.rb', line 15 def wrap_app detected_locale = RequestInfo.results.locale previous_locale = ::I18n.locale ::I18n.locale = detected_locale status, headers, body = super # Set header language back to the client headers["Content-Language"] = RequestInfo.results.locale # Reset our modifications after app is finished ::I18n.locale = previous_locale [status, headers, body] end |