Module: LocaleSetter::Controller

Defined in:
lib/locale_setter/controller.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(controller) ⇒ Object



3
4
5
# File 'lib/locale_setter/controller.rb', line 3

def self.included(controller)
  controller.before_filter :set_locale
end

Instance Method Details

#default_url_options(options = {}) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/locale_setter/controller.rb', line 7

def default_url_options(options = {})
  if i18n.locale == i18n.default_locale
    options
  else
    {LocaleSetter.config.url_param => i18n.locale}.merge(options)
  end
end

#i18nObject



30
31
32
# File 'lib/locale_setter/controller.rb', line 30

def i18n
  I18n
end

#locale_userObject



25
26
27
28
# File 'lib/locale_setter/controller.rb', line 25

def locale_user
  current_user_method = LocaleSetter.config.current_user_method.to_sym
  send(current_user_method) if respond_to?(current_user_method)
end

#set_localeObject



15
16
17
18
19
20
21
22
23
# File 'lib/locale_setter/controller.rb', line 15

def set_locale
  Generic.set_locale(
    i18n,
    {:params => params,
     :user   => locale_user,
     :domain => request.domain,
     :env    => request.env}
  )
end