Module: LanguageHelper

Includes:
ApplicationHelper
Defined in:
app/helpers/language_helper.rb

Instance Method Summary collapse

Methods included from ApplicationHelper

#all_services_connected?, #bookmarklet_code, #changelog_url, #donations_enabled?, #jquery_include_tag, #pod_name, #pod_version, #popover_with_close_html, #qrcode_uri, #service_unconnected?, #source_url, #timeago

Instance Method Details

#available_language_optionsObject


6
7
8
9
10
11
12
# File 'app/helpers/language_helper.rb', line 6

def available_language_options
  options = []
  AVAILABLE_LANGUAGES.each do |locale, language|
    options << [language, locale]
  end
  options.sort_by { |o| o[0] }
end

#direction_for(string) ⇒ Object


27
28
29
30
# File 'app/helpers/language_helper.rb', line 27

def direction_for(string)
  return '' unless string.respond_to?(:cleaned_is_rtl?)
  string.cleaned_is_rtl? ? 'rtl' : 'ltr'
end

#get_javascript_strings_for(language, section) ⇒ Object


14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/helpers/language_helper.rb', line 14

def get_javascript_strings_for(language, section)
  defaults = I18n.t(section, :locale => DEFAULT_LANGUAGE)

  if language != DEFAULT_LANGUAGE
    translations = I18n.t(section, :locale => language)
    defaults.deep_merge!(translations)
  end

  defaults['pluralization_rule'] = I18n.t('i18n.plural.js_rule', :locale => language)
  defaults['pod_name'] = pod_name
  defaults
end

#rtl?Boolean

Returns:

  • (Boolean)

32
33
34
# File 'app/helpers/language_helper.rb', line 32

def rtl?
  @rtl ||= RTL_LANGUAGES.include?(I18n.locale.to_s)
end