You must create locale
folder just under your django-project
folder as shown below. *The folder name must be locale
according to my experiments:
django-project
|-core
| └-settings.py
|-app1
| |-models.py
| └-admin.py
|-app2
| |-models.py
| └-admin.py
└-locale # Here
Then, you can create django.po
in each locale/<...>/LC_MESSAGES/
with the command below. *The command below can create or update one or more django.po
:
django-admin makemessages --locale=en --locale=fr --locale=ja
Or:
django-admin.py makemessages -l en -l fr -l ja
Then, django.po
is created in each locale/<...>/LC_MESSAGES/
as shown below:
django-project
|-core
| └-settings.py
|-app1
| |-models.py
| └-admin.py
|-app2
| |-models.py
| └-admin.py
└-locale
|-en
| └-LC_MESSAGES
| └-django.po # Here
|-fr
| └-LC_MESSAGES
| └-django.po # Here
└-ja
└-LC_MESSAGES
└-django.po # Here
And, you can update all django.po
in locale
folder with the command below. *With the command below, you can only update django.po
but cannot create django.po
:
django-admin makemessages --all
Or:
django-admin makemessages -a
And, you can compile django.po
to django.mo
in each locale/<...>/LC_MESSAGES/
with the command below:
django-admin compilemessages
Then, django.po
is compiled to django.mo
in each locale/<...>/LC_MESSAGES/
as shown below:
django-project
|-core
| └-settings.py
|-app1
| |-models.py
| └-admin.py
|-app2
| |-models.py
| └-admin.py
└-locale
|-en
| └-LC_MESSAGES
| |-django.po
| └-django.mo # Here
|-fr
| └-LC_MESSAGES
| |-django.po
| └-django.mo # Here
└-ja
└-LC_MESSAGES
|-django.po
└-django.mo # Here
In addition, even if you create locale
folder just under core
, app1
and app2
folders as shown below:
django-project
|-core
| |-settings.py
| └-locale # Here
|-app1
| |-models.py
| |-admin.py
| └-locale # Here
└-app2
|-models.py
|-admin.py
└-locale # Here
Then, run the command below:
django-admin.py makemessages -l en -l fr -l ja
Then, you will still get the error below according to my experiments and opposed to How Django discovers translations so you must create locale
folder just under your django-project
folder:
CommandError: Unable to find a locale path to store translations for
file manage.py. Make sure the 'locale' directory exists in an app or
LOCALE_PATHS setting is set.
makemessages
command from thatlocale
directory if it's already available. – Proctology