I wwant to clean up my i18n files by removing unused values. Is it possible to determine which ones are in use/unused?
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:
I think this is the issue bacause no warnings are being raised. I will do this manually for now since I only have like 100 keys.
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.