Skip to content

Commit

Permalink
Finish multi language support
Browse files Browse the repository at this point in the history
  • Loading branch information
Kale-Ko committed Jan 29, 2022
1 parent 82db744 commit 0304233
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 6 deletions.
33 changes: 32 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@

<body>
<div id="content">
<div id="sidebar"></div>
<div id="navbar">
<div id="sidebar"></div>

<select id="language"></select>
</div>

<div id="main"></div>
</div>
Expand Down Expand Up @@ -104,6 +108,33 @@
}
})
})

fetch("./pages/languages.json").then(res => res.json()).then(languages => {
var languagelist = document.getElementById("language")

var index = 0
function next() {
fetch("./pages/" + languages[index] + "/language.json").then(res => res.json()).then(language => {
var option = document.createElement("option")
option.value = language.code
option.innerHTML = language.name + " (" + language.status + ")"
languagelist.appendChild(option)
if (lang == language.code) languagelist.value = language.code

if (index < languages.length - 1) {
index++
next()
}
})
}
next()

languagelist.addEventListener("change", event => {
lang = languagelist.value

window.location.replace("./?page=" + page + "&lang=" + lang)
})
})
</script>
</body>

Expand Down
2 changes: 1 addition & 1 deletion pages/en/language.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"code": "en",
"name": "English",
"status": "fully-translated"
"status": "Full"
}
2 changes: 0 additions & 2 deletions pages/es/404-notfound.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Wiki Emotecraft

## 404 No Encontrado

La página que estabas buscando no se pudo encontrar
2 changes: 1 addition & 1 deletion pages/es/language.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"code": "es",
"name": "Espanjol",
"status": "barley-translated"
"status": "Partial"
}
18 changes: 17 additions & 1 deletion style/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ html {
text-align: center;
}

#sidebar {
#navbar {
background: var(--forground-color);
border: var(--border-thickness) solid var(--border-color);
border-radius: var(--border-radius);
Expand All @@ -76,6 +76,14 @@ html {
text-align: center;
}

#sidebar {
width: 100%;
height: 88%;

margin: 2% 0%;
padding: 0%;
}

.dropdown {
background: var(--dropdown-color);

Expand All @@ -94,6 +102,14 @@ html {
display: block;
}

#language {
width: 100%;
height: 4%;

margin: 2% 0%;
padding: 0%;
}

h1 {
font-size: 50px;
}
Expand Down

0 comments on commit 0304233

Please sign in to comment.