Skip to main content

Improved and complement gettext support for javascript for Django

Project description

It is an improvement to the implementation of django gettext for javascrtipt.

Features:

  • Now parse javascript teplates for translatable strings (tested with underscore.template)

  • 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?

Django makemesages command generates a djangojs domain po file from *.js files, django-jsgettext generates a djgettext domain po file from .html files (javascript templates) and the new view exposes the two gettext domains to the javascript.

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'), [1]) %></div>

How use it?

Urls files:

from djsgettext.views import I18n

urlpatterns = patterns('',
    url(r'^js-gettext/$', I18n.as_view()),
)

Collect messages from templates:

python manage.py jsgettext_makemessages

Project details


Release history Release notifications | RSS feed

This version

0.5

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-jsgettext-0.5.tar.gz (5.4 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page