Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Language translations #89

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions _includes/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
<a href="https://github.com/minetest/minetest.github.io">Website developed at GitHub.</a>
</p>
</footer>
</div>

<script type="text/javascript">
document.getElementById("translate").innerHTML=translate(document.getElementById("translate").innerHTML)
</script>
<script src="/lib/js/jquery.min.js"></script>
<script src="/lib/js/jquery.smooth-scroll.min.js"></script>
<script src="/lib/js/jquery.goup.min.js"></script>
Expand Down
15 changes: 15 additions & 0 deletions _includes/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,26 @@
$("a").smoothScroll(); // jQuery Smooth Scroll
$.goup(); // jQuery GoUp
});
function translate(src) {
var text=src;
var lang=(navigator.browserLanguage || navigator.language).toLowerCase();
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", "locale/"+lang+".txt", false);
xmlhttp.send();
var lines=xmlhttp.responseText.split("\n");
for(var i=0;i<lines.length;i++) {
var line=lines[i].split(":=",2);
if(line.length!=2)continue;
text=text.replace(line[0],line[1]);
}
return text;
}
</script>
</head>

<body>
<noscript><p><img src="//stats.minetest.net/piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript>
<div id="translate">
<div id="top"></div>
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
Expand Down
1 change: 1 addition & 0 deletions locale/zh-cn.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Meet Minetest.:=遇见Minetest。