How to Find Missing or Unused I18n Translations

Jessie Young

While I18n is a great tool for quick copy changes, translation files can quickly become large and multiply, leaving you with the feeling that there are missing or unused translations hiding under your nose. Enter i18n-tasks, which provides - you guessed it - I18n tasks. Among these tasks are:

% i18n-tasks unused

and

% i18n-tasks missing

Want the test suite to fail when there are missing or unused tasks? Add i18n-tasks to your Gemfile:

group :test do
  gem "i18n-tasks"
end
% bundle

And run the following:

% cp $(i18n-tasks gem-path)/templates/rspec/i18n_spec.rb spec/

You now have a test in your spec directory that will fail when there are missing or unused I18n translations!

Bonus: Use thoughtbot’s I18n-tasks config file template to set up your config/i18n-tasks.yml file. This will ensure that I18n-tasks doesn’t return false positives or false negatives.

What’s next

If you found this useful, you might also enjoy: