Module: LanguageSwitcher::Helpers

Includes:
LanguageSwitcher
Defined in:
lib/language_switcher.rb

Instance Method Summary collapse

Methods included from LanguageSwitcher

#attribute_translation, #each_language, #language, #t

Instance Method Details

#language_navObject



53
54
55
56
57
# File 'lib/language_switcher.rb', line 53

def language_nav
  I18n.available_locales.inject("".html_safe) do |html, lang|
    html << ("li", link_to(t(lang), "#language_#{lang}") )
  end
end

#language_switcher(&block) ⇒ Object



35
36
37
# File 'lib/language_switcher.rb', line 35

def language_switcher(&block)
  ("div", ("ul", language_nav) << language_tabs(&block), 'data-tabs'=>'data-tabs' )
end

#language_tab(lang, &block) ⇒ Object



45
46
47
48
49
50
51
# File 'lib/language_switcher.rb', line 45

def language_tab(lang, &block)
  ("div", :id=>"language_#{lang}") do
    language(lang) do
      block.call lang
    end
  end
end

#language_tabs(&block) ⇒ Object



39
40
41
42
43
# File 'lib/language_switcher.rb', line 39

def language_tabs(&block)
  I18n.available_locales.inject("".html_safe) do |html, lang|
    html << language_tab(lang, &block)
  end
end