-
Notifications
You must be signed in to change notification settings - Fork 0
/
multi_lang.js
40 lines (34 loc) · 1002 Bytes
/
multi_lang.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Code from https://webparts.cman.jp/string/lang/
window.onload = function() {
var wDef = (navigator.browserLanguage || navigator.language || navigator.userLanguage).substr(0,2);
langSet(wDef);
}
function langSet(argLang){
var title = document.getElementsByClassName("about-title");
var text = document.getElementsByClassName("about-text");
var heading = document.getElementsByClassName("heading");
for (var i = 0; i < title.length; i++) {
if(title[i].getAttribute("lang") == argLang){
title[i].style.display = '';
}
else{
title[i].style.display = 'none';
}
}
for (var i = 0; i < text.length; i++) {
if(text[i].getAttribute("lang") == argLang){
text[i].style.display = '';
}
else{
text[i].style.display = 'none';
}
}
for (var i = 0; i < heading.length; i++) {
if(heading[i].getAttribute("lang") == argLang){
heading[i].style.display = '';
}
else{
heading[i].style.display = 'none';
}
}
}