I am creating a website with HTML5 and CSS, not using CMS. My next goal was to make the website in many languages so I searched and found many libraries. I am newbie to this and went for the easiest one or the one with more comments, examples...
So I took i18next, but I also tried i18n, i18next.amd... Right now I am stuck because I was following a few tutorials and cant make this work... Everytime I get this error
Uncaught ReferenceError: i18n is not defined
So I created an empty project just to make this work and learn how to do it. This new project is really light. The structure is:
- index.html
- locales
- en
- translation.json
- es
- translation.json
- default
- translation.json
- en
- js
- jquery.min.js
- i18next.min.js
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<script type="text/javascript" src="js/jquery.min.js" ></script>
<script type="text/javascript" src="js/i18next.min.js" ></script>
<script type="text/javascript">
var options ={
lng: "en" ,
resGetPath: './../locales/__lng__/__ns__.json'
};
i18n.init(options, function(t) {
$(".nav").i18n();
});
</script>
<ul class="nav">
<li><a href="#" data-i18n="nav.home">asd</a></li>
<li><a href="#" data-i18n="nav.page1">asd</a></li>
<li><a href="#" data-i18n="nav.page2">asd</a></li>
</ul>
</body>
</html>
and all of the JSON files are like this:
{
"app": {
"name": "i18next"
},
"nav": {
"home": "Home",
"page1": "Page One",
"page2": "Page Two"
}
}
I wish someone can help me, and I will really appreciate. (sorry for my english btw)
Tutorials I mentioned: http://i18next.github.io/i18next/ http://jsbin.com/yaxofuhuzu/1/edit?html,js,output www.davidhamannmedia.com/en/post-i18next-an-easy-to-use-translation-javascript-library
And many more...