Jquery i18n插件

问题描述 投票:1回答:1

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

具体来说,我想在必须翻译的标签中使用数据API,但它不起作用。

警报显示“嗯”,跨度与“嗯”和“Dois”保持一致。我想要一个显示“ONE”并且分别跨越“ONE”和“TWO”的警报。

<!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"
}

有没有人用过这个?

jquery internationalization
1个回答
0
投票

你实际上并没有调用en.json文件。请遵循以下文章:

How to Localize Your App With jQuery.I18n

© www.soinside.com 2019 - 2024. All rights reserved.