Sha256: d35129c644d5348450ce3eec9255b5ec947a98031186aa52f853e54d25785953
Contents?: true
Size: 966 Bytes
Versions: 1
Compression:
Stored size: 966 Bytes
Contents
module LocaleSetter module Generic def self.set_locale(i18n, options = {:params => nil, :user => nil, :env => nil}) i18n.locale = from_params(options[:params], available(i18n)) || from_user(options[:user], available(i18n)) || from_http(options[:env], available(i18n)) || i18n.default_locale end def self.available(i18n) i18n.available_locales.map(&:to_s) end def self.from_user(user, available) LocaleSetter::User.for(user, available) end def self.from_http(env, available) if env && env[HTTP_HEADER] LocaleSetter::HTTP.for(env[HTTP_HEADER], available) end end def self.from_params(params, available) if params && params[URL_PARAM] LocaleSetter::Param.for(params[URL_PARAM], available) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
locale_setter-0.3.0 | lib/locale_setter/generic.rb |