Sha256: 65e660126e8782c8a2779ae471539bd3667cc2bc369ef2ffa4a9044f8a97d54c

Contents?: true

Size: 873 Bytes

Versions: 20

Compression:

Stored size: 873 Bytes

Contents

# Rails 3.2.16 and 4.0.2 introduced a new way of displaying missing translation :
# they now wrap them in a <span> element with useful class and title
#
# https://github.com/rails/rails/commit/78790e4bceedc632cb40f9597792d7e27234138a

module Localeapp
  module MimicRailsMissingTranslationDisplay

    def self.included(o)
      o.instance_eval do

        alias :old_rails_call :call
        def call(exception, locale, key, options)
          locale, key = old_rails_call(exception, locale, key, options).split(', ')
          keys = I18n.normalize_keys(locale, key, options[:scope])
          "<span class=\"translation_missing localeapp\" title=\"translation missing: #{keys.join('.')}\">#{keys.last.to_s.titleize}</span>".html_safe
        end

      end
    end

  end
end

Localeapp::ExceptionHandler.send(:include, ::Localeapp::MimicRailsMissingTranslationDisplay)

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
localeapp-3.3.0 lib/localeapp/rails/mimic_rails_missing_translation_display.rb
localeapp-3.2.0 lib/localeapp/rails/mimic_rails_missing_translation_display.rb
localeapp-3.1.3 lib/localeapp/rails/mimic_rails_missing_translation_display.rb
localeapp-3.1.2 lib/localeapp/rails/mimic_rails_missing_translation_display.rb
localeapp-3.1.1 lib/localeapp/rails/mimic_rails_missing_translation_display.rb
localeapp-3.1.0 lib/localeapp/rails/mimic_rails_missing_translation_display.rb
localeapp-3.0.1 lib/localeapp/rails/mimic_rails_missing_translation_display.rb
localeapp-3.0.0 lib/localeapp/rails/mimic_rails_missing_translation_display.rb
localeapp-2.5.0 lib/localeapp/rails/mimic_rails_missing_translation_display.rb
localeapp-2.4.0 lib/localeapp/rails/mimic_rails_missing_translation_display.rb
localeapp-2.3.0 lib/localeapp/rails/mimic_rails_missing_translation_display.rb
localeapp-2.2.0 lib/localeapp/rails/mimic_rails_missing_translation_display.rb
localeapp-2.1.1 lib/localeapp/rails/mimic_rails_missing_translation_display.rb
localeapp-2.1.0 lib/localeapp/rails/mimic_rails_missing_translation_display.rb
localeapp-2.0.0 lib/localeapp/rails/mimic_rails_missing_translation_display.rb
localeapp-1.0.2 lib/localeapp/rails/mimic_rails_missing_translation_display.rb
localeapp-1.0.1 lib/localeapp/rails/mimic_rails_missing_translation_display.rb
localeapp-1.0.0 lib/localeapp/rails/mimic_rails_missing_translation_display.rb
localeapp-0.9.3 lib/localeapp/rails/mimic_rails_missing_translation_display.rb
localeapp-0.9.2 lib/localeapp/rails/mimic_rails_missing_translation_display.rb