我正在尝试为i18n使用this jquery插件。

具体来说,我想在必须转换的标记中使用数据API,但它无法正常工作。

警报显示“ um”,跨度停留在“ Um”和“ Dois”。我想要一个警报,分别显示“一个”和跨度“一个”和“两个”。



<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">

<title>jQuery i18n Demo</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js" ></script>
<script src="../src/jquery.i18n.js"></script>
<script src="../src/jquery.i18n.messagestore.js"></script>

<link rel="stylesheet" href="css/bootstrap.min.css">
<script src="js/bootstrap.min.js"></script>

<script>
    $.i18n({
        locale: 'en'
    });

    alert($.i18n("um"));
</script>
</head>

<body>
<span data-i18n="um">Um</span>.
<span data-i18n="dois">Dois</span>.
</body>
</html>


en.json

{
"um": "ONE",
"dois": "TWO"
}


有人使用过吗?

最佳答案

您实际上并不是在调用en.json文件。请按照以下文章:
How to Localize Your App With jQuery.I18n

07-24 19:07
查看更多