Module: Localizer::Helper
- Defined in:
- lib/localizer/helper.rb
Instance Method Summary collapse
- #link_to_locale(locale, name) ⇒ Object
- #locale ⇒ Object
- #locales(options = {}) ⇒ Object
- #localized_current_path(locale) ⇒ Object
- #localized_root ⇒ Object
- #when_locale(locale) ⇒ Object
- #with_locale(locale) ⇒ Object
Instance Method Details
#link_to_locale(locale, name) ⇒ Object
35 36 37 38 39 |
# File 'lib/localizer/helper.rb', line 35 def link_to_locale locale, name active = (I18n.locale.to_s == locale.to_s) link_to image_tag("flags/#{locale}.png", :title => name), send( controller.action_name+'_path', locale ), :class => (active ? 'active' : '') end |
#locale ⇒ Object
3 4 5 |
# File 'lib/localizer/helper.rb', line 3 def locale params[:locale] || 'it' end |
#locales(options = {}) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/localizer/helper.rb', line 27 def locales = {} locales = Localizer.config.locales if [:exclude] locales - [ [:exclude] ] end locales end |
#localized_current_path(locale) ⇒ Object
41 42 43 |
# File 'lib/localizer/helper.rb', line 41 def localized_current_path locale url_for(:action => nil, :locale => locale) end |
#localized_root ⇒ Object
7 8 9 |
# File 'lib/localizer/helper.rb', line 7 def localized_root locale == 'it' ? root_path : local_root_path(locale) end |
#when_locale(locale) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/localizer/helper.rb', line 19 def when_locale locale locale_backup = I18n.locale I18n.locale = locale result = yield locale I18n.locale = locale_backup return result end |
#with_locale(locale) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/localizer/helper.rb', line 11 def with_locale locale locale_backup = I18n.locale I18n.locale = locale result = yield locale I18n.locale = locale_backup return result end |