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, #uri_with_username

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



23
24
25
26
# File 'app/helpers/language_helper.rb', line 23

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
# File 'app/helpers/language_helper.rb', line 14

def get_javascript_strings_for(language, section)
  translations = I18n.t(section, locale: DEFAULT_LANGUAGE).dup
  translations.deep_merge!(I18n.t(section, locale: language)) if language != DEFAULT_LANGUAGE

  translations["pluralization_rule"] = I18n.t("i18n.plural.js_rule", locale: language)
  translations["pod_name"] = pod_name
  translations
end

#rtl?Boolean

Returns:

  • (Boolean)


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

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