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
[2] GitHub - svenfuchs/i18n-active_record: I18n ActiveRecord backend