aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers/translation_helper.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_view/helpers/translation_helper.rb')
-rw-r--r--actionpack/lib/action_view/helpers/translation_helper.rb20
1 files changed, 20 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..e1010ccf5f
--- /dev/null
+++ b/actionpack/lib/action_view/helpers/translation_helper.rb
@@ -0,0 +1,20 @@
+require 'action_view/helpers/tag_helper'
+
+module ActionView
+ module Helpers
+ module TranslationHelper
+ def translate(*args)
+ args << args.extract_options!.merge(:raise => true)
+ I18n.translate *args
+
+ rescue I18n::MissingTranslationData => e
+ keys = I18n.send :normalize_translation_keys, e.locale, e.key, e.options[:scope]
+ content_tag('span', keys.join(', '), :class => 'translation_missing')
+ end
+
+ def localize(*args)
+ I18n.l *args
+ end
+ end
+ end
+end \ No newline at end of file