Module: LocaleSelector::ControllerClassMethods

Defined in:
lib/locale_selector.rb

Instance Method Summary collapse

Instance Method Details

#offer_locales(*args) ⇒ Object

Usage: offer_locales :en_UK, :de, :domain => ‘my_application’ The default for the list of the locales is the list of subdirectories of the ‘locale’ folder. Possible options are:

:domain

the gettext domain

:lang_cookie_path

the path for cookie that remembers the user locale selection



92
93
94
95
96
97
98
99
100
101
# File 'lib/locale_selector.rb', line 92

def offer_locales(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  class_variable_set :@@offered_locales,
    args.empty? ?
    GetText::Rails::available_locales :
    args.flatten.map{|l| l.to_s}.uniq
  helper_method :effective_locale, :offered_locales
  init_gettext options[:domain] || LocaleSelector::default_domain
  class_variable_set :@@lang_cookie_path, options[:lang_cookie_path] || '/'
end