From 98f88b8a266e91acd99c2d51a15fbdd1b94ed008 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Fri, 16 Jul 2021 14:29:48 -0400 Subject: [PATCH] Fix/multilang (#326) * Adding a few missing langs. * Remove unused extra language issue. * 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 2510b95..aad9745 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 { -- 2.44.1