raise_on_missing_translations in controller

config.action_view.raise_on_missing_translations is used in ActionView::Helpers::TranslationHelper to re-raise exceptions on missing translation.

However, when you call translate from controller (e.g. redirect_to path, notice: t(".done")) this setting has no effect. This is because AbstractController::Translation#translate calls I18n.translate directly, and doesn’t go through TranslationHelper

Yes, obviously the config option is scoped to “action_view” but still I found it pretty surprising.

I wanted raise behaviour by default in controllers to, so I added this to ApplicationController:

def translate(key, options={})
super(key, options.reverse_merge(raise: ActionView::Base.raise_on_missing_translations))
alias :t :translate


It’d be great though to have a universal raise_on_missing_translations option in Rails.