INNER CODE UNIT · Python
get_locale
GHJJ123/brainrotguard · i18n/__init__.py:36
def get_locale(config) -> str:
"""Extract normalized locale from config."""
app = getattr(config, "app", None)
return normalize_locale(getattr(app, "locale", DEFAULT_LOCALE))
def normalize_time_format(value: str | None) -> str:
"""Normalize configured time format to a supported value."""
if not value:
return DEFAULT_TIME_FORMAT
normalized = value.strip().lower().replace("_", "").replace("-", "")
if normalized in ("locale", "default", "auto"):
return "locale"
if normalized in ("12h", "12hr", "12hour", "ampm"):
return "12h"
if normalized in ("24h", "24hr", "24hour"):
return "24h"
return DEFAULT_TIME_FORMAT