Determining missing translation keys from gettext
This post's featured URL for sharing metadata is https://www.jvt.me/img/profile.jpg.
If you're working with applications that require translations, you may be using gettext's
.po format to store your translations.
One issue I've found with this is that sometimes it can be hard to quickly audit whether there are any missing translations, especially in larger applications.
In December I'd put together a tool to check for this, but hadn't ended up pushing it anywhere and adding an associated blog post, so here it is!
Say we have
msgid "error" msgstr "Something went wrong" msgid "success" msgstr "Operation failed successfully"
msgid "error" msgstr "¡algo salió mal!"
In this example, we can clearly see that the
success key is missing from
By following the instructions to install
missing-translations, we can then run:
missing-translations -po '*.po'
At which point we'll be told:
Key `success` does not have a translation in every locale, missing: [es.po]