I came across the following:

I wanted to add my own exception handler to the I18n api. So I did,
but it didn't do what I wanted. It just kept returning <span
class="translation_missing">key, key</span>. After searching for a
while I came along this TranslationHelper in Edge Rails. It sets the
options[:raise] to true and I18n.translate rescues the exception
itself, instead of the exception handler I defined. Can't this helper
be removed? The default exception handler already generates a text
"translation missing ..." and is enough I think. It is very confusing
when defining your own exception handler and it won't reach that
handler, because of this.

Jaap van der Meer


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
      alias :t :translate

      def localize(*args)
        I18n.localize *args
      end
      alias :l :localize
    end
  end
end

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"rails-i18n" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rails-i18n?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to