We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
Checking for missing gettext translations in CI
almirsarajcic
Created
Are you doing i18n of your Elixir app? How do you know whether all the strings you’ve predetermined for i18n have translations in all the languages you support?
We’ve had the same issue. We’ve solved it by adding a CI check so that every PR adding new strings to be translated has to also include the translations.
Unfortunately, there’s no out-of-box solution, so this time, we couldn’t write a one-liner and call it done. Still, you can add this to your Makefile
and run make check-gettext
as part of your CI as well as local code checks.
check-gettext:
@mix gettext.extract --merge > /dev/null 2>&1
@if ! git diff --quiet priv/gettext; then \
echo '❌ Found uncommitted Gettext translation changes!' && \
echo '\nModified files:' && \
git diff --name-only priv/gettext | sed 's/^/ - /' && \
echo '\nTo fix this:' && \
echo '1. Run "mix gettext.extract --merge" locally' && \
echo '2. Review and commit the changes' && \
echo '3. Push the updates to your branch\n' && \
exit 1; \
fi
What we do is run mix gettext.extract --merge
to generate translation files. Then, we check git diff
for any uncommitted changes. If they are found, then it means some strings aren’t translated, so we need to go back and do that manually. Of course, in our workflow, we use Cursor together with ChatGPT for translations, but still, that part is not fully automated.
We’re always looking for opportunities to automate any parts of code review that are prone to human errors. We’ve written about our CI in detail here: Optimum Elixir CI with GitHub Actions.
Copy link
copied to clipboard