i18next加载json错误(找不到404) [英] i18next load json error(404 Not Found)
本文介绍了i18next加载json错误(找不到404)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我在index.html上的代码
this is my code at 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文件
And I've created 2 json file at the same directory with index.html
locales/en.json
locales/de.json
json文件内容:
{
"first_data": "de-first-data"
}
Firefox尝试加载de.json和en.json,但显示错误404.
Firefox try to load de.json and en.json but get the error 404.
您是否知道为什么i18next无法加载json文件.
Do you have any idea why i18next cannot load the json file.
这是我的下面的文件夹结构:
This is my folder structure below:
index.html
locales/de.json
locales/en.json
javascript/i18next-1.7.4.js
javascript/jquery-1.11.1.min.js
推荐答案
您将应用程序托管在IIS中. IIS默认情况下(据我所知)不支持JSON文件类型.
You host application in IIS. IIS by default (as far as I know) doesn't support JSON file type.
以下问题与同一问题有关: 找不到JSON文件错误404.3
Following question is related to same problem: ERROR 404.3 Not Found for JSON file
这篇关于i18next加载json错误(找不到404)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文