Module: MerbI18n::Controller

Included in:
Merb::Controller
Defined in:
lib/merb-i18n.rb

Instance Method Summary collapse

Instance Method Details

#_set_i18nObject



22
23
24
25
26
27
28
29
30
# File 'lib/merb-i18n.rb', line 22

def _set_i18n
  R18n::I18n.default = Merb::Plugins.config[:merb_i18n][:default_locale]

  locales = R18n::I18n.parse_http(request.env['HTTP_ACCEPT_LANGUAGE'])
  locales.insert(0, params[:locale]) if params[:locale]

  @i18n = R18n::I18n.new(locales, self.i18n_dirs)
  R18n.set(@i18n)
end

#i18nObject

Return tool for i18n support. It will be R18n::I18n object, see it documentation for more information.



18
19
20
# File 'lib/merb-i18n.rb', line 18

def i18n
  @i18n 
end

#i18n_dirsObject

Dirs to load translations



38
39
40
# File 'lib/merb-i18n.rb', line 38

def i18n_dirs
  Merb.dir_for(:i18n)
end

#ni18nObject

Namespaced i18n with controller and action name



33
34
35
# File 'lib/merb-i18n.rb', line 33

def ni18n
  @n18n ||= i18n.send(params[:controller]).send(params[:action])
end