Checking used/unused i18n values

Let’s say your site has two languages:

i18n/
├── de.toml
└── en.toml

Move one of the i18n files to the root of your project:

mv i18n/en.toml .

Then:

hugo --printI18nWarnings 

Result (all i18n calls in all templates)

i18n|MISSING_TRANSLATION|en|foo
i18n|MISSING_TRANSLATION|en|bar
i18n|MISSING_TRANSLATION|en|baz

Then return the moved i18n to its original location:

mv en.toml i18n/

Then you can manually compare the output to your i18n files, removing the extraneous key/value pairs as needed.


Important

You must generate at least one page for each template that contains an i18n call. For example, with this template structure…

layouts/
├── _default/
│   ├── baseof.html
│   ├── home.html
│   ├── list.html
│   └── single.html
└── posts/
    └── single.html  <-- contains {{ i18n "foo" }}

…you must have at least one content file that will use the layouts/posts/single.html template. If you do not, the foo key will not appear on the list of missing translations.

Creating or updating i18n files

While this is not specifically related to your question (it does not remove unused keys), it may be of interest for new projects:

https://discourse.gohugo.io/t/33718/5