diff options
author | Sven Fuchs <svenfuchs@artweb-design.de> | 2008-07-06 19:00:55 +0200 |
---|---|---|
committer | Sven Fuchs <svenfuchs@artweb-design.de> | 2008-07-06 19:00:55 +0200 |
commit | c9ed2c9bd24b9f4cdfcb692151f87ba900469e71 (patch) | |
tree | c8ca560039a7389258995b13f29766e0b5f4d0bd /actionpack/lib | |
parent | a865d19516a716762b46ca29212bac668dd7c4a0 (diff) | |
download | rails-c9ed2c9bd24b9f4cdfcb692151f87ba900469e71.tar.gz rails-c9ed2c9bd24b9f4cdfcb692151f87ba900469e71.tar.bz2 rails-c9ed2c9bd24b9f4cdfcb692151f87ba900469e71.zip |
add a translation helper
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_view/helpers/translation_helper.rb | 16 |
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 |