这是我在index.html 的代码
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"/>
<script src="javascript/jquery-1.11.1.min.js" type="text/javascript"></script>
<script src="javascript/i18next-1.7.4.js" type="text/javascript"></script>
<title>i18next test</title>
</head>
<body>
<p id="id001" data-i18n="first_data">first</p>
</body>
<script type="text/javascript">
$(document).ready(function(){
language_complete = navigator.language.split("-");
language = (language_complete[0]);
i18n.init({
lng: language,
resGetPath: 'locales/__lng__.json',
fallbackLng: "en",
}, function(){
$("first_data").i18n();
});
});
</script>
</html>
我在与index.html相同的目录中创建了2个json文件
locales/en.json
locales/de.json
json文件内容:
{
"first_data": "de-first-data"
}
Firefox try to load de.json and en.json but get the error 404.
您知道为什么 i18next 无法加载 json 文件吗?
这是我的文件夹结构如下:
index.html
locales/de.json
locales/en.json
javascript/i18next-1.7.4.js
javascript/jquery-1.11.1.min.js
您在 IIS 中托管应用程序。 IIS 默认情况下(据我所知)不支持 JSON 文件类型。
以下问题与同一问题相关:错误 404.3 未找到 JSON 文件 https://stackoverflow.com/questions/15944311/error-404-3-not-found-for-json-file
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)