Skip to content

Instantly share code, notes, and snippets.

@jacobat
Last active December 31, 2015 12:19
Show Gist options
  • Save jacobat/7985892 to your computer and use it in GitHub Desktop.
Save jacobat/7985892 to your computer and use it in GitHub Desktop.
module I18n
module Backend
class Error
include Base
def lookup(locale, key, scope = [], options = {})
case key
when /missing/
nil
when /count/
{ :one => "one" }
end
end
end
end
end
I18n.backend = I18n::Backend::Error.new
I18n.exception_handler = ->(*args) { p args }
I18n.t('missing.something') # Outputs args from handler as excepted
I18n.t('count.something', :count => 2) # Raises exception
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment