L10n (Localization) By JavaScript

联合创作 · 2023-10-02 14:15

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>
浏览 4
点赞
评论
收藏
分享

手机扫一扫分享

编辑 分享
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

编辑 分享
举报