feat: add multilingual glossary support (backend + frontend types)
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 1m31s

Backend:
- Add source_language column to glossaries table
- Add translations JSON column to glossary_terms table
- Alembic migration for schema changes
- format_glossary_for_prompt now language-aware: extracts correct
  translation per target language, falls back to EN reference for
  templates with only FR→EN data
- CRUD routes accept/return source_language and translations
- Pydantic schemas updated

Frontend:
- Types updated: GlossaryTerm now has translations: Record<string, string>
- Glossary/GlossaryListItem now have source_language
- Added SUPPORTED_LANGUAGES constant (13 languages)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-16 15:25:28 +02:00
parent a76f7710e8
commit b2d918c832
8 changed files with 167 additions and 46 deletions

View File

@@ -17,6 +17,9 @@ class GlossaryTermCreate(BaseModel):
target: str = Field(
..., min_length=1, max_length=500, description="Traduction cible"
)
translations: Optional[dict[str, str]] = Field(
None, description="Traductions multilingues: {\"en\": \"coil\", \"de\": \"Spule\", ...}"
)
@field_validator("source", "target")
@classmethod
@@ -30,6 +33,7 @@ class GlossaryTermResponse(BaseModel):
id: str
source: str
target: str
translations: dict[str, str] = {}
created_at: Optional[datetime] = None
model_config = {"from_attributes": True}
@@ -39,6 +43,9 @@ class GlossaryCreate(BaseModel):
"""Schema for creating a glossary."""
name: str = Field(..., min_length=1, max_length=255, description="Nom du glossaire")
source_language: str = Field(
default="fr", max_length=10, description="Langue source (ISO code)"
)
terms: list[GlossaryTermCreate] = Field(
default_factory=list, description="Liste des termes"
)
@@ -53,6 +60,7 @@ class GlossaryUpdate(BaseModel):
"""Schema for updating a glossary (all fields optional)."""
name: Optional[str] = Field(None, min_length=1, max_length=255)
source_language: Optional[str] = Field(None, max_length=10)
terms: Optional[list[GlossaryTermCreate]] = Field(None)
@field_validator("name")
@@ -66,6 +74,7 @@ class GlossaryResponse(BaseModel):
id: str
name: str
source_language: str = "fr"
terms: list[GlossaryTermResponse] = []
created_at: Optional[datetime] = None
updated_at: Optional[datetime] = None
@@ -78,6 +87,7 @@ class GlossaryListItem(BaseModel):
id: str
name: str
source_language: str = "fr"
terms_count: int = Field(
default=0, description="Nombre de termes dans le glossaire"
)