From c9ed2c9bd24b9f4cdfcb692151f87ba900469e71 Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Sun, 6 Jul 2008 19:00:55 +0200 Subject: add a translation helper --- actionpack/lib/action_view/helpers/translation_helper.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 actionpack/lib/action_view/helpers/translation_helper.rb (limited to 'actionpack/lib') 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 -- cgit v1.2.3