wesley tanaka

Caching decorator for Django /jsi18n/

This Django app contains a decorator function which allows the /jsi18n/ django.views.i18n.javascript_catalog to be cached by the browser.  It assumes that your site is using version numbers in URLs similar to the way that is described on page 30 of the presentation slides for the "Engaging User Experiences with Google App Engine" Google I/O talk.  This has been tested with the stock Django 0.96 included in Google App Engine.

Download

The source code is on GitHub.

Installation

  1. Copy the entire jsi18ncache/ directory into your django project alongside your other django apps.
  2. Add 'jsi18ncache' to INSTALLED_APPS in settings.py
  3. In your urls.py, change
    (r'^jsi18n/$', 'django.views.i18n.javascript_catalog', js_info_dict),
    to
    (r'^.*/jsi18n/$', 'jsi18ncache.views.javascript_catalog', js_info_dict),
  4. Change the <script> tag in your your HTML templates and pages to something along the lines of:
    {% load i18n %}
    {% get_current_language as LANGUAGE_CODE %}
    <script type="text/javascript" src="/{{appversion}}/jsi18n/?language={{LANGUAGE_CODE}}"></script>

Suggested Links

Syndicate content