🌐(backend) internationalize demo

This allows the demo to generate user and filenames with other locales
than English, for all languages defined in the project's settings.
In particular, it allows the generation of accented names, which were
previously missing.
This commit is contained in:
Sylvain Boissel
2025-11-23 11:42:46 +01:00
parent a49f3b6b32
commit 08fb191e6b
2 changed files with 5 additions and 4 deletions

View File

@@ -13,6 +13,7 @@ and this project adheres to
### Changed
- 🚸(backend) use unaccented full name for user search #1637
- 🌐(backend) internationalize demo #1644
## [4.1.0] - 2025-12-09

View File

@@ -17,7 +17,8 @@ from core import models
from demo import defaults
fake = Faker()
languages = [x for (x, y) in settings.LANGUAGES]
fake = Faker(languages)
logger = logging.getLogger("impress.commands.demo.create_demo")
@@ -127,7 +128,7 @@ def create_demo(stdout):
is_staff=False,
short_name=first_name,
full_name=f"{first_name:s} {random.choice(last_names):s}",
language=random.choice(settings.LANGUAGES)[0],
language=random.choice(languages),
)
)
queue.flush()
@@ -179,8 +180,7 @@ def create_demo(stdout):
is_superuser=False,
is_active=True,
is_staff=False,
language=dev_user["language"]
or random.choice(settings.LANGUAGES)[0],
language=dev_user["language"] or random.choice(languages),
)
)