Sha256: 16fd0fee6dcb180b108f5b6dd12ce05d5162871cfd8aade259e0996bd28db0ce

Contents?: true

Size: 826 Bytes

Versions: 1

Compression:

Stored size: 826 Bytes

Contents

I18n::Backend::Simple.send(:include, I18n::Backend::Cascade)

# TODO no idea how to use a module here :/
ActionView::Base.class_eval do
  def translate(key, options = {})
    # TODO must be fixed in I18n::Backend::Cascade
    options.merge!(:cascade => { :step => 1, :offset => 2, :skip_root => false }) if key.to_s.include?('.')
    super(key, options)
  end
  alias t translate
end

# TODO submit a Rails patch
ActionView::Helpers::TranslationHelper.module_eval do
  def translate(key, options = {})
    options.merge!(:wrap_exception => true) unless options.key?(:wrap_exception)
    translation = I18n.translate(scope_key_by_partial(key), options)
    if html_safe_translation_key?(key) && translation.respond_to?(:html_safe)
      translation.html_safe
    else
      translation
    end
  end
  alias :t :translate
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
adva-core-0.0.2 lib/adva/view/helper/i18n.rb