From: Dessalines Date: Fri, 16 Jul 2021 18:29:48 +0000 (-0400) Subject: Fix/multilang (#326) X-Git-Url: http://these/git/readmes/%7B%60%24%7BarchiveTodayUrl%7D/%24%7BgetStaticDir%28%29%7D/styles/styles.css?a=commitdiff_plain;h=98f88b8a266e91acd99c2d51a15fbdd1b94ed008;p=lemmy-ui.git Fix/multilang (#326) * Adding a few missing langs. * Remove unused extra language issue. * Fix secondary languages. Fixes #265 --- 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 {