Django support for translations in Javascript files

I read and followed the instructions in here , but can't seem to see the line in javascript in the po file.

structure of my project is: 
cb/    
   cb_app    
   cb    
   static_files    
   templates

First I copied them to my url.py:

js_info_dict = {
    'packages': ('cb_app',),
}

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

Then I added this script to my html:

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

The actual script where I would like to get the translation is just as simple:

$(document).ready(function () { 
    $('#id_sales_item').chosen({no_results_text: gettext('No results match')}); 
});

... and is used in the same html.

So what else do I need to do?

All I did then was run the line below both from cb/cband from cb/cb_app.

django-admin.py makemessages -l en_GB

But still, there are no signs of โ€œNo matching resultsโ€ in cb/cb/localeor incb/cb_app/locale

Any tips?

+5
source share
1 answer

I finally found a problem.

Django Django. , locale. javascript- . .

, , - settings.py (. ):

LOCALE_PATHS = ( '/home/kave/projects/cb/locale',)

locale project (. )

url.py html (. ).

, , , project-root-directory: /home/kave/projects/cb :

django-admin.py makemessages -l en_GB
django-admin.py makemessages -d djangojs -l en_GB

, . javascript po.

.

+4

All Articles