Created
March 5, 2015 13:08
-
-
Save yeradis/ae24d79f2198c2000c51 to your computer and use it in GitHub Desktop.
i18next simple sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"app": { | |
"name": "i18next sample" | |
}, | |
"nav": { | |
"home": "Home", | |
"page1": "Page One", | |
"page2": "Page Two" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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