Module: Localite::RailsFilter

Defined in:
lib/localite/rails_filter.rb

Class Method Summary collapse

Class Method Details

.filter(controller, &block) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/localite/rails_filter.rb', line 2

def self.filter(controller, &block)
  #
  # get the current locale
  locale = begin
    controller.send(:current_locale)
  rescue NoMethodError
  end

  #
  # get the current locale
  begin
    scope = controller.send(:localite_scope)
    scope = [ scope ] if scope && !scope.is_a?(Array)
  rescue NoMethodError
  end

  #
  # set up localite for this action.
  Localite.html do
    Localite.in(locale) do 
      Localite.scope(*scope, &block)
    end
  end
end