feat(backend): drop dictionary dialect columns, add allowed_languages

- Removes source_dialect and target_dialect from TerminologyDictionary model,
  schemas, routes, helper serialization, and all tests
- Adds allowed_languages config field (BCP-47 language codes) to GlobalSettings
  with validation, consolidated settings response, and API endpoint
- Adds alembic migration f1a2b3c4d5e6 to drop the two columns
This commit is contained in:
2026-06-03 11:48:03 +03:00
parent 236dadb914
commit 1e6ec34c2b
15 changed files with 129 additions and 67 deletions

View File

@@ -141,6 +141,26 @@ class GlobalSettings(BaseModel):
# Global worker limit for concurrent validation runs
GLOBAL_VALIDATION_WORKER_LIMIT: int = 3
# Allowed languages for translation (BCP-47 codes)
allowed_languages: list[str] = Field(
default_factory=lambda: [
"ru", "en", "de", "fr", "es", "it", "pt", "zh", "ja", "ko",
"ar", "tr", "nl", "pl", "sv", "da", "fi", "cs", "hu", "ro",
"vi", "th", "he", "id", "ms",
]
)
@field_validator("allowed_languages")
@classmethod
def validate_allowed_languages(cls, v: list[str]) -> list[str]:
import re
for tag in v:
if not tag or not tag.strip():
raise ValueError("Empty language code is not allowed")
if not re.match(r'^[a-zA-Z]{2,8}(-[a-zA-Z0-9]{1,8})*$', tag.strip()):
raise ValueError(f"Invalid BCP-47 language code: {tag}")
return v
# #endregion GlobalSettings