Sha256: 36a56f75154b74a6765acc60b0425c3691f979783b1482af4aa3e21bfd5ef62c

Contents?: true

Size: 458 Bytes

Versions: 4

Compression:

Stored size: 458 Bytes

Contents

module Trestle
  module I18nHelper
    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

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
trestle-0.9.1 app/helpers/trestle/i18n_helper.rb
trestle-0.9.0 app/helpers/trestle/i18n_helper.rb
trestle-0.8.13 app/helpers/trestle/i18n_helper.rb
trestle-0.8.12 app/helpers/trestle/i18n_helper.rb