Module: LanguageHelper

Defined in:
app/helpers/language_helper.rb

Instance Method Summary collapse

Instance Method Details

#available_language_optionsObject


2
3
4
5
6
7
8
# File 'app/helpers/language_helper.rb', line 2

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


10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/helpers/language_helper.rb', line 10

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


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

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