Why doesn't Django create locale files from template files in another directory?

Version Information:

Django version 1.3 pre-alpha SVN-13858

Ubuntu GNU / Linux 10.10

I am completely new to i18n and l10n in Django, and I'm currently trying to make my Django project available in Dutch (in addition to its default language: English). I tried to apply the instructions given at http://docs.djangoproject.com/en/dev/topics/i18n/translation/ and http://www.djangobook.com/en/2.0/chapter19/ , but I did not succeed . I do not know if this is due to my directory structure and template files located in a completely different directory (I do not mean as a subdirectory in my Django project directory). My project directory is as follows:

/home/emre/mydjango/myproject /home/emre/mydjango/myproject/myapp1 /home/emre/mydjangotemplates /home/emre/mydjangotemplates/myapp1 

In the directories myproject and myapp1, I tried to run the following command:

 django-admin.py makemessages -l nl 

But received the following error:

 Error: This script should be run from the Django SVN tree or your project or app tree. If you did indeed run it from the SVN checkout or your project or application, maybe you are just missing the conf/locale (in the django tree) or locale (for project and application) directory? It is not created automatically, you have to create it by hand if you want to enable i18n for your project or application. 

So, I tried to create the locale directories in the myproject and myapp1 directories. After that, I again issued the above command (once in the project and once in the application directory), and this time without any errors or warnings, he said:

 processing language nl 

I checked the locale directories and saw that they were filled with sub-directories, but there were no .po files:

 $ tree . `-- nl `-- LC_MESSAGES 2 directories, 0 files 

I double-checked that I have my .html files (template files) in home / emre / mydjangotemplates and that they include {% load i18n%} and some lines like {% trans "Part of the English text"%} .

What am I missing? Should I call the django-admin.py makemessages command with different parameters? Why doesn't Django create .po files even if I have text to translate into my .html template files?

+5
source share
1 answer

makemessages is viewed only in directories in the current directory. You can try creating a symbolic link from your project to your templates directory and adding - s to make it follow symbolic links .

+9
source

Source: https://habr.com/ru/post/900511/


All Articles