Module: RailsLocalization::Controller

Defined in:
lib/rails-localization/controller.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rails-localization/controller.rb', line 3

def self.included(base)
  base.class_eval do
    around_filter :process_with_locale

    protected

    def process_with_locale
      begin
        if params.has_key?(:locale)
          ::I18n.locale = params[:locale].blank? ? ::I18n.default_locale : params[:locale].to_s
        end
        yield
      ensure 
        ::I18n.locale = ::I18n.default_locale
      end 
    end    
  end
end