Skip to content
This repository
Browse code

simplify exception handler and delegate store_translations

  • Loading branch information...
commit 48ff00d2af07693171ec341500537b30e23e83bc 1 parent 1962b82
Sven Fuchs authored

Showing 2 changed files with 5 additions and 4 deletions. Show diff stats Hide diff stats

  1. +4 3 lib/i18n.rb
  2. +1 1  test/i18n_test.rb
7 lib/i18n.rb
@@ -145,6 +145,7 @@ def translate(key, options = {})
145 145 locale = options.delete(:locale) || I18n.locale
146 146 backend.translate locale, key, options
147 147 rescue I18n::ArgumentError => e
  148 + raise e if options[:raise]
148 149 send @@exception_handler, e, locale, key, options
149 150 end
150 151 alias :t :translate
@@ -162,9 +163,9 @@ def localize(object, options = {})
162 163 # MissingTranslationData exceptions are re-raised. When a MissingTranslationData
163 164 # was caught and the option :raise is not set the handler returns an error
164 165 # message string containing the key/scope.
165   - def default_exception_handler(e, locale, key, options)
166   - return e.message if !options[:raise] && MissingTranslationData === e
167   - raise e
  166 + def default_exception_handler(exception, locale, key, options)
  167 + return exception.message if MissingTranslationData === exception
  168 + raise exception
168 169 end
169 170
170 171 # Merges the given locale, key and scope into a single array of keys.
2  test/i18n_test.rb
@@ -8,7 +8,7 @@
8 8
9 9 class I18nTest < Test::Unit::TestCase
10 10 def setup
11   - I18n.backend.store_translations :'en-US', {
  11 + I18n.store_translations :'en-US', {
12 12 :currency => {
13 13 :format => {
14 14 :separator => '.',

0 comments on commit 48ff00d

Please sign in to comment.
Something went wrong with that request. Please try again.