Add Language Support and Copy English Translation as Placeholder

This commit is contained in:
BloxerHD 2026-06-29 12:51:13 +01:00
commit 5be4b0e760
Signed by: bloxerhd018
SSH key fingerprint: SHA256:ItSfcfhpXlfkMK3uQSDYW5X3XKm0hbHWQqWcCK57px8
38 changed files with 1103 additions and 34 deletions

View file

@ -1,26 +1,72 @@
const guideContents = document.querySelectorAll(".guide-content");
const guideButtons = document.querySelectorAll(".guide");
const langs = [
"en", // [x] English
"es", // [ ] Spanish
"ja", // [ ] Japanese
"fr", // [ ] French
"it", // [ ] Italian
"de", // [ ] German
]
const params = new URLSearchParams(window.location.search);
const guideParam = params.get("guide");
async function updateGuide(guide, lang) {
let buttonsRes = await fetch(`/md/${lang}/buttons.html`);
let guide = "install-wiiu";
let guidePath = '/md/en/install-wiiu.md';
if (guideParam) {
guide = guideParam;
guidePath = `/md/en/${guide}.md`;
if (buttonsRes.ok) {
let buttonsHTML = await buttonsRes.text();
document.getElementById("guide-buttons").innerHTML = buttonsHTML;
}
let guidePath = `/md/${lang}/${guide}.md`;
let guideRes = await fetch(guidePath);
if (!guideRes.ok) throw new Error(`Guide "${guide}" was not found`);
const guideButton = document.getElementById(guide);
if (guideButton) guideButton.classList.add("active");
let text = await guideRes.text();
const html = marked.parse(text);
document.getElementById("guide-contents").innerHTML = html;
}
fetch(guidePath)
.then(res => {
if (!res.ok) throw new Error(`Guide "${guide} was not found`);
const guideButton = document.getElementById(guide);
if (guideButton) guideButton.classList.add("active");
async function updateLang(newLang) {
localStorage.setItem("lang", newLang);
return res.text();
})
.then(text => {
const html = marked.parse(text);
document.getElementById("guide-contents").innerHTML = html;
})
const params = new URLSearchParams(window.location.search);
const guideParam = params.get("guide");
let guide = "install-wiiu";
if (guideParam) {
guide = guideParam;
}
await updateGuide(guide, newLang);
}
window.onload = (async () => {
const params = new URLSearchParams(window.location.search);
const guideParam = params.get("guide");
let lang = "en"
let savedLang = localStorage.getItem("lang");
if (savedLang) {
lang = savedLang;
} else {
let currentLang = navigator.language.split("-")[0];
if (langs.includes(currentLang)) {
localStorage.setItem("lang", currentLang);
lang = currentLang;
}
}
let guide = "install-wiiu";
if (guideParam) {
guide = guideParam;
}
await updateGuide(guide, lang)
})