L10n (Localization) By JavaScript
Localization your webpages by using AJAX.
Preview and bug report, please visit: http://www.hpyer.cn/codes/l10n-by-javascript
Example:
<html>
<head>
<title>Example</title>
<script src="jquery.js" language="JavaScript" type="text/javascript"></script>
<script src="jquery.l10n.js" language="JavaScript" type="text/javascript"></script>
<script type="text/javascript">
$.l10n.init({
'dir': './languages',
'lang': 'zh_CN',
'cache': true
});
</script>
</head>
<body>
<script type="text/javascript">
// Translate directly
document.write($.l10n.__('Words need to be translated'));
// Or
$.l10n._e('Words need to be translated');
</script>
<!-- Translate indirectly -->
<span>Words need to be translated</span>
<script type="text/javascript">
$('span').l10n();
</script>
</body>
</html>
评论