I used i18n plugin for load *.properties file for translation and its working fine on android platform but same library not working on IOS 10.3.1. It gives me below error:
我使用i18n插件来加载* .properties文件进行翻译,它在android平台上工作正常,但是同样的库不适用于IOS 10.3.1。它给我以下错误:
i have done some changes in i18n library but still its not working.
我在i18n库中做了一些更改,但仍然无法正常工作。
function loadAndParseFile(filename, settings) {
$.ajax({
url: filename,
async: false,
cache: settings.cache,
crossDomain: true,
jsonpCallback:'callback'
contentType:'text/plain;charset='+ settings.encoding,
dataType: 'text',
success: function(data, status) {
parseData(data, settings.mode);
}
});
}
In above code:
在上面的代码中:
i have been added Cross Domain 'true' and datatype 'text'.. when i changed datatype 'text' to 'jsonp' its working but it gives .properties file error. Please check below error..
我已经添加了Cross Domain'true'和数据类型'text'..当我将数据类型'text'更改为'jsonp'时它工作但是它给出了.properties文件错误。请检查以下错误..
That means. file is loaded, but inner data format is different.
这意味着。文件已加载,但内部数据格式不同。
1 个解决方案
#1
0
If you are using now JSONP instead of text, the file will be loaded as javascript code, so if contents are not valid javascript code it will fail.
如果您现在使用的是JSONP而不是文本,则该文件将作为javascript代码加载,因此如果内容无效,则javascript代码将失败。
Surround data with a global variable assignation or a function call:
使用全局变量赋值或函数调用环绕数据:
window.variable = "_DATA_"; // or
functionName("_DATA_");
If _DATA_ are JSON format, then you don't need surround with quotes, otherwise you'll need to use "_DATA_" because without quotes it will not be valid javascript syntax.
如果_DATA_是JSON格式,那么你不需要带引号的环绕声,否则你需要使用“_DATA_”因为没有引号它将不是有效的javascript语法。
#1
0
If you are using now JSONP instead of text, the file will be loaded as javascript code, so if contents are not valid javascript code it will fail.
如果您现在使用的是JSONP而不是文本,则该文件将作为javascript代码加载,因此如果内容无效,则javascript代码将失败。
Surround data with a global variable assignation or a function call:
使用全局变量赋值或函数调用环绕数据:
window.variable = "_DATA_"; // or
functionName("_DATA_");
If _DATA_ are JSON format, then you don't need surround with quotes, otherwise you'll need to use "_DATA_" because without quotes it will not be valid javascript syntax.
如果_DATA_是JSON格式,那么你不需要带引号的环绕声,否则你需要使用“_DATA_”因为没有引号它将不是有效的javascript语法。