From e2d58380a766cb455e88c3c8f442be66e59482cc Mon Sep 17 00:00:00 2001 From: FloPinguin <25036848+FloPinguin@users.noreply.github.com> Date: Tue, 24 Mar 2026 20:21:13 +0100 Subject: [PATCH] =?UTF-8?q?For=20v30:=20Fix=20base=20language=20preferred?= =?UTF-8?q?=20over=20regional=20variant=20in=20auto-detection=20?= =?UTF-8?q?=F0=9F=8C=90=20(#3506)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description: When the browser reports a locale like `de-DE`, the language selector didn't find an exact match and fell through to candidate matching, where it picked `de-CH` (Swiss German) over `de` (German) because longer codes were sorted first. This adds an early check: if the base language code (e.g. `de`) is directly supported, return it immediately before scanning regional candidates. FYI @Aotumuri ## Please complete the following: - [X] I have added screenshots for all UI updates - [X] I process any text displayed to the user through translateText() and I've added it to the en.json file - [X] I have added relevant tests to the test directory - [X] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced ## Please put your Discord username so you can be contacted if a bug or regression is found: FloPinguin --- src/client/LangSelector.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/client/LangSelector.ts b/src/client/LangSelector.ts index a373a73ce..479b2d012 100644 --- a/src/client/LangSelector.ts +++ b/src/client/LangSelector.ts @@ -72,6 +72,7 @@ export class LangSelector extends LitElement { if (supported.has(lang)) return lang; const base = lang.slice(0, 2); + if (supported.has(base)) return base; const candidates = Array.from(supported).filter((key) => key.startsWith(base), );