Fix language bug on mobile browsers

This commit is contained in:
Dessalines 2021-07-18 11:08:24 -04:00
parent 3a593addfd
commit 48a6118173
2 changed files with 10 additions and 3 deletions

View file

@ -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()}

View file

@ -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];
}