It is an improvement to the implementation of django gettext for javascrtipt.
- New I18n view more extensible (build on top of CBV) that exposes the djangojs gettext domain and djsgettext domain generated for translation scrings from js templates. Aditionaly the performance is improved with caching of this view (does not supports by django view as default behavior).
How it works?
The new view is created because the primary view of django is monolitic and not permits expose domains distinct than djangojs and django.
Currently, only is tested with underscore templates. Example:
<div><%= gettext('sample message') %></div> <div><%= ngettext('1 message', 'some messages', num) %></div> <div><%= interpolate(gettext('sample %s'), ) %></div>
How use it?
from djsgettext.views import I18n urlpatterns = patterns('', url(r'^js-gettext/$', I18n.as_view()), )
Collect messages from templates:
python manage.py jsgettext_makemessages