Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save suweller/322820 to your computer and use it in GitHub Desktop.
Save suweller/322820 to your computer and use it in GitHub Desktop.
Suicidal Missing Translation Exceptions.
module I18n
class SuicidalMissingTranslationData < RuntimeError; end
class << self
def translate_with_suicidal_exceptions(*args)
translate_without_suicidal_exceptions(*args)
rescue I18n::MissingTranslationData => e
if %w(test cucumber).include? ENV['RAILS_ENV']
raise I18n::SuicidalMissingTranslationData, e
elsif %(staging production).include? ENV['RAILS_ENV']
ActiveRecord::Base.logger.error "translation missing '#{e}'"
elsif 'development' == ENV['RAILS_ENV']
raise e
end
end
alias_method_chain :translate, :suicidal_exceptions
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment