Module: LocaleHelper

Defined in:
app/helpers/locale_helper.rb

Instance Method Summary collapse

Instance Method Details

#current_localeObject



6
7
8
# File 'app/helpers/locale_helper.rb', line 6

def current_locale
  session[:locale]
end

#current_locale?(locale) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
# File 'app/helpers/locale_helper.rb', line 9

def current_locale?(locale)
  locale == current_locale
end

#enabled_localesObject

mirror I18n extension



3
# File 'app/helpers/locale_helper.rb', line 3

def enabled_locales; I18n.enabled_locales end


12
13
14
# File 'app/helpers/locale_helper.rb', line 12

def link_to_locale(locale, name = nil, *args)
  link_to(name || locale_name(locale), "/#{locale}#{request && request.path}", *args) if locale_enabled?(locale)
end

#locale_enabled?(locale) ⇒ Boolean

Returns:

  • (Boolean)


4
# File 'app/helpers/locale_helper.rb', line 4

def locale_enabled?(locale); I18n.locale_enabled?(locale) end

#locale_name(locale) ⇒ Object



15
16
17
# File 'app/helpers/locale_helper.rb', line 15

def locale_name(locale)
  I18n.t(:this_file_language, :locale => locale) if locale_enabled?(locale)
end