{"id":15024441,"url":"https://github.com/zyegfryed/django-statici18n","last_synced_at":"2025-05-15T16:05:40.042Z","repository":{"id":2894242,"uuid":"3901824","full_name":"zyegfryed/django-statici18n","owner":"zyegfryed","description":"A Django app that compiles i18n JavaScript catalogs to static files.","archived":false,"fork":false,"pushed_at":"2024-11-28T09:03:26.000Z","size":395,"stargazers_count":66,"open_issues_count":1,"forks_count":25,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-12T23:46:07.668Z","etag":null,"topics":["catalog","django","i18n","python","python3"],"latest_commit_sha":null,"homepage":"https://django-statici18n.readthedocs.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zyegfryed.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2012-04-02T15:05:48.000Z","updated_at":"2024-11-28T08:49:47.000Z","dependencies_parsed_at":"2024-04-20T10:32:24.903Z","dependency_job_id":"27ba600c-97c8-424f-a199-743a613f0364","html_url":"https://github.com/zyegfryed/django-statici18n","commit_stats":{"total_commits":304,"total_committers":27,"mean_commits":11.25925925925926,"dds":0.5723684210526316,"last_synced_commit":"9b83a8f0f2e625dd5f56d53cfe4e07aca9479ab6"},"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zyegfryed%2Fdjango-statici18n","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zyegfryed%2Fdjango-statici18n/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zyegfryed%2Fdjango-statici18n/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zyegfryed%2Fdjango-statici18n/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zyegfryed","download_url":"https://codeload.github.com/zyegfryed/django-statici18n/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254374427,"owners_count":22060611,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["catalog","django","i18n","python","python3"],"created_at":"2024-09-24T20:00:21.770Z","updated_at":"2025-05-15T16:05:40.017Z","avatar_url":"https://github.com/zyegfryed.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"django-statici18n\n=================\n\n.. image:: https://github.com/zyegfryed/django-statici18n/actions/workflows/build.yml/badge.svg?branch=main\n   :alt: Build Status\n   :target: https://github.com/zyegfryed/django-statici18n/actions\n\n.. image:: https://codecov.io/gh/zyegfryed/django-statici18n/branch/main/graph/badge.svg?token=xiaDYAr30F\n   :target: https://codecov.io/gh/zyegfryed/django-statici18n\n\nOverview\n--------\n\nWhen dealing with internationalization in JavaScript code, Django provides\nthe `JSONCatalog view`_ which sends out a JavaScript code library with\nfunctions that mimic the gettext interface, plus an array of translation\nstrings.\n\nAt first glance, it works well and everything is fine. But, because\n`JSONCatalog view`_ is generating JavaScript catalog dynamically on each\nand every request, it's `adding an overhead`_ that can be an issue with\nsite growth.\n\nThat's what ``django-statici18n`` is for:\n\n    Collecting JavaScript catalogs from each of your Django apps (and any\n    other place you specify) into a single location that can easily be\n    served in production.\n\nThe main website for ``django-statici18n`` is\n`github.com/zyegfryed/django-statici18n`_ where you can also file tickets.\n\n.. _JSONCatalog view: https://docs.djangoproject.com/en/3.2/topics/i18n/translation/#the-jsoncatalog-view\n.. _adding an overhead: https://docs.djangoproject.com/en/3.2/topics/i18n/translation/#note-on-performance\n.. _github.com/zyegfryed/django-statici18n: https://github.com/zyegfryed/django-statici18n\n\nSupported Django Versions\n-------------------------\n\n``django-statici18n`` works with all the Django versions officially\nsupported by the Django project. At this time of writing, these are the\n4.2 (LTS), 5.0 and 5.1 series.\n\nInstallation\n------------\n\n1. Use your favorite Python packaging tool to install ``django-statici18n``\n   from `PyPI`_, e.g.::\n\n    pip install django-statici18n\n\n2. Add ``'statici18n'`` to your ``INSTALLED_APPS`` setting::\n\n    INSTALLED_APPS = [\n        # ...\n        'statici18n',\n    ]\n\n3. Once you have `translated`_ and `compiled`_ your messages, use the\n   ``compilejsi18n`` management command::\n\n    python manage.py compilejsi18n\n\n4. Add the `django.core.context_processors.i18n`_ context processor to the\n   ``context_processors`` section for your backend in the ``TEMPLATES``\n   setting - it should have already been set by Django::\n\n    TEMPLATES = [\n      {\n        # ...\n        'OPTIONS': {\n          'context_processors': {\n            # ...\n            'django.template.context_processors.i18n',\n          },\n        },\n      },\n    ]\n\n5. Edit your template(s) and replace the `dynamically generated script`_ by the\n   statically generated one:\n\n  .. code-block:: html+django\n\n    \u003cscript src=\"{{ STATIC_URL }}jsi18n/{{ LANGUAGE_CODE }}/djangojs.js\"\u003e\u003c/script\u003e\n\n.. note::\n\n    By default, the generated catalogs are stored to ``STATIC_ROOT/jsi18n``.\n    You can modify the output path and more options by tweaking\n    ``django-statici18n`` settings.\n\n**(Optional)**\n\nThe following step assumes you're using `django.contrib.staticfiles`_.\n\n5. Edit your template(s) and use the provided template tag:\n\n  .. code-block:: html+django\n\n    {% load statici18n %}\n    \u003cscript src=\"{% statici18n LANGUAGE_CODE %}\"\u003e\u003c/script\u003e\n\n6. Or inline the JavaScript directly in your template:\n\n  .. code-block:: html+django\n\n    {% load statici18n %}\n    \u003cscript\u003e{% inlinei18n LANGUAGE_CODE %}\u003c/script\u003e\n\n.. _PyPI: http://pypi.python.org/pypi/django-statici18n\n.. _translated: https://docs.djangoproject.com/en/4.2/topics/i18n/translation/#message-files\n.. _compiled: https://docs.djangoproject.com/en/4.2/topics/i18n/translation/#compiling-message-files\n.. _django.core.context_processors.i18n: https://docs.djangoproject.com/en/4.2/ref/templates/api/#django-template-context-processors-i18n\n.. _Upgrading templates to Django 1.8: https://docs.djangoproject.com/en/2.2/ref/templates/upgrading/\n.. _dynamically generated script: https://docs.djangoproject.com/en/4.2/topics/i18n/translation/#using-the-javascript-translation-catalog\n.. _django.contrib.staticfiles: https://docs.djangoproject.com/en/4.2/ref/contrib/staticfiles/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzyegfryed%2Fdjango-statici18n","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzyegfryed%2Fdjango-statici18n","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzyegfryed%2Fdjango-statici18n/lists"}