From 79be6ed4e4e8527a52e06c4be44fde2e9951cecf Mon Sep 17 00:00:00 2001 From: Egor fureunoir Gorbunov Date: Fri, 27 Feb 2026 19:02:55 +0300 Subject: [PATCH] feat(demo_data): use translation override to ensure consistent locale wraps actions in a `with override("en")` block to enforce the use of the English locale during execution. This ensures consistent behavior and message formatting regardless of the server's default language settings. --- engine/core/management/commands/demo_data.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/engine/core/management/commands/demo_data.py b/engine/core/management/commands/demo_data.py index 195f4dca..3858ab6e 100644 --- a/engine/core/management/commands/demo_data.py +++ b/engine/core/management/commands/demo_data.py @@ -10,6 +10,7 @@ from django.core.files.base import ContentFile from django.core.management.base import BaseCommand from django.db import transaction from django.utils import timezone +from django.utils.translation import override from engine.blog.models import Post, PostTag from engine.core.models import ( @@ -86,12 +87,13 @@ class Command(BaseCommand): self._load_demo_data() - if action == "install": - self._install(options) - elif action == "remove": - self._remove() - else: - self.stdout.write(self.style.ERROR(f"Unknown action: {action}")) + with override("en"): + if action == "install": + self._install(options) + elif action == "remove": + self._remove() + else: + self.stdout.write(self.style.ERROR(f"Unknown action: {action}")) @property def staff_user(self):