Class: Locomotive::Steam::Middlewares::Locale
- Inherits:
-
ThreadSafe
- Object
- ThreadSafe
- Locomotive::Steam::Middlewares::Locale
- Includes:
- Concerns::Helpers
- Defined in:
- lib/locomotive/steam/middlewares/locale.rb
Overview
Set the locale from the path if possible or use the default one
Examples:
/fr/index => locale = :fr
/fr/ => locale = :fr
/index => locale = :en (default one)
/en/index?locale=fr => locale = :fr
/index => redirection to /en if the locale in cookie is :en
Constant Summary
Constants included from Concerns::Helpers
Concerns::Helpers::CACHE_HEADERS, Concerns::Helpers::HTML_CONTENT_TYPE, Concerns::Helpers::HTML_MIME_TYPES
Instance Attribute Summary
Attributes inherited from ThreadSafe
Instance Method Summary collapse
Methods included from Concerns::Helpers
#html?, #inject_cookies, #json?, #log, #make_local_path, #modify_path, #mounted_on, #redirect_to, #render_response
Methods inherited from ThreadSafe
#call, #decorate_entry, #default_liquid_context, #default_locale, #liquid_assigns, #live_editing?, #locale, #locales, #merge_with_params, #next, #page, #params, #path, #repositories, #request, #services, #session, #site
Instance Method Details
#_call ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/locomotive/steam/middlewares/locale.rb', line 19 def _call env['steam.path'] = request.path_info env['steam.locale'] = services.locale = extract_locale log "Locale used: #{locale.upcase}" I18n.with_locale(locale) do self.next end end |