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:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user