Registry / web-framework / django-statici18n

django-statici18n

JSON →
library2.7.1pypypiunverified

django-statici18n is a Django application designed to compile i18n JavaScript catalogs into static files. This addresses the performance overhead associated with Django's default dynamic `JSONCatalog` view, which generates JavaScript code on each request. The library is actively maintained and supports all officially supported Django versions, currently including 4.2 LTS, 5.2 LTS, and 6.0 series.

pip install django-statici18n
INSTALL
IMPORT
SIG · DJANGO-STATICI18N
D
django-statici18n
web-frameworkpythonv2.7.1
Install
3.5s avg
Import
Disk
66MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.7.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 66.4MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 3.5s · import 0.000s · 67MB
66MB installed
● package 66MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

statici18n
{% load statici18n %}
Used in Django templates to load the provided template tags.
compilejsi18n
python manage.py compilejsi18n
This is a Django management command, not a Python import. It's run from the command line.

To quickly set up `django-statici18n`: 1. Add `statici18n` and `django.contrib.staticfiles` to `INSTALLED_APPS`. 2. Ensure `django.template.context_processors.i18n` is in your `TEMPLATES` context processors. 3. Define `LOCALE_PATHS` in your settings to point to your translation directories. 4. Run `python manage.py makemessages`, then `python manage.py compilemessages` to create and compile your translation files. 5. Execute `python manage.py compilejsi18n` to generate the static JavaScript catalogs. 6. Include the generated script in your templates using `{% load statici18n %}` and `{% statici18n LANGUAGE_CODE %}`.

import os # settings.py # ... INSTALLED_APPS = [ # ... 'django.contrib.staticfiles', 'statici18n', ] TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ # ... 'django.template.context_processors.i18n', ], }, }, ] # Define LOCALE_PATHS to ensure Django finds your translation files LOCALE_PATHS = [ os.path.join(BASE_DIR, 'locale'), ] # Optional: Configure output directory if different from default (STATIC_ROOT/jsi18n) # STATICI18N_ROOT = os.path.join(BASE_DIR, 'static_i18n_output') # STATICI18N_OUTPUT_DIR = 'js_catalogs' # project/templates/base.html (or any template where JS i18n is needed) # ... # {% load static i18n %} # {% load statici18n %} # <script src="{% statici18n LANGUAGE_CODE %}"></script> # ... # After making changes to messages: # python manage.py makemessages -l en # python manage.py compilemessages # python manage.py compilejsi18n # python manage.py collectstatic
Debug
Known issues
gotchaDynamic `JSONCatalog` view performance overhead: Django's default `JSONCatalog` view generates JavaScript catalogs dynamically on each request, which can introduce significant overhead as your site scales. `django-statici18n` solves this by pre-compiling these catalogs into static files.
fix
Implement `django-statici18n` as described in the quickstart to generate and serve static JavaScript catalogs.
affects: All Django versions using `JSONCatalog` without static compilation.
breakingDjango's `JavaScriptCatalog` view, a core component, no longer accepts `mimetype` argument in Django 1.6+. It's been renamed to `content_type`. While `django-statici18n` abstracts this, be aware of underlying Django changes if debugging.
fix
Ensure your Django project is running a version compatible with `django-statici18n` (currently >=4.2) and that no custom code relies on the deprecated `mimetype` argument for `JavaScriptCatalog`.
affects: Django < 1.6
gotchaEmpty or missing JavaScript catalogs after running `compilejsi18n`. This usually indicates that Django cannot find your locale paths or translation files.
fix
Verify that `LOCALE_PATHS` is correctly configured in your `settings.py` to point to the directories containing your `locale` folders. Also, ensure `makemessages` and `compilemessages` were run successfully.
affects: All versions
gotchaStatic files (including i18n catalogs) not served in development or production. `django-statici18n` relies on Django's static files infrastructure.
fix
Ensure `django.contrib.staticfiles` is in `INSTALLED_APPS`, `STATIC_URL` and `STATIC_ROOT` are properly defined, and you are running `collectstatic` in production. For development, ensure `DEBUG = True` and `STATIC_URL` is configured, or explicitly serve static files.
affects: All versions
Upgrade
Version history
2.7.1latest on PyPI · released Mar 15, 2026
Audit
Dependencies
DjangorequiredCore framework dependency, requires >=4.2,<6.1
django-appconfrequiredUsed for managing application settings, requires >=1.0
gettextrequiredRequired by Django's i18n machinery for message compilation (system-level dependency usually)
Agent activity
6 hits · last 30 days
node
6
Resources
django-statici18n — pip install django-statici18n · libregistry