Sha256: d1bf2064185e72b3549fcf2abc35aefb06b9b78f8cc3616408327baf76c2d704

Contents?: true

Size: 547 Bytes

Versions: 9

Compression:

Stored size: 547 Bytes

Contents

module Refinery
  module TranslationHelper

    # Overrides Rails' core I18n.t() function to produce a more helpful error message.
    # The default one wreaks havoc with CSS and makes it hard to understand the problem.
    def t(key, options = {})
      if (val = super) =~ /class.+?translation_missing/
        val = val.to_s.gsub(/<span[^>]*>/, 'i18n: ').gsub('</span>', '').gsub(', ', '.')
      end

      val
    end

    def translated_field(record, field)
      Refinery::TranslatedFieldPresenter.new(record).call(field)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
refinerycms-core-4.0.3 app/helpers/refinery/translation_helper.rb
refinerycms-core-4.0.2 app/helpers/refinery/translation_helper.rb
refinerycms-core-4.0.1 app/helpers/refinery/translation_helper.rb
refinerycms-core-3.0.6 app/helpers/refinery/translation_helper.rb
refinerycms-core-4.0.0 app/helpers/refinery/translation_helper.rb
refinerycms-core-3.0.5 app/helpers/refinery/translation_helper.rb
refinerycms-core-3.0.4 app/helpers/refinery/translation_helper.rb
refinerycms-core-3.0.3 app/helpers/refinery/translation_helper.rb
refinerycms-core-3.0.2 app/helpers/refinery/translation_helper.rb