Fix redirect
This commit is contained in:
parent
e81778f561
commit
a48f50dc9c
11
index.html
11
index.html
@ -10,27 +10,24 @@ layout: none
|
|||||||
var languages = {{ site.data.languages | jsonify }};
|
var languages = {{ site.data.languages | jsonify }};
|
||||||
function getLanguage() {
|
function getLanguage() {
|
||||||
var userLang = navigator.language || navigator.userLanguage;
|
var userLang = navigator.language || navigator.userLanguage;
|
||||||
|
|
||||||
for (var i = 0; i < languages.length; i++) {
|
for (var i = 0; i < languages.length; i++) {
|
||||||
var lang = languages[i];
|
var lang = languages[i];
|
||||||
console.log(lang.code + " vs " + userLang);
|
|
||||||
|
|
||||||
if (userLang.indexOf(lang.code) == 0) {
|
if (userLang.indexOf(lang.code) == 0) {
|
||||||
return lang;
|
return lang;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var language = getLanguage() || languages[0];
|
var language = getLanguage() || languages[0];
|
||||||
console.log('<a href="/' + language.code +
|
var url = language.code + "/index.html";
|
||||||
'/index.html">Redirecting to the ' + language.name +
|
console.log('<a href="' + url + '">Redirecting to the ' + language.name +
|
||||||
' version...</a>')
|
' version...</a>')
|
||||||
document.write('<a href="/' + language.code +
|
document.write('<a href="' + language.code +
|
||||||
'/index.html">Redirecting to the ' + language.name +
|
'/index.html">Redirecting to the ' + language.name +
|
||||||
' version...</a>');
|
' version...</a>');
|
||||||
|
|
||||||
|
window.location.replace(url);
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
Reference in New Issue
Block a user