MCPcopy
hub / github.com/learnhouse/learnhouse / normalize_language

Function normalize_language

apps/api/src/services/email/translations.py:751–756  ·  view source on GitHub ↗

Return a supported locale code, falling back to English.

(lang: str | None)

Source from the content-addressed store, hash-verified

749
750
751def normalize_language(lang: str | None) -> str:
752 """Return a supported locale code, falling back to English."""
753 if not lang:
754 return DEFAULT_LANGUAGE
755 code = lang.split("-")[0].lower()
756 return code if code in SUPPORTED_LANGUAGES else DEFAULT_LANGUAGE
757
758
759def t(lang: str | None, key: str, **fmt) -> str:

Calls

no outgoing calls