I18n list missing translations on page

When an i18n translation is missing, it can throw an error so you won’t miss it.

But when refactoring/moving/creating a page it could be really painfull to just get the missing translation error page, one by missing translation.

It would be nicer to display a missing translations list into a frame (such as web console, or rack-mini-profiler) So you can still see your refactoring progress and which translations are missing and create them all at once.


This is a really interesting idea!

I think it might make sense to build this as a gem using Rails Engines – that way the Rails team can have the option of whether to include it or not, but it’ll still be available to people who find it valuable. That process could bypass a lot of the consensus-building work that tends to occur before considering new built-ins to Rails core.

Would you have time to work on a project like that? Maybe even just wireframe out what you want, in case other people are interested in implementation?

I’ve gotten a lot of mileage in the past out of a simple CSS rule that takes the span classname that Rails adds to the missing translation in the rendered view and turns it bright red with yellow text, like a cobra staring you down. Impossible to miss!


Interesting! Do you think that that’s implementable in a globalizable way? Like how Bullet presents an overlay warning users of n+1 queries?

It’s really low-fi, the only wrinkle I put to it was to keep it out of the page head if you’re in production. It was something like this:

<%= stylesheet_link_tag :i18n_fail unless Rails.env.production? %>

…in the main layout file. The style was really simple, since Rails already wraps these failures in a span:

<span class="translation_missing">Blargh</span>

so it’s just .translation_missing { color: yellow; background-color: red; }. Very hard to miss on screen.


1 Like

I used the same approach of the css class in the past, that worked great and I had the same yellow/red colors, but inverted :joy:

You may also want to check out the i18n-tasks gem. It has an i18n-tasks missing command to help look for missing translations and you can set that up in your CI so that tests fail when translations are missing.

Our team also does something similar to this answer to rescue from missing translation errors in Prod and report those with Airbrake just in case any problems do slip through.

1 Like