Class: Merb::Controller
- Inherits:
-
Object
- Object
- Merb::Controller
- Includes:
- Global
- Defined in:
- lib/merb_global/controller.rb
Constant Summary
Constants included from Global
Class Method Summary collapse
-
.language(&block) ⇒ Object
Sets the language of block.
-
.locale(&block) ⇒ Object
Sets the language of block.
Instance Method Summary collapse
Methods included from Global
DateProvider, MessageProvider, NumericProvider, #_, config
Class Method Details
.language(&block) ⇒ Object
Sets the language of block.
The block should return language or nil if other method should be used to determine the language
Please note that this method is deprecated and the preferred method is locale.
17 18 19 |
# File 'lib/merb_global/controller.rb', line 17 def self.language(&block) self._mg_locale = block end |
.locale(&block) ⇒ Object
Sets the language of block.
The block should return language or nil if other method should be used to determine the language
24 25 26 |
# File 'lib/merb_global/controller.rb', line 24 def self.locale(&block) self._mg_locale = block end |
Instance Method Details
#setup_language ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/merb_global/controller.rb', line 28 def setup_language # Set up the language accept_language = self.request.env['HTTP_ACCEPT_LANGUAGE'] Merb::Global::Locale.current = (!params[:locale].nil? && params[:locale].to_s.length > 0 && Merb::Global::Locale.new(h(params[:locale]))) || (self._mg_locale && Merb::Global::Locale.new(self.instance_eval(&self._mg_locale))) || Merb::Global::Locale.from_accept_language(accept_language) || Merb::Global::Locale.new('en') end |