Skip to content

Instantly share code, notes, and snippets.

@yeradis
Created March 5, 2015 13:08
Show Gist options
  • Save yeradis/ae24d79f2198c2000c51 to your computer and use it in GitHub Desktop.
Save yeradis/ae24d79f2198c2000c51 to your computer and use it in GitHub Desktop.
i18next simple sample
<!DOCTYPE html>
<html>
<head>
<!-- optional -->
<script type="text/javascript" src="[PATH]/jquery.js" />
<script type="text/javascript" src="[PATH]/i18next.js" />
</head>
<body>
<ul class="nav">
<li><a href="#" data-i18n="nav.home"></a></li>
<li><a href="#" data-i18n="nav.page1"></a></li>
<li><a href="#" data-i18n="nav.page2"></a></li>
</ul>
</body>
</html>
{
"app": {
"name": "i18next sample"
},
"nav": {
"home": "Home",
"page1": "Page One",
"page2": "Page Two"
}
}
i18n.init({
debug: true,
fallbackLng: 'es'
}, function(t) {
//translate just nav
$(".nav").i18n();
//or you can translate everything
$("body").i18n();
// programatical accessing resources
var appName = t("app.name");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment