Return a supported locale code, falling back to English.
(lang: str | None)
| 749 | |
| 750 | |
| 751 | def 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 | |
| 759 | def t(lang: str | None, key: str, **fmt) -> str: |
no outgoing calls