translation_helper.rb 464 字节
Newer Older
S
Sven Fuchs 已提交
1 2 3 4 5 6
require 'action_view/helpers/tag_helper'

module ActionView
  module Helpers
    module TranslationHelper
      def translate(*args)
S
Sven Fuchs 已提交
7 8
        args << args.extract_options!.merge(:raise => true)
        I18n.translate *args
S
Sven Fuchs 已提交
9 10

      rescue I18n::MissingTranslationData => e
S
Sven Fuchs 已提交
11
        keys = I18n.send :normalize_translation_keys, e.locale, e.key, e.options[:scope]
S
Sven Fuchs 已提交
12 13 14 15 16
        content_tag('span', keys.join(', '), :class => 'translation_missing')
      end
    end
  end
end