Module: LocaleHelper
- Defined in:
- app/helpers/locale_helper.rb
Instance Method Summary collapse
- #current_locale ⇒ Object
- #current_locale?(locale) ⇒ Boolean
-
#enabled_locales ⇒ Object
mirror I18n extension.
- #link_to_locale(locale, name = nil, *args) ⇒ Object
- #locale_enabled?(locale) ⇒ Boolean
- #locale_name(locale) ⇒ Object
Instance Method Details
#current_locale ⇒ Object
6 7 8 |
# File 'app/helpers/locale_helper.rb', line 6 def current_locale session[:locale] end |
#current_locale?(locale) ⇒ Boolean
9 10 11 |
# File 'app/helpers/locale_helper.rb', line 9 def current_locale?(locale) locale == current_locale end |
#enabled_locales ⇒ Object
mirror I18n extension
3 |
# File 'app/helpers/locale_helper.rb', line 3 def enabled_locales; I18n.enabled_locales end |
#link_to_locale(locale, name = nil, *args) ⇒ Object
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
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 |