1

If I execute the following in a Divio Cloud (formerly known as "Aldryn") project:

docker-compose run --rm web python manage.py makemessages

I get:

CommandError: Can't find xgettext. Make sure you have GNU gettext tools 0.15 or newer installed.

  • Is running `manage.py makemessages the right way to create / update message files on Divio Cloud?

As a workaround I have added this to the Dockerfile:

# add gettext for manage.py makemessages RUN apt-get update && apt-get install -y gettext

and then

docker-compose build web

  • Also, will the .mo files be compiled on Divio Cloud deployment or does one have to precompile them?
Daniele Procida
  • 1,477
  • 10
  • 27
Mario
  • 2,619
  • 1
  • 24
  • 22

1 Answers1

4

Currently Aldryn does not support generating the .mo files for you. While waiting for Aldryn itself to provide support for this out of the box, you can work around the issue by editing the Dockerfile, as you already did:

1) Towards the top, just before the # <DOCKER_BUILD>, add the following command (as you already pointed out):

# add gettext for manage.py makemessages 
RUN apt-get update && apt-get install -y gettext && apt-get clean && rm -rf /var/lib/apt/lists/*

2) At the bottom, just after the # </DOCKER_BUILD>, add the following command:

# compile the messages
RUN DJANGO_MODE=build python manage.py compilemessages

Edit: If you're using baseproject>=3.13.1, step 1) is not needed anymore.

GaretJax
  • 7,462
  • 1
  • 38
  • 47
  • It's strange but at `docker-compose build web` I get `CommandError: This script should be run from the Django Git checkout or your project or app tree, or with the settings module specified.`, whatever I try. I get the same error from `docker-compose run --rm web`. `pwd` shows `/app`. Dockerfile: https://gist.github.com/macolo/d7d31b17e3b31becdac39ca6354385dc – Mario May 08 '16 at 20:04
  • 1
    Where is your `locale` folder? Mine is at `/app/locale`, and it's the only one which is getting compiled. By looking at the django source, that error is raised when no `locale` directories are found in the pwd: https://github.com/django/django/blob/master/django/core/management/commands/compilemessages.py#L69-L81 – GaretJax May 09 '16 at 08:05
  • Thx for the hint, indeed I got confused by the error message. There was no locales folder in that project. Many thanks again. – Mario May 09 '16 at 08:18