3

I want to use multiple language in my app and for that i have followed this doc

After the creation of django.po inside locale folder, I opened that, as this files contain '#' which told you that which line you can translate. But this file only contain admin part it does not have my app templates i.e., HTML files of my app.

So how I can translate those HTML files, OR what should I have to do so that django.po file can also contain my app templates.

I have followed only this doc.

user1746291
  • 323
  • 2
  • 5
  • 15

1 Answers1

1

You need to use the {% trans %} or {% blocktrans %} template tags in your html files before you run

python manage.py makemessages -l <locale>

If you have done that, and your HTML templates are inside your source tree, then makemessages should pick them up. If you haven't used those template tags, then you won't see any output from them in your .po file.

Ian Clelland
  • 43,011
  • 8
  • 86
  • 87
  • Yes i already did that...but it does not work for me........ Is there anything I have to specify in my model or views ?? – user1746291 Oct 15 '12 at 08:50
  • Is [`USE_IL8N`](https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-USE_I18N) definitely set to `True` in your settings and have you set >1 languages in the [`LANGUAGE`](https://docs.djangoproject.com/en/dev/ref/settings/#languages) setting ? – Timmy O'Mahony Oct 15 '12 at 08:56
  • Even .po files does not pick my models and views – user1746291 Oct 15 '12 at 08:59
  • @TimmyO'Mahony i have used like this `LANGUAGE_CODE = 'en-us' LANGUAGES = ( ('es', 'Spanish'), )` – user1746291 Oct 15 '12 at 09:01
  • Try adding English to the list of `LANGUAGES` too – Timmy O'Mahony Oct 15 '12 at 09:04
  • ok......And there is anything that I have to ** import in models** ..... and now if I run **makemessages**. will it overwrite the existing *.po file* – user1746291 Oct 15 '12 at 09:07
  • @TimmyO'Mahony IN my case it only picks things which are under my **site-packages/django** nothing else – Inforian Oct 15 '12 at 10:02
  • Are you using `manage.py`, or `django-admin.py`? (Not sure that it makes a difference, but often `django-admin.py` won't work properly with anything that depends on your app settings. – Ian Clelland Oct 15 '12 at 14:27