Determining missing translation keys from gettext .po files

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 en.po:

msgid "error"
msgstr "Something went wrong"

msgid "success"
msgstr "Operation failed successfully"

And es.po:

msgid "error"
msgstr "¡algo salió mal!"

In this example, we can clearly see that the success key is missing from es.po.

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]

Written by Jamie Tanna's profile image Jamie Tanna on , and last updated on .

Content for this article is shared under the terms of the Creative Commons Attribution Non Commercial Share Alike 4.0 International, and code is shared under the Apache License 2.0.

#blogumentation #go.

This post was filed under articles.

Interactions with this post

Interactions with this post

Below you can find the interactions that this page has had using WebMention.

Have you written a response to this post? Let me know the URL:

Do you not have a website set up with WebMention capabilities? You can use Comment Parade.