b28-cli 1.6.8 → 1.7.0
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 +9 -1
- package/dist/ExtractFile.js +3 -0
- package/dist/ExtractFileOrigin.js +3 -3
- package/dist/cmd.js +1 -254
- package/dist/debug/test.js +4 -3
- package/dist/extract/extract-regexp.js +4 -1
- package/dist/extract/extract.js +9 -0
- package/dist/extractOrigin/extract.js +13 -5
- package/dist/extractOrigin/extract_html_ori.js +4 -0
- package/dist/extractOrigin/extract_js_ori.js +8 -4
- package/dist/handle.js +1 -0
- package/dist/util/config.js +5 -0
- package/package.json +1 -1
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
|
| -------------- | --------------------------- | -------------------- | --------------------------------------------------- |
|
package/dist/ExtractFile.js
CHANGED
|
@@ -97,6 +97,7 @@ var ExtractFile = function () {
|
|
|
97
97
|
CONFIG_HONG: this.CONFIG_HONG,
|
|
98
98
|
onlyZH: this.option.onlyZH,
|
|
99
99
|
transWords: this.option.transWords,
|
|
100
|
+
isOrigin: this.option.isOrigin,
|
|
100
101
|
isTranslate: this.option.isTranslate,
|
|
101
102
|
isCheckTrans: this.option.isCheckTrans,
|
|
102
103
|
baseWritePath: this.option.baseWritePath,
|
|
@@ -117,6 +118,7 @@ var ExtractFile = function () {
|
|
|
117
118
|
CONFIG_HONG: this.CONFIG_HONG,
|
|
118
119
|
onlyZH: this.option.onlyZH,
|
|
119
120
|
transWords: this.option.transWords,
|
|
121
|
+
isOrigin: this.option.isOrigin,
|
|
120
122
|
isTranslate: this.option.isTranslate,
|
|
121
123
|
isCheckTrans: this.option.isCheckTrans,
|
|
122
124
|
baseWritePath: this.option.baseWritePath,
|
|
@@ -157,6 +159,7 @@ var ExtractFile = function () {
|
|
|
157
159
|
CONFIG_HONG: this.CONFIG_HONG,
|
|
158
160
|
onlyZH: this.option.onlyZH,
|
|
159
161
|
transWords: this.option.transWords,
|
|
162
|
+
isOrigin: this.option.isOrigin,
|
|
160
163
|
isTranslate: this.option.isTranslate,
|
|
161
164
|
isCheckTrans: this.option.isCheckTrans,
|
|
162
165
|
baseWritePath: this.option.baseWritePath,
|
|
@@ -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();
|
package/dist/cmd.js
CHANGED
|
@@ -37,6 +37,7 @@ var figlet = require("figlet");
|
|
|
37
37
|
var comments = {
|
|
38
38
|
commandType: "操作类型",
|
|
39
39
|
onlyZH: "只提取中文",
|
|
40
|
+
isOrigin: "提取接入原厂代码中的词条",
|
|
40
41
|
baseReadPath: "待提取文件地址",
|
|
41
42
|
baseOutPath: "提取的Excel文件输出地址",
|
|
42
43
|
hongPath: "宏文件地址",
|
|
@@ -67,260 +68,6 @@ var comments = {
|
|
|
67
68
|
transEncode: "转码后文件的编码方式(默认UTF-8)"
|
|
68
69
|
};
|
|
69
70
|
|
|
70
|
-
/**
|
|
71
|
-
* 命令行手动输入参数逐条配置
|
|
72
|
-
*/
|
|
73
|
-
// let questions = [
|
|
74
|
-
// // 提取词条
|
|
75
|
-
// [
|
|
76
|
-
// {
|
|
77
|
-
// type: "confirm",
|
|
78
|
-
// name: "onlyZH",
|
|
79
|
-
// message: "只提取中文?"
|
|
80
|
-
// },
|
|
81
|
-
// {
|
|
82
|
-
// type: "input",
|
|
83
|
-
// name: "baseReadPath",
|
|
84
|
-
// message: "待提取文件地址:"
|
|
85
|
-
// },
|
|
86
|
-
// {
|
|
87
|
-
// type: "input",
|
|
88
|
-
// name: "baseOutPath",
|
|
89
|
-
// message: "提取的Excel文件输出地址:"
|
|
90
|
-
// },
|
|
91
|
-
// {
|
|
92
|
-
// type: "input",
|
|
93
|
-
// name: "hongPath",
|
|
94
|
-
// message: "宏文件地址:"
|
|
95
|
-
// }
|
|
96
|
-
// ],
|
|
97
|
-
// // 翻译文件
|
|
98
|
-
// [
|
|
99
|
-
// {
|
|
100
|
-
// type: "input",
|
|
101
|
-
// name: "baseTranslatePath",
|
|
102
|
-
// message: "待翻译文件根目录:"
|
|
103
|
-
// },
|
|
104
|
-
// {
|
|
105
|
-
// type: "input",
|
|
106
|
-
// name: "baseTransOutPath",
|
|
107
|
-
// message: "翻译后文件输出根目录:"
|
|
108
|
-
// },
|
|
109
|
-
// {
|
|
110
|
-
// type: "input",
|
|
111
|
-
// name: "hongPath",
|
|
112
|
-
// message: "宏文件地址:"
|
|
113
|
-
// },
|
|
114
|
-
// {
|
|
115
|
-
// type: "input",
|
|
116
|
-
// name: "languagePath",
|
|
117
|
-
// message: "语言包文件地址:"
|
|
118
|
-
// },
|
|
119
|
-
// {
|
|
120
|
-
// type: "input",
|
|
121
|
-
// name: "sheetName",
|
|
122
|
-
// message: "Excel中对应的sheet:"
|
|
123
|
-
// },
|
|
124
|
-
// {
|
|
125
|
-
// type: "input",
|
|
126
|
-
// name: "keyName",
|
|
127
|
-
// message: "key对应列:", //指代代码中的词条需要被那一列的数据替换
|
|
128
|
-
// default: "EN"
|
|
129
|
-
// },
|
|
130
|
-
// {
|
|
131
|
-
// type: "input",
|
|
132
|
-
// name: "valueName",
|
|
133
|
-
// message: "value对应列:", //指代代码中目前需要被替换的语言
|
|
134
|
-
// default: "CN", // ALL代表所有
|
|
135
|
-
// default: ""
|
|
136
|
-
// }
|
|
137
|
-
// ],
|
|
138
|
-
// // 翻译检查
|
|
139
|
-
// [
|
|
140
|
-
// {
|
|
141
|
-
// type: "input",
|
|
142
|
-
// name: "baseCheckPath",
|
|
143
|
-
// message: "待检查文件根目录:"
|
|
144
|
-
// },
|
|
145
|
-
// {
|
|
146
|
-
// type: "input",
|
|
147
|
-
// name: "langJsonPath",
|
|
148
|
-
// message: "语言包json文件地址:"
|
|
149
|
-
// },
|
|
150
|
-
// {
|
|
151
|
-
// type: "input",
|
|
152
|
-
// name: "hongPath",
|
|
153
|
-
// message: "宏文件地址:"
|
|
154
|
-
// },
|
|
155
|
-
// {
|
|
156
|
-
// type: "input",
|
|
157
|
-
// name: "logPath",
|
|
158
|
-
// message: "检查信息输出路径:"
|
|
159
|
-
// }
|
|
160
|
-
// ],
|
|
161
|
-
// // excel转json
|
|
162
|
-
// [
|
|
163
|
-
// {
|
|
164
|
-
// type: "input",
|
|
165
|
-
// name: "excelPath",
|
|
166
|
-
// message: "Excel文件地址:"
|
|
167
|
-
// },
|
|
168
|
-
// {
|
|
169
|
-
// type: "input",
|
|
170
|
-
// name: "sheetName",
|
|
171
|
-
// message: "Excel中对应的sheet:"
|
|
172
|
-
// },
|
|
173
|
-
// {
|
|
174
|
-
// type: "input",
|
|
175
|
-
// name: "keyName",
|
|
176
|
-
// message: "key对应列:",
|
|
177
|
-
// default: "EN"
|
|
178
|
-
// },
|
|
179
|
-
// {
|
|
180
|
-
// type: "input",
|
|
181
|
-
// name: "valueName",
|
|
182
|
-
// message: "value对应列:" // ALL代表所有
|
|
183
|
-
// },
|
|
184
|
-
// {
|
|
185
|
-
// type: "input",
|
|
186
|
-
// name: "outJsonPath",
|
|
187
|
-
// message: "输出json文件目录:"
|
|
188
|
-
// }
|
|
189
|
-
// ],
|
|
190
|
-
// // json转excel
|
|
191
|
-
// [
|
|
192
|
-
// {
|
|
193
|
-
// type: "input",
|
|
194
|
-
// name: "jsonPath",
|
|
195
|
-
// message: "json文件地址:"
|
|
196
|
-
// },
|
|
197
|
-
// {
|
|
198
|
-
// type: "input",
|
|
199
|
-
// name: "outExcelPath",
|
|
200
|
-
// message: "输出Excel文件目录:"
|
|
201
|
-
// }
|
|
202
|
-
// ],
|
|
203
|
-
// // json文件合并
|
|
204
|
-
// [
|
|
205
|
-
// {
|
|
206
|
-
// type: "input",
|
|
207
|
-
// name: "mainJsonPath",
|
|
208
|
-
// message: "主json文件地址:"
|
|
209
|
-
// },
|
|
210
|
-
// {
|
|
211
|
-
// type: "input",
|
|
212
|
-
// name: "mergeJsonPath",
|
|
213
|
-
// message: "次json文件地址:"
|
|
214
|
-
// },
|
|
215
|
-
// {
|
|
216
|
-
// type: "input",
|
|
217
|
-
// name: "outMergeJsonPath",
|
|
218
|
-
// message: "合并后输出的地址:"
|
|
219
|
-
// }
|
|
220
|
-
// ],
|
|
221
|
-
// // 原厂代码添加翻译函数
|
|
222
|
-
// [
|
|
223
|
-
// {
|
|
224
|
-
// type: "input",
|
|
225
|
-
// name: "baseProPath",
|
|
226
|
-
// message: "原厂代码地址:"
|
|
227
|
-
// },
|
|
228
|
-
// {
|
|
229
|
-
// type: "input",
|
|
230
|
-
// name: "baseProOutPath",
|
|
231
|
-
// message: "添加翻译函数后文件输出地址:"
|
|
232
|
-
// },
|
|
233
|
-
// {
|
|
234
|
-
// type: "input",
|
|
235
|
-
// name: "ignoreCode",
|
|
236
|
-
// message: "需要注释的代码正则:",
|
|
237
|
-
// default: "/<!--s*hide|-->/g"
|
|
238
|
-
// },
|
|
239
|
-
// {
|
|
240
|
-
// type: "input",
|
|
241
|
-
// name: "templateExp",
|
|
242
|
-
// message: "后台插入表达式正则:",
|
|
243
|
-
// default: "/<%([^\n]*?)%>/g"
|
|
244
|
-
// }
|
|
245
|
-
// ],
|
|
246
|
-
// // 提取json文件,生成一个excel表格
|
|
247
|
-
// [
|
|
248
|
-
// {
|
|
249
|
-
// type: "input",
|
|
250
|
-
// name: "baseReadPath",
|
|
251
|
-
// message: "待提取文件地址:",
|
|
252
|
-
// validate: valid.folder // 必填,可以是文件也可以是文件夹
|
|
253
|
-
// },
|
|
254
|
-
// {
|
|
255
|
-
// type: "input",
|
|
256
|
-
// name: "languagePath",
|
|
257
|
-
// message: "语言包文地址(文件夹):"
|
|
258
|
-
// },
|
|
259
|
-
// {
|
|
260
|
-
// type: "input",
|
|
261
|
-
// name: "baseOutPath",
|
|
262
|
-
// message: "提取的Excel文件输出地址:",
|
|
263
|
-
// default(answers) {
|
|
264
|
-
// return getDirname(answers.baseReadPath);
|
|
265
|
-
// }
|
|
266
|
-
// },
|
|
267
|
-
// {
|
|
268
|
-
// type: "input",
|
|
269
|
-
// name: "hongPath",
|
|
270
|
-
// message: "宏文件地址:",
|
|
271
|
-
// default: ""
|
|
272
|
-
// }
|
|
273
|
-
// ],
|
|
274
|
-
// // 翻译文件检查
|
|
275
|
-
// [
|
|
276
|
-
// {
|
|
277
|
-
// type: "input",
|
|
278
|
-
// name: "outExcel",
|
|
279
|
-
// message: "输出的excel文件地址:",
|
|
280
|
-
// default: "C:\\Users\\Administrator\\Desktop\\a.xlsx"
|
|
281
|
-
// },
|
|
282
|
-
// {
|
|
283
|
-
// type: "input",
|
|
284
|
-
// name: "inExcel",
|
|
285
|
-
// message: "最终excel文件地址:",
|
|
286
|
-
// default: "C:\\Users\\Administrator\\Desktop\\b.xlsx"
|
|
287
|
-
// },
|
|
288
|
-
// {
|
|
289
|
-
// type: "input",
|
|
290
|
-
// name: "baseCheckPath",
|
|
291
|
-
// message: "待检查文件根目录:"
|
|
292
|
-
// },
|
|
293
|
-
// {
|
|
294
|
-
// type: "input",
|
|
295
|
-
// name: "jsonPath",
|
|
296
|
-
// message: "语言包文件夹地址:"
|
|
297
|
-
// },
|
|
298
|
-
// {
|
|
299
|
-
// type: "input",
|
|
300
|
-
// name: "outExcelPath",
|
|
301
|
-
// message: "输出Excel文件目录:"
|
|
302
|
-
// }
|
|
303
|
-
// ],
|
|
304
|
-
// // 文件转码
|
|
305
|
-
// [
|
|
306
|
-
// {
|
|
307
|
-
// type: "input",
|
|
308
|
-
// name: "transFilePath",
|
|
309
|
-
// message: "待转码文件地址"
|
|
310
|
-
// },
|
|
311
|
-
// {
|
|
312
|
-
// type: "input",
|
|
313
|
-
// name: "transOutPath",
|
|
314
|
-
// message: "转码后文件输出地址"
|
|
315
|
-
// },
|
|
316
|
-
// {
|
|
317
|
-
// type: "input",
|
|
318
|
-
// name: "transEncode",
|
|
319
|
-
// message: "转码后文件的编码方式(默认UTF-8)"
|
|
320
|
-
// }
|
|
321
|
-
// ]
|
|
322
|
-
// ];
|
|
323
|
-
|
|
324
71
|
/**
|
|
325
72
|
* 初始化b28.config.js文件
|
|
326
73
|
*/
|
package/dist/debug/test.js
CHANGED
|
@@ -15,8 +15,9 @@ var hongPath = "./test/TestFile/config/index.js";
|
|
|
15
15
|
function getWords() {
|
|
16
16
|
(0, _index2.default)({
|
|
17
17
|
commandType: _config.COMMAD.GET_WORDS,
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
isOrigin: true,
|
|
19
|
+
baseReadPath: "D:/Desktop/trans/test/outSrc",
|
|
20
|
+
baseOutPath: "D:/Desktop/trans",
|
|
20
21
|
hongPath: hongPath
|
|
21
22
|
}).then(function (data) {
|
|
22
23
|
var t = data;
|
|
@@ -227,7 +228,7 @@ function transOrigin() {
|
|
|
227
228
|
}
|
|
228
229
|
|
|
229
230
|
module.exports = function () {
|
|
230
|
-
var command = "
|
|
231
|
+
var command = "getWord";
|
|
231
232
|
switch (command) {
|
|
232
233
|
case "check":
|
|
233
234
|
check();
|
|
@@ -32,10 +32,13 @@ var ExtractOld = function (_Extract) {
|
|
|
32
32
|
|
|
33
33
|
function ExtractOld(option) {
|
|
34
34
|
(0, _classCallCheck3.default)(this, ExtractOld);
|
|
35
|
-
return (0, _possibleConstructorReturn3.default)(this, _Extract.call(this, option,
|
|
35
|
+
return (0, _possibleConstructorReturn3.default)(this, _Extract.call(this, option, "regexp"));
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
ExtractOld.prototype.transNode = function transNode(content) {
|
|
39
|
+
if (this.option.isOrigin) {
|
|
40
|
+
content = content.replace(/<%([^\n]*?)%>/gi, "");
|
|
41
|
+
}
|
|
39
42
|
return Promise.resolve(content);
|
|
40
43
|
};
|
|
41
44
|
|
package/dist/extract/extract.js
CHANGED
|
@@ -34,6 +34,8 @@ var Extract = function () {
|
|
|
34
34
|
isTranslate: false,
|
|
35
35
|
// 是否是检查翻译
|
|
36
36
|
isCheckTrans: false,
|
|
37
|
+
// 是否是原厂代码
|
|
38
|
+
isOrigin: false,
|
|
37
39
|
// 翻译文件时,写入的根目录
|
|
38
40
|
baseWritePath: "",
|
|
39
41
|
oldData: {},
|
|
@@ -65,6 +67,9 @@ var Extract = function () {
|
|
|
65
67
|
this.isWorking = true;
|
|
66
68
|
this.curFilePath = filePath;
|
|
67
69
|
return (0, _index.loadFile)(filePath).then(function (data) {
|
|
70
|
+
if (_this.option.isOrigin) {
|
|
71
|
+
data = data.replace(/<%([^\n]*?)%>/gi, "");
|
|
72
|
+
}
|
|
68
73
|
return _this.transNode(data);
|
|
69
74
|
}).then(function (AST) {
|
|
70
75
|
return _this.scanNode(AST);
|
|
@@ -165,6 +170,10 @@ var Extract = function () {
|
|
|
165
170
|
}
|
|
166
171
|
}
|
|
167
172
|
|
|
173
|
+
if (/#(if|endif|else|elif)/ig.test(val)) {
|
|
174
|
+
return "";
|
|
175
|
+
}
|
|
176
|
+
|
|
168
177
|
val = (0, _index.trim)(val);
|
|
169
178
|
// 移除首尾空格
|
|
170
179
|
val = val.replace(/(^\s+)|(\s+$)/g, "");
|
|
@@ -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) {
|
package/dist/handle.js
CHANGED
package/dist/util/config.js
CHANGED
|
@@ -134,6 +134,11 @@ var baseQuestions = [{
|
|
|
134
134
|
default: function _default(answers) {
|
|
135
135
|
return (0, _index.getDirname)(answers.baseReadPath);
|
|
136
136
|
}
|
|
137
|
+
}, {
|
|
138
|
+
type: "confirm",
|
|
139
|
+
name: "isOrigin",
|
|
140
|
+
message: "提取原厂代码?",
|
|
141
|
+
default: false
|
|
137
142
|
}, {
|
|
138
143
|
type: "input",
|
|
139
144
|
name: "hongPath",
|