Skip to content
Find missing translations in your code more easily.
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



I18n::MissingTranslations is a simple tool that helps with finding missing translations in your application.

It consists of three parts:

  • a module that plugs into the I18n::ExceptionHandler class and logs I18n::MissingTranslationData exceptions
  • an in-memory logger that simply holds missing translations during a request or test run
  • a middleware that can be used to dump the contents of the logger to a file after each request

This is what you might want to put into your test_helper:

require 'i18n/missing_translations'
at_exit { I18n.missing_translations.dump }

If there are any missing translations then this will print out a YAML snippet for them that you can copy and paste to your locale file.

The following hooks up the I18n::MissingTranslations middleware in development mode:

require 'i18n/missing_translations'
config.app_middleware.use(I18n::MissingTranslations) if Rails.env.development?

This will then log missing tranlations in development mode to a file missing_translations.yml in your locales dir, which is config/locales if present (i.e. per Rails convention) or the current directory otherwise. You can also pass a filename as an argument:

config.app_middleware.use(I18n::MissingTranslations, 'path/to/locales/missing.yml')

The middleware reads and writes per request. That means that on subsequent requests missing translations are added to the missing_translations.yml file. So if you go ahead and copy translations from the missing_translations.yml to your actual locale files you will also want to clear or delete missing_translations.yml.

NOTE that Rails (3.0.1) does not pick up new locale files between requests. That effectively means that changes to the missing_translations.yml file will be overwritten unless you restart the server. Thus your workflow for finding and moving missing translation keys should look something like this:

  • start the server
  • click around/work on stuff
  • check config/locales/missing_translations.yml
  • copy any missing translation keys to your actual locale files and correct the translations
  • delete or clear config/locales/missing_translations.yml
  • restart the server
Something went wrong with that request. Please try again.