Class: Locomotive::Steam::Middlewares::Locale

Inherits:
ThreadSafe
  • Object
show all
Includes:
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)

The

Instance Attribute Summary

Attributes inherited from ThreadSafe

#env

Instance Method Summary collapse

Methods included from Helpers

#decorate_entry, #default_liquid_context, #default_locale, #html?, #json?, #liquid_assigns, #live_editing?, #locale, #locales, #log, #make_local_path, #modify_path, #mounted_on, #page, #params, #path, #redirect_to, #render_response, #repositories, #request, #services, #site

Methods inherited from ThreadSafe

#call, #next

Instance Method Details

#_callObject



18
19
20
21
22
23
24
25
26
# File 'lib/locomotive/steam/middlewares/locale.rb', line 18

def _call
  locale = extract_locale

  log "Detecting locale #{locale.upcase}"

  I18n.with_locale(locale) do
    self.next
  end
end