Skip to main content

Inline translation string editing for Django

Project description

django-cartouche

CI

codecov

Inline .po translation editing for Django. Click on any translated string in the browser to edit it directly during development.

Installation

Install as a development dependency:

pip install django-cartouche --group dev
# or with uv
uv add django-cartouche --dev

Configuration

django-cartouche should only be installed in development environments. Configure it in your local/development settings file (e.g., settings/local.py or settings/dev.py):

# settings/local.py

from .base import *

DEBUG = True

INSTALLED_APPS += [
    "cartouche",
]

MIDDLEWARE += [
    "cartouche.middleware.CartoucheMiddleware",  # Must be after LocaleMiddleware
]

Conditionally include URLs in your urls.py:

from django.conf import settings

urlpatterns = [
    # ...
]

if settings.DEBUG:
    urlpatterns += [
        path("cartouche/", include("cartouche.urls")),
    ]

Set the lang attribute on your <html> element for locale detection:

<html lang="{{ LANGUAGE_CODE }}">

The editor only activates when DEBUG=True, but following these practices ensures cartouche is never present in production.

Development

uv sync                              # Install dependencies
uv run pre-commit install            # Install git hooks (one-time)
cd demo && python manage.py runserver  # Run demo server
ruff check src/ && ruff format src/  # Lint and format
pytest --cov                         # Run tests with coverage

Making Commits

Use the interactive CLI for guided conventional commits:

uv run cz commit

Or use standard git with conventional format:

git commit -m "feat: add new feature"
git commit -m "fix(compiler): handle edge case"

Feedback

If you end up using django-cartouche, I'd genuinely like to hear about your experience. Whether you've found it helpful, run into issues or have ideas for improvements, your feedback is welcome.

Share your feedback here →

Project details


Download files

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

Source Distribution

django_cartouche-0.1.0.tar.gz (76.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_cartouche-0.1.0-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file django_cartouche-0.1.0.tar.gz.

File metadata

  • Download URL: django_cartouche-0.1.0.tar.gz
  • Upload date:
  • Size: 76.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.2

File hashes

Hashes for django_cartouche-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c53be56fcb2f4b9a1f2f9e6aeea1f7bad224aa281cf42f1e3175326209b1500d
MD5 2ca70010ce3989f4115ec2dbdf307743
BLAKE2b-256 29c5b2845946e28007bea3fdcf2a045149bcce32eebb339435ccf5d5e826cf3e

See more details on using hashes here.

File details

Details for the file django_cartouche-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_cartouche-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 568f96cbd24bce87cd2d62c57c3467f944f501a767f788dde562a5353748a9ee
MD5 e2dd3361c630fb374518278d1ba86eaf
BLAKE2b-256 53149e01157ae15f1c2cf9ec42990612d1ca1a1b6dda7e3e2808926fe97c9ae3

See more details on using hashes here.

Supported by

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