views:

41

answers:

1

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/howto/i18n/ 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?

+1  A: 

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.

Ofri Raviv
I created symbolic links to template directory from project and app directories, and then tried the same command, same result. Then deleted the locale sub-directories, re-created them, tried it, same result, then also tried as django-admin.py makemessages -a, but unfortunately all I get is an empty locale/nl/LC_MESSAGES/ directory within my project and app folders.
Emre Sevinç
try added --verbosity 2 to the end of the command. it should print what it is doing, maybe it will give some clue.
Ofri Raviv
I did and it seems like it is not traversing the subdirectories that are normally reachable by following the symlink: examining files with the extensions: .htmlprocessing language nlignoring file models.py~ in .ignoring file urls.py~ in .ignoring file views.py~ in .processing file __init__.py in .processing file models.py in .processing file tests.py in .processing file urls.py in .processing file views.py in
Emre Sevinç
then add -s or --symlink
Ofri Raviv
Thanks a lot, it works with --symlink
Emre Sevinç