Skip to content

[audit] LANGUAGE_CODE / gettext / Accept-Language not honored — SPA UI and translated verbose_name / action descriptions stay English #630

@MartinCastroAlvarez

Description

@MartinCastroAlvarez

Adoption pain point

Zero references to `gettext`, `activate`, `Accept-Language`, or `LANGUAGE_CODE` in the API package (verified). A consumer running Django with:

```python
LANGUAGE_CODE = "es-ar"
USE_I18N = True
LANGUAGES = [("es", "Español"), ("en", "English")]
MIDDLEWARE = [..., "django.middleware.locale.LocaleMiddleware", ...]

class CuentaAdmin(admin.ModelAdmin):
class Meta:
verbose_name = _("Cuenta")
verbose_name_plural = _("Cuentas")

@admin.action(description=_("Marcar como pagado"))
def mark_paid(self, request, queryset): ...

```

...sees raw English strings in the SPA: the package name, action descriptions, `help_text`, `verbose_name`, even though every other surface in the app (legacy admin, frontend, error pages) is correctly translated.

What stock Django gets

Django's `LocaleMiddleware` activates the request's locale per Accept-Language header. The HTML admin auto-translates every `gettext_lazy` string at render time. Stock behavior; zero ModelAdmin config.

Suggested fix

Two pieces, both required:

API side. Activate the request locale (`django.utils.translation.activate(get_language_from_request(request))`) before computing the JSON payload, so any `gettext_lazy` proxies in `verbose_name` / `description` / `help_text` resolve to translated strings. `LocaleMiddleware` does this for the legacy HTML admin automatically — the API package needs to either keep `LocaleMiddleware` in the stack OR explicitly activate per request.

SPA chrome side. The SPA's own strings ("Add", "Search", "Loading…", "Save and continue editing", "Confirm delete", etc.) are hard-coded English in `@dar/web`. Internationalize via a small message catalog (`@dar/i18n` package) keyed off the active locale from a new `config.language` wire field.

Filed by

Audit triage 2026-05-30. Adoption blocker for any non-English-primary shop.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions