Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Version info:

Django version 1.3 pre-alpha SVN-13858

Ubuntu GNU/Linux 10.10

I'm totally new to i18n and l10n in Django and currently I'm 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 had no success. I don't know if this is related to my directory structure and template files being in a completely different directory (I mean not as a subdirectory within the my Django project directory). My project directory looks like the following:

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

In the myproject and myapp1 directories I tried to issue 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 locale directories within myproject and myapp1 directories. After that I issued the above command again (once in the project and once in the app directory) and this time without any error or warnings it said:

processing language nl

I checked the locale directories and saw that they were populated with sub-directories but there weren't any .po files at all:

$ 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 "A piece of English text" %}.

What am I missing? Should I invoke the django-admin.py makemessages command with different parameters? Why doesn't Django create .po files even though I have some text to be translated in my .html template files?

like image 929
Emre Sevinç Avatar asked Sep 16 '10 12:09

Emre Sevinç


1 Answers

makemessages only looks in directories under the current directory. You can try creating a symlink from somewhere under your project to your templates directory and add the -s to make it follow symlinks.

like image 109
Ofri Raviv Avatar answered Nov 03 '22 00:11

Ofri Raviv