How to write a translator script for a website in jquery

There is a site.
How to make sure that when you log in to the site, one text changes to another. Let's say the site has the following words FORUM, TOPICS, ANSWERS. When the page loaded, these words were translated to this FORUM, TEMALAR, CAVABLAR

I wrote this script, but for some reason it does not work correctly. The whole page is converted to porridge :)

<script>
 $('body').each(function(){
     var $this = $(this);
     var t = $this.text();
     $this.html(t.replace('Форум','Forum')
        .replace('Темы', 'Mövzular'));
 });
</script>
Author: MSDN.WhiteKnight, 2016-02-27

1 answers

Brewed in this way, you can make as many translations as you want.

<!DOCTYPE html>
<html>
<head>
	<title>titile</title>
	<meta charset="utf-8">
	<style>

	</style>
	<script src="https://code.jquery.com/jquery-1.11.3.js"></script>
	<script>
		$(function(){

			var obj = {
				"Форум": 'Forum',
				"Темы": 'Temalar',
				"Ответы": 'Cavablar'
			}

			var html = $('body').html();

			for (key in obj) {
				html = html.replace(key, obj[key]);
			}

			$('body').html(html);

		});
	</script>
</head>
<body>

<a href="">Форум</a>

<table>
	<tr>
		<td>Темы</td>
	</tr>
</table>


<span>Ответы</span>

</body>
</html>
 1
Author: Jean-Claude, 2016-02-29 11:26:51