aboutsummaryrefslogtreecommitdiff
path: root/src/app/lang.js
blob: f1c31d32a1fa007715a98ca6a59abf3be84bc171 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// Replaces strings in the HTML will language strings properly. This
// searches for %%<string>%%, aka, %%gui.exit%% will be replaced with
// "Exit", this works without issues.
function setlang() {
	// Finds %%%% strings
	html = document.body.innerHTML.split("%%");

	for (let i = 0; i < html.length; i++) {
		// Simply checks to make sure it is actually a lang string.
		if (html[i][0] != " " && 
			html[i][html[i].length - 1] != " ") {
			// Replaces it with it's string
			html[i] = lang(html[i]);
		}
	}
	
	// Replaces the original HTML with the translated/replaced HTML
	document.body.innerHTML = html.join("");
}