Search code examples
pythondjangodjango-appsdjango-i18n

How do I run makemessages so it includes some apps that are outside the Django project?


I have the following structure:

.
├── apps
│   ├── app1
│   │   ├── app1
│   │   └── setup.py
│   ├── app2
│   │   ├── app2
│   │   └── setup.py
├── my_django_project
│   ├── appA
│   ├── appB
│   ├── my_django_project
│   ├── db.sqlite3
│   ├── manage.py
│   └── requirements.txt
├── deployment
│   └── some files
├── locale
│   └── fr
│       └── LC_MESSAGES
│           ├── django.mo
│           └── django.po
├── log
│   └── some files
├── media
├── README.rst
├── run
│   └── some files
└── static

I have started to translate my project. I have sucessfully translated everything that was in my_django_project which is the actual django project. I have 2 apps installed with python setup.py develop, that are located outside the django project scope. I don't seem to be able to run the makemessages command. Running it with the manage.py helper doesn't find the apps in the apps folder. i.e nothing has been added to locale/fr/LC_MESSAGES/django.po. It worked fine for appA and appB located in my_django_project.

How do I run make messages for these apps located outside the django project ?


Solution

  • I need to create symlinks in the django project:

    cd my_django_project
    ln -s ../apps/app1/app1 .
    

    and then I need to add an extra parameter to follow synlinks:

    ./manage.py makemessages -l fr --symlinks
    

    EDIT:

    A better way to fix this is to add a locale directory in the folder app, and to run the following command (in the app folder):

    django-admin makemessages -l fr
    

    And then messages are compiled by running the foloowing command (run in the app folder):

    django-admin compilemessages