forked from MapComplete/MapComplete
Fix: fix #1813. For some reason, importing a .js-file suddenly fails, so ported it to typescript
This commit is contained in:
parent
c70ab96427
commit
cab414e808
3 changed files with 33 additions and 32 deletions
|
@ -1,31 +0,0 @@
|
|||
let lang = (
|
||||
(navigator.languages && navigator.languages[0]) ||
|
||||
navigator.language ||
|
||||
navigator["userLanguage"] ||
|
||||
"en"
|
||||
).substr(0, 2)
|
||||
|
||||
function filterLangs(maindiv) {
|
||||
let foundLangs = 0
|
||||
for (const child of Array.from(maindiv.children)) {
|
||||
if (child.attributes.getNamedItem("lang")?.value === lang) {
|
||||
foundLangs++
|
||||
}
|
||||
}
|
||||
if (foundLangs === 0) {
|
||||
lang = "en"
|
||||
}
|
||||
for (const child of Array.from(maindiv.children)) {
|
||||
const childLang = child.attributes.getNamedItem("lang")
|
||||
if (childLang === undefined) {
|
||||
continue
|
||||
}
|
||||
if (childLang.value === lang) {
|
||||
continue
|
||||
}
|
||||
child.parentElement.removeChild(child)
|
||||
}
|
||||
}
|
||||
|
||||
filterLangs(document.getElementById("descriptions-while-loading"))
|
||||
filterLangs(document.getElementById("default-title"))
|
32
src/UI/RemoveOtherLanguages.ts
Normal file
32
src/UI/RemoveOtherLanguages.ts
Normal file
|
@ -0,0 +1,32 @@
|
|||
export {}
|
||||
let lang = (
|
||||
(navigator.languages && navigator.languages[0]) ||
|
||||
navigator.language ||
|
||||
navigator["userLanguage"] ||
|
||||
"en"
|
||||
).substr(0, 2)
|
||||
|
||||
function filterLangs(maindiv) {
|
||||
let foundLangs = 0
|
||||
for (const child of Array.from(maindiv.children)) {
|
||||
if (child.attributes.getNamedItem("lang")?.value === lang) {
|
||||
foundLangs++
|
||||
}
|
||||
}
|
||||
if (foundLangs === 0) {
|
||||
lang = "en"
|
||||
}
|
||||
for (const child of Array.from(maindiv.children)) {
|
||||
const childLang = child.attributes.getNamedItem("lang")
|
||||
if (childLang === undefined) {
|
||||
continue
|
||||
}
|
||||
if (childLang.value === lang) {
|
||||
continue
|
||||
}
|
||||
child.parentElement.removeChild(child)
|
||||
}
|
||||
}
|
||||
|
||||
filterLangs(document.getElementById("descriptions-while-loading"))
|
||||
filterLangs(document.getElementById("default-title"))
|
Loading…
Add table
Add a link
Reference in a new issue