aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_view/helpers/translation_helper.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/actionpack/lib/action_view/helpers/translation_helper.rb b/actionpack/lib/action_view/helpers/translation_helper.rb
new file mode 100644
index 0000000000..0bfe6bf771
--- /dev/null
+++ b/actionpack/lib/action_view/helpers/translation_helper.rb
@@ -0,0 +1,16 @@
+require 'action_view/helpers/tag_helper'
+
+module ActionView
+ module Helpers
+ module TranslationHelper
+ def translate(*args)
+ key, locale, options = I18n.send :process_translate_arguments, *args
+ I18n.translate key, locale, options.merge(:raise => true)
+
+ rescue I18n::MissingTranslationData => e
+ keys = I18n.send :normalize_translation_keys, locale, key, options[:scope]
+ content_tag('span', keys.join(', '), :class => 'translation_missing')
+ end
+ end
+ end
+end \ No newline at end of file