wahnsinn vibe
This commit is contained in:
16
backend/core/i18n.py
Normal file
16
backend/core/i18n.py
Normal file
@@ -0,0 +1,16 @@
|
||||
"""Tiny i18n helper for DE/EN content stored as {'de': ..., 'en': ...} dicts."""
|
||||
from typing import Any
|
||||
|
||||
DEFAULT_LOCALE = "de"
|
||||
SUPPORTED = ("de", "en")
|
||||
|
||||
|
||||
def pick(field: dict[str, Any] | None, locale: str = DEFAULT_LOCALE) -> str:
|
||||
if not field:
|
||||
return ""
|
||||
return field.get(locale) or field.get(DEFAULT_LOCALE) or next(iter(field.values()), "")
|
||||
|
||||
|
||||
def normalize(field: dict[str, Any] | None) -> dict[str, str]:
|
||||
field = field or {}
|
||||
return {lang: str(field.get(lang, "")) for lang in SUPPORTED}
|
||||
Reference in New Issue
Block a user