Search code examples
javascriptdjangodjango-i18n

jsi18n django.catalogue doesn't contain any translated strings (but djangojs.mo does)


So I just translated a javascript djangojs.po file in a django project. Then:

./manage.py compilemessages -l fr #correctly creates my djangojs.mo file

Edit my urls.py

js_info_dict = {
    'domain': 'djangojs',
    'packages': ('my_app',),
}
#add to urlpatterns = patterns('',
...
url(r'^jsi18n/', 'django.views.i18n.javascript_catalog', js_info_dict),

I head over to http://localhost:8000/jsi18n/ in my browser. I get a nice js file, but the django.catalogue is empty.

django.catalog = django.catalog || {};

So where did my translation strings go?

FYI, translation works fine on my template code with the django.mo file in the same directory as djangojs.mo. Django 1.9.6.


Solution

  • I'm going to post this answer as a monument to my stupidity. Hopefully it's useful for someone else.

    I wasn't logged in, and had session authentication enabled. Evidently, /jsi18n/ isn't a @login_required url, but it doesn't pull the strings out of the django.mo file until you do login.