I tried to follow the guide but it's not clear enough.
I added this to my urls.py
urlpatterns = patterns('', (r'^jsi18n/(?P<packages>\S+?)/$', 'django.views.i18n.javascript_catalog'), )
Generated the lang files using this command:
django-admin.py makemessages -d djangojs -l fr
root_folder/locale/fr/LC_MESSAGES
now contain django.po
& djangojs.po
and alert(gettext('this is to be translated'));
in one of my js files was picked up in djangojs.po
.
I ran
django-admin.py compilemessages
and restarted the server.Added this to my base.html:
<script type="text/javascript" src="{% url 'django.views.i18n.javascript_catalog' 'locale' %}" >< /script >
Note that I added 'locale' to avoid the exception of not passing the package name when dynamically loading translations.
Visited
/jsi18n/locale/
from my browser and all I get is Django translation functions:/* gettext library */ var catalog = new Array(); function pluralidx(count) { return (count == 1) ? 0 : 1; } function gettext(msgid) { ....
Why 'this is to be translated' is not showing and on which basis it will show a specific language without passing it with the URL?