robos85
robos85

Reputation: 2554

Django - JavaScript translation problem

Hi I have a problem with JS translation in Django. I did everything like is said in documentation, so: I made .po then .mo files (django.mo, djangojs.mo). Translated files are in path: *myapp/locale/pl/LC_MESSAGES/* and *myapp/locale/en/LC_MESSAGES/* Translations in .html and .py files work OK. The only problem is that JS translation always displays original phrase, not translated. main urls.py:

urlpatterns += patterns('', (r'^jsi18n/$', 'django.views.i18n.javascript_catalog',{}), )

template file in header (as first JS part):

<script type="text/javascript" src="{% url django.views.i18n.javascript_catalog %}"></script>

All my js files are in path /myapp/site_media/js/ and the only .mo files are in path which I wrote before. I use gettext() in JS strings.

What did I do wrong?

Upvotes: 2

Views: 2322

Answers (1)

mkriheli
mkriheli

Reputation: 1846

To use the jsi18n view you have 2 options:

  1. Specify the desired translation packages in the dict passed to the view, which will be combined (you've specified an empty dict - hence no packages)
  2. Catch the packages parameter in the url pattern, and specify the package names in the url, separated with +.

This is described in the javascript_catalog documentation. Maybe you've missed it. I suggest taking another look:

Upvotes: 2

Related Questions