Permalink
Browse files

simplify exception handler and delegate store_translations

  • Loading branch information...
1 parent 1962b82 commit 48ff00d2af07693171ec341500537b30e23e83bc Sven Fuchs committed Jul 8, 2008
Showing with 5 additions and 4 deletions.
  1. +4 −3 lib/i18n.rb
  2. +1 −1 test/i18n_test.rb
View
@@ -145,6 +145,7 @@ def translate(key, options = {})
locale = options.delete(:locale) || I18n.locale
backend.translate locale, key, options
rescue I18n::ArgumentError => e
+ raise e if options[:raise]
send @@exception_handler, e, locale, key, options
end
alias :t :translate
@@ -162,9 +163,9 @@ def localize(object, options = {})
# MissingTranslationData exceptions are re-raised. When a MissingTranslationData
# was caught and the option :raise is not set the handler returns an error
# message string containing the key/scope.
- def default_exception_handler(e, locale, key, options)
- return e.message if !options[:raise] && MissingTranslationData === e
- raise e
+ def default_exception_handler(exception, locale, key, options)
+ return exception.message if MissingTranslationData === exception
+ raise exception
end
# Merges the given locale, key and scope into a single array of keys.
View
@@ -8,7 +8,7 @@
class I18nTest < Test::Unit::TestCase
def setup
- I18n.backend.store_translations :'en-US', {
+ I18n.store_translations :'en-US', {
:currency => {
:format => {
:separator => '.',

0 comments on commit 48ff00d

Please sign in to comment.