b28-cli 1.6.8 → 1.6.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.MD
CHANGED
|
@@ -256,7 +256,15 @@ module.exports = {
|
|
|
256
256
|
|
|
257
257
|
### 原厂代码添加翻译函数
|
|
258
258
|
|
|
259
|
-
在原厂代码中添加翻译函数`_()`,实现多语言产品需求,同时生成初始的语言包`json
|
|
259
|
+
在原厂代码中添加翻译函数`_()`,实现多语言产品需求,同时生成初始的语言包`json`文件。
|
|
260
|
+
|
|
261
|
+

|
|
262
|
+
|
|
263
|
+
对于无法识别的内容或风险内容,输出到`log.txt`文件,手动检查是否需要添加翻译函数。
|
|
264
|
+
`log.txt`中存在三种类型的log:
|
|
265
|
+
- **词条不存在**:词条标识字段无法在C文件中找到对应的英文描述词条;
|
|
266
|
+
- **翻译函数缺失?**:当前语句可能需要添加翻译函数,如要添加,请根据提供的文件信息找到当前语句手动添加翻译函数;
|
|
267
|
+
- **文件检查**:当前文件添加翻译函数后可能会存在一定的语法错误,请根据提供的文件信息,找到文件手动检查修正。(问题代码大概率出现在js代码中的html字符串拼接部分)
|
|
260
268
|
|
|
261
269
|
| 属性 | 值类型 | 默认值 | 说明 |
|
|
262
270
|
| -------------- | --------------------------- | -------------------- | --------------------------------------------------- |
|
|
@@ -116,11 +116,11 @@ var ExtractFile = function () {
|
|
|
116
116
|
return Promise.all([this.handleHtml(), this.handleJs()]).then(function (data) {
|
|
117
117
|
var suspectLine = "";
|
|
118
118
|
data.forEach(function (item) {
|
|
119
|
-
suspectLine += item.join("\n\r");
|
|
119
|
+
suspectLine += "\n\r" + item.join("\n\r");
|
|
120
120
|
});
|
|
121
|
-
var suspectPath = _path2.default.join(_this.option.baseWritePath, "
|
|
121
|
+
var suspectPath = _path2.default.join(_this.option.baseWritePath, "log.txt");
|
|
122
122
|
(0, _index.writeTextFile)(suspectPath, suspectLine);
|
|
123
|
-
(0, _index.log)("\
|
|
123
|
+
(0, _index.log)("\u6DFB\u52A0\u7FFB\u8BD1\u51FD\u6570\u8FC7\u7A0B\u4E2D\u9700\u8981\u624B\u52A8\u6392\u67E5\u95EE\u9898log\uFF1A" + suspectPath, _index.LOG_TYPE.DONE);
|
|
124
124
|
//重置
|
|
125
125
|
_this.exportLangs();
|
|
126
126
|
_this.reset();
|
|
@@ -37,6 +37,7 @@ var Extract = function () {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
Extract.prototype.init = function init(words) {
|
|
40
|
+
this.warnings = [];
|
|
40
41
|
this.words = words;
|
|
41
42
|
// 记录当前的文件路径
|
|
42
43
|
this.curFilePath = "";
|
|
@@ -85,11 +86,14 @@ var Extract = function () {
|
|
|
85
86
|
matchs = matchs.filter(function (item) {
|
|
86
87
|
return !(/(alert|confirm)\((.).*?\2\)/gi.test(item) || /_\(.*?\)/g.test(item) || !/\s/g.test(item));
|
|
87
88
|
});
|
|
88
|
-
|
|
89
|
-
|
|
89
|
+
matchs = matchs.map(function (item) {
|
|
90
|
+
return " [\u7FFB\u8BD1\u51FD\u6570\u7F3A\u5931\uFF1F]\uFF1A[" + item + "]";
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
if (matchs && matchs.length > 0 || _this.warnings.length > 0) {
|
|
94
|
+
var _suspectLine;
|
|
90
95
|
|
|
91
|
-
|
|
92
|
-
}
|
|
96
|
+
(_suspectLine = _this.suspectLine).push.apply(_suspectLine, ["#--#--#--#--#--# \u6587\u4EF6\u5730\u5740\u3010" + _this.curFilePath + "\u3011 #--#--#--#--#--#"].concat(Array.from(new Set(_this.warnings)), matchs || []));
|
|
93
97
|
}
|
|
94
98
|
|
|
95
99
|
return _this.startTrans();
|
|
@@ -123,7 +127,11 @@ var Extract = function () {
|
|
|
123
127
|
};
|
|
124
128
|
|
|
125
129
|
Extract.prototype.transWord = function transWord(val) {
|
|
126
|
-
|
|
130
|
+
var word = this.words[val];
|
|
131
|
+
if (word === undefined) {
|
|
132
|
+
this.warnings.push(" [\u8BCD\u6761\u4E0D\u5B58\u5728]\uFF1A[" + val + "]");
|
|
133
|
+
}
|
|
134
|
+
return word;
|
|
127
135
|
};
|
|
128
136
|
|
|
129
137
|
Extract.prototype.complete = function complete() {
|
|
@@ -81,6 +81,7 @@ var ExtractHTML = function (_Extract) {
|
|
|
81
81
|
ExtractHTML.prototype.scanNode = function scanNode(document) {
|
|
82
82
|
var _this3 = this;
|
|
83
83
|
|
|
84
|
+
this.warnings = [];
|
|
84
85
|
// 遍历各节点
|
|
85
86
|
this.listNode(document.documentElement);
|
|
86
87
|
|
|
@@ -121,8 +122,11 @@ var ExtractHTML = function (_Extract) {
|
|
|
121
122
|
return this.extractJS.transNode(child.innerHTML, true).then(function (AST) {
|
|
122
123
|
return _this5.extractJS.scanNode(AST);
|
|
123
124
|
}).then(function (fileData) {
|
|
125
|
+
var _warnings;
|
|
126
|
+
|
|
124
127
|
// 写入文件
|
|
125
128
|
child.innerHTML = fileData;
|
|
129
|
+
(_warnings = _this5.warnings).push.apply(_warnings, _this5.extractJS.warnings);
|
|
126
130
|
return _this5.nextJsTask();
|
|
127
131
|
}).catch(function (e) {
|
|
128
132
|
(0, _index.log)(e, _index.LOG_TYPE.ERROR);
|
|
@@ -34,6 +34,7 @@ var ExtractJs = function (_Extract) {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
ExtractJs.prototype.transNode = function transNode(jsDoc) {
|
|
37
|
+
this.warnings = [];
|
|
37
38
|
return Promise.resolve(jsDoc);
|
|
38
39
|
};
|
|
39
40
|
|
|
@@ -56,11 +57,14 @@ var ExtractJs = function (_Extract) {
|
|
|
56
57
|
// 对于'<% xxx %>'添加翻译函数
|
|
57
58
|
.replace(newReg, function (match, p1, p2) {
|
|
58
59
|
return _this2.transWord(p2) ? "_(" + p1 + _this2.transWord(p2) + p1 + ")" : match;
|
|
59
|
-
})
|
|
60
|
-
// 对于<% xxx %>添加翻译函数
|
|
61
|
-
.replace(reg, function (match, p1) {
|
|
62
|
-
return _this2.transWord(p1) ? "_('" + _this2.transWord(p1) + "')" : match;
|
|
63
60
|
});
|
|
61
|
+
if (reg.test(jsDoc)) {
|
|
62
|
+
_this2.warnings.push(' [文件检查]:[该文件中js代码部分可能存在格式不正确的翻译函数或字符串未添加翻译函数]');
|
|
63
|
+
// 对于<% xxx %>添加翻译函数
|
|
64
|
+
jsDoc = jsDoc.replace(reg, function (match, p1) {
|
|
65
|
+
return _this2.transWord(p1) ? _this2.transWord(p1) : match;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
64
68
|
}
|
|
65
69
|
// 对alert、confirm添加翻译函数
|
|
66
70
|
jsDoc = jsDoc.replace(/(alert|confirm)\((('|").*?\3)\)/gi, function (a, b, c) {
|