# Extraction of activerecord backend to separate gem + tiny changes to exception handling api

**URL:** <https://www.ruby-forum.com/t/extraction-of-activerecord-backend-to-separate-gem-tiny-changes-to-exception-handling-api/198685>\
**Category:** Rails I18n\
**Created:** [November 5, 2010, 1:50pm UTC](https://www.ruby-forum.com/t/extraction-of-activerecord-backend-to-separate-gem-tiny-changes-to-exception-handling-api/198685 "2010-11-05T13:50:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![okkezSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/85f322/32.png) [@okkezSS](https://www.ruby-forum.com/u/okkezSS)\
**Post date:** [November 5, 2010, 1:50pm UTC](https://www.ruby-forum.com/t/extraction-of-activerecord-backend-to-separate-gem-tiny-changes-to-exception-handling-api/198685/1 "2010-11-05T13:50:47Z")

</div>

Just a headsup about a few things that I’ve just pushed to the 0.5.0  
branch [1]

First, I’ve extracted the ActiveRecord backend including support classes  
to a separate gem [2].

I’m now looking for a maintainer for it! So if you’re actively using the  
ActiveRecord backend and want to maintain it, please clone the  
repository (don’t fork it) and push it to a newly created repository (so  
it becomes your own). I’ll then delete my own copy of it.

This gem will continue to be supported as a first-class usecase for the  
I18n library and we’ll probably add it to our CI. If nobody’s interested  
in this I’ll continue maintaining it myself.

Also, I’ve pushed a few changes to the exception handling API.

So far one is able to set a custom exception handler to  
I18n.exception\_handler, which can be a method name or anything that  
responds to #call. This is fine but provides little flexibility. To make  
this more flexible I’ve added an ExceptionHandler class which can be  
more easily extended by including a module or subclassing. An instance  
of this class is set to I18n.exception\_handler by default.

I’ve also added the ability to pass an option :rescue\_format =\> :html  
and the exception handler will respond in a similar fashion as the  
current ActionView translation handler does, i.e. it wraps the message  
to a span tag with the class “translation\_missing” (so we’ll be able to  
remove this bit of code from ActionView and thus get rid of the rescue  
clause over there, which sometimes is annoying). I’m not really sure  
about the :rescue\_format option key, so if you happen to have a better  
idea, let me know.

Different from the ActionView helper the span tag contains a titleized  
version of the last token of the translation key. I.e. if the key was  
foo.bar\_baz then the span tag contains the text “Bar Baz”. This should  
make people more happy who found the missing translation messages too  
noisy.

I’ve also added the ability to pass an :exception\_handler option per  
request which then will take precedence over whatever is set to  
I18n.exception\_handler.

These changes obviously deprecate the #default\_exception\_handler method  
which is now not used anymore by the gem itself.

I also plan to remove deprecation any warnings that have been around  
since pre 0.4.0 with the release of 0.5.0 and remove the respective  
methods.

Please lemme know what you think!

[1] [https://github.com/svenfuchs/i18n/commits/0.5.0](https://github.com/svenfuchs/i18n/commits/0.5.0)  
[2] [GitHub - svenfuchs/i18n-active\_record: I18n ActiveRecord backend](https://github.com/svenfuchs/i18n-active_record)
