Skip to content

Commit

Permalink
Update Missing to handle throw/catch for compatibility with i18n 0.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ppg committed Oct 11, 2011
1 parent b631b05 commit d3aca96
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/i18n/backend/active_record/missing.rb
Expand Up @@ -54,7 +54,15 @@ def store_default_translation(locale, key, interpolations)
end end


def translate(locale, key, options = {}) def translate(locale, key, options = {})
super # Support throw/catch for MissingTranslation (i18n 0.6.0)
result = catch(:exception) do
super
end
if result.is_a?(I18n::MissingTranslation)
self.store_default_translations(locale, key, options)
throw(:exception, result)
end
result
rescue I18n::MissingTranslationData => e rescue I18n::MissingTranslationData => e
self.store_default_translations(locale, key, options) self.store_default_translations(locale, key, options)
raise e raise e
Expand Down

0 comments on commit d3aca96

Please sign in to comment.