[Django]-Django Translation on Heroku is not fully working

2👍

After some research, I found it’s better to commit the compiled messages files (*.mo) to Heroku, and translation will work properly.

2👍

You can generate those files during the build.

Add a post compile file in bin/post_compile (no extension like procfile) with the following line:

python manage.py compilemessages

Optionally you can add the specific language (e.g. python manage.py compilemessages -l nl)

Since Heroku 20, gettext is automatically added for the default Python build package. This is only during build and not at runtime. Therefore the command should be added in post_compile and not under release: in the procfile.

Older info links to buildpacks for gettext on Heroku (e.g. in the question above). Those are not needed anymore with this configuration.

👤takje

Leave a comment