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

@@ -71,6 +71,7 @@ export function EditGlossaryDialog({
id: `temp-${i}`,
source: t.source,
target: t.target,
translations: t.translations || {},
created_at: null,
})),
};

View File

@@ -2,12 +2,14 @@ export interface GlossaryTerm {
id: string;
source: string;
target: string;
translations: Record<string, string>;
created_at: string | null;
}
export interface Glossary {
id: string;
name: string;
source_language: string;
terms: GlossaryTerm[];
created_at: string;
updated_at: string;
@@ -16,6 +18,7 @@ export interface Glossary {
export interface GlossaryListItem {
id: string;
name: string;
source_language: string;
terms_count: number;
created_at: string;
}
@@ -48,6 +51,7 @@ export interface GlossaryUpdateResponse {
export interface GlossaryTermInput {
source: string;
target: string;
translations?: Record<string, string>;
}
export interface GlossaryTermInputWithId extends GlossaryTermInput {
@@ -56,16 +60,34 @@ export interface GlossaryTermInputWithId extends GlossaryTermInput {
export interface GlossaryCreateInput {
name: string;
source_language?: string;
terms?: GlossaryTermInput[];
}
export interface GlossaryUpdateInput {
name?: string;
source_language?: string;
terms?: GlossaryTermInput[];
}
export const MAX_TERMS_PER_GLOSSARY = 500;
export const SUPPORTED_LANGUAGES: { code: string; label: string; flag: string }[] = [
{ code: 'en', label: 'English', flag: '🇬🇧' },
{ code: 'fr', label: 'Français', flag: '🇫🇷' },
{ code: 'es', label: 'Español', flag: '🇪🇸' },
{ code: 'de', label: 'Deutsch', flag: '🇩🇪' },
{ code: 'pt', label: 'Português', flag: '🇧🇷' },
{ code: 'it', label: 'Italiano', flag: '🇮🇹' },
{ code: 'nl', label: 'Nederlands', flag: '🇳🇱' },
{ code: 'ru', label: 'Русский', flag: '🇷🇺' },
{ code: 'ja', label: '日本語', flag: '🇯🇵' },
{ code: 'ko', label: '한국어', flag: '🇰🇷' },
{ code: 'zh', label: '中文', flag: '🇨🇳' },
{ code: 'ar', label: 'العربية', flag: '🇸🇦' },
{ code: 'fa', label: 'فارسی', flag: '🇮🇷' },
];
// Generate unique IDs for React keys
let idCounter = 0;
export function generateTermId(): string {