Skip to content

Commit

Permalink
Process cases when headers are empty or Accept-Language is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
insolor committed Jul 21, 2024
1 parent 29a108e commit 1a70418
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions package_build/i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@


def get_preferred_languages() -> list[str]:
headers = _get_websocket_headers()
return re.findall(r"([a-zA-Z-]{2,})", headers["Accept-Language"]) or []
headers = _get_websocket_headers() or {}
accept_language = headers.get("Accept-Language") or ""
return re.findall(r"([a-zA-Z-]{2,})", accept_language) or []


locale_dir = Path(__file__).parent / "locale"
Expand Down

0 comments on commit 1a70418

Please sign in to comment.