From 48a6118173086e538ad21827aa1d6c1339769f65 Mon Sep 17 00:00:00 2001 From: Dessalines <tyhou13@gmx.com> Date: Sun, 18 Jul 2021 11:08:24 -0400 Subject: [PATCH] Fix language bug on mobile browsers --- src/server/index.tsx | 5 +++++ src/shared/utils.ts | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/server/index.tsx b/src/server/index.tsx index 163ab53..c95e44a 100644 --- a/src/server/index.tsx +++ b/src/server/index.tsx @@ -111,6 +111,11 @@ server.get("/*", async (req, res) => { <script>window.isoData = ${serialize(isoData)}</script> <script>window.lemmyConfig = ${serialize(config)}</script> + <!-- A remote debugging utility for mobile + <script src="//cdn.jsdelivr.net/npm/eruda"></script> + <script>eruda.init();</script> + --> + ${helmet.title.toString()} ${helmet.meta.toString()} diff --git a/src/shared/utils.ts b/src/shared/utils.ts index 931f2f1..49801d4 100644 --- a/src/shared/utils.ts +++ b/src/shared/utils.ts @@ -394,9 +394,11 @@ export function getLanguage(override?: string): string { export function getBrowserLanguage(): string { // 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", - ]; + + // NOTE, mobile browsers seem to be missing this list, so append en + let allowedLangs = navigator.languages + .concat("en") + .filter(v => langs.includes(v)); return allowedLangs[0]; } -- 2.44.1