From 4ad0879aa2ec8e22c8dc2a790d77cf048d734f69 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Fri, 16 Jul 2021 14:28:10 -0400 Subject: [PATCH] Fix secondary languages. Fixes #265 --- src/shared/utils.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/shared/utils.ts b/src/shared/utils.ts index 2510b95f..aad9745c 100644 --- a/src/shared/utils.ts +++ b/src/shared/utils.ts @@ -392,7 +392,12 @@ export function getLanguage(override?: string): string { } export function getBrowserLanguage(): string { - return navigator.language; + // Intersect lemmy's langs, with the browser langs + let langs = languages ? languages.map(l => l.code) : ["en"]; + let allowedLangs = navigator.languages.filter(v => langs.includes(v)) || [ + "en", + ]; + return allowedLangs[0]; } export function getMomentLanguage(): string {