From f2157215e23fcb6583d090faf8cff49e9e6a7b12 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Wed, 28 Oct 2020 15:52:42 -0700 Subject: web: fix lang detection (include 'en') If a user had any non-english language preference, was defaulting to that, even if 'en' had higher preference. --- fatcat_scholar/hacks.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'fatcat_scholar/hacks.py') diff --git a/fatcat_scholar/hacks.py b/fatcat_scholar/hacks.py index fc16564..96226ff 100644 --- a/fatcat_scholar/hacks.py +++ b/fatcat_scholar/hacks.py @@ -77,3 +77,13 @@ def test_parse_accept_lang() -> None: parse_accept_lang("en-ca,en;q=0.8,en-us;q=0.6,de-de;q=0.4,de;q=0.2", ["de"]) == "de" ) + assert ( + parse_accept_lang( + "en-ca,en;q=0.8,en-us;q=0.6,de-de;q=0.4,de;q=0.2", ["en", "de"] + ) + == "en" + ) + assert ( + parse_accept_lang("en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7", ["zh", "en", "de"]) + == "en" + ) -- cgit v1.2.3