Skip to content

Commit d83a4d2

Browse files
FloPinguinevanpelle
authored andcommitted
For v30: Fix base language preferred over regional variant in auto-detection 🌐 (#3506)
## 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
1 parent 39ad547 commit d83a4d2

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

src/client/LangSelector.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export class LangSelector extends LitElement {
7171
if (supported.has(lang)) return lang;
7272

7373
const base = lang.slice(0, 2);
74+
if (supported.has(base)) return base;
7475
const candidates = Array.from(supported).filter((key) =>
7576
key.startsWith(base),
7677
);

0 commit comments

Comments
 (0)