Module: Georgia::InternationalizationHelper

Defined in:
app/helpers/georgia/internationalization_helper.rb

Instance Method Summary collapse

Instance Method Details

#available_localesObject



4
5
6
# File 'app/helpers/georgia/internationalization_helper.rb', line 4

def available_locales
  I18n.available_locales
end


16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/helpers/georgia/internationalization_helper.rb', line 16

def link_to_available_locales
  return unless I18n.available_locales.any?
  links = I18n.available_locales.map do |locale|
    (:li, link_to(t("georgia.#{locale}"), locale: locale ))
  end
  (:p, class: 'hint') do
    (:div, class: 'dropdown') do
      link_to("Change language <span class='caret'></span>".html_safe, '#', class: 'btn btn-warning', data: {toggle: 'dropdown'}, role: :button) +
      (:ul, links.join('').html_safe, class: 'dropdown-menu', role: 'menu')
    end
  end
end


8
9
10
11
12
13
14
# File 'app/helpers/georgia/internationalization_helper.rb', line 8

def link_to_locale html_options={}
  if available_locales.length == 2
    link_to_locale_single html_options
  else
    link_to_locale_list html_options
  end
end