Module: Trestle::I18nHelper

Defined in:
app/helpers/trestle/i18n_helper.rb

Instance Method Summary collapse

Instance Method Details

#default_translation(key) ⇒ Object



14
15
16
17
18
# File 'app/helpers/trestle/i18n_helper.rb', line 14

def default_translation(key)
  translate(key, locale: :en)
rescue I18n::InvalidLocale
  key.split(".").last.humanize
end

#i18n_fallbacks(locale = I18n.locale) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'app/helpers/trestle/i18n_helper.rb', line 3

def i18n_fallbacks(locale=I18n.locale)
  if I18n.respond_to?(:fallbacks)
    I18n.fallbacks[locale]
  elsif locale.to_s.include?("-")
    fallback = locale.to_s.split("-").first
    [locale, fallback]
  else
    [locale]
  end
end