b28-cli 1.6.9 → 1.7.1
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 +2 -1
- package/dist/ExtractFile.js +3 -0
- package/dist/cmd.js +1 -254
- package/dist/debug/test.js +4 -3
- package/dist/extract/extract-html.js +2 -0
- package/dist/extract/extract-regexp.js +4 -1
- package/dist/extract/extract.js +9 -0
- package/dist/handle.js +7 -0
- package/dist/util/config.js +5 -0
- package/package.json +1 -1
package/README.MD
CHANGED
|
@@ -181,6 +181,7 @@ module.exports = {
|
|
|
181
181
|
| 属性 | 值类型 | 默认值 | 说明 |
|
|
182
182
|
| ------------ | ------- | -------------- | ------------------------- |
|
|
183
183
|
| onlyZH | Boolean | false | 只提取中文词条 |
|
|
184
|
+
| isOrigin | Boolean | false | 是否是提取接入原厂代码词条 |
|
|
184
185
|
| baseReadPath | String | `必填` | 待提取文件根目录 |
|
|
185
186
|
| baseOutPath | String | `baseReadPath` | 提取的 Excel 文件输出目录 |
|
|
186
187
|
| hongPath | String | 空 | 功能宏文件地址 |
|
|
@@ -280,7 +281,7 @@ module.exports = {
|
|
|
280
281
|
>
|
|
281
282
|
> `otherLangPath`: 原厂代码存储其它语言词条的C文件地址,多个文件用逗号连接,用于生成初始语言包json文件
|
|
282
283
|
|
|
283
|
-
|
|
284
|
+
**注意:**原厂代码修改完成后,可以用词条提取工具进行词条提取,将提取工具的`isOrigin`设为`true`即可。
|
|
284
285
|
|
|
285
286
|
**预设不进行翻译配置如下**
|
|
286
287
|
|
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,
|
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/test",
|
|
20
|
+
baseOutPath: "D:/Desktop",
|
|
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();
|
|
@@ -223,6 +223,8 @@ var ExtractHTML = function (_Extract) {
|
|
|
223
223
|
return _this4.nextJsTask();
|
|
224
224
|
}).catch(function (error) {
|
|
225
225
|
console.log(error);
|
|
226
|
+
_this4.jsHandleList = [];
|
|
227
|
+
_this4.errorList.push(_this4.curFilePath);
|
|
226
228
|
(0, _index.log)("\u5185\u8054JS\u5904\u7406\u51FA\u9519- " + error, _index.LOG_TYPE.error);
|
|
227
229
|
return _this4.nextJsTask();
|
|
228
230
|
});
|
|
@@ -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, "");
|
package/dist/handle.js
CHANGED
|
@@ -93,11 +93,15 @@ function addTrans(cfg) {
|
|
|
93
93
|
return extractOri.scanFile();
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
/**
|
|
97
|
+
* 提取词条
|
|
98
|
+
*/
|
|
96
99
|
function getWords(cfg) {
|
|
97
100
|
var extract = new _ExtractFile2.default({
|
|
98
101
|
baseReadPath: cfg.baseReadPath,
|
|
99
102
|
baseWritePath: cfg.baseOutPath,
|
|
100
103
|
onlyZH: cfg.onlyZH,
|
|
104
|
+
isOrigin: cfg.isOrigin,
|
|
101
105
|
hongPath: cfg.hongPath,
|
|
102
106
|
writeExcel: true,
|
|
103
107
|
needFilePath: true
|
|
@@ -195,6 +199,9 @@ function checkExcel(cfg) {
|
|
|
195
199
|
});
|
|
196
200
|
}
|
|
197
201
|
|
|
202
|
+
/**
|
|
203
|
+
* 提取词条及json文件生成一个excel表格
|
|
204
|
+
*/
|
|
198
205
|
function getAllWords(cfg) {
|
|
199
206
|
var extract = new _ExtractFile2.default({
|
|
200
207
|
jsonPath: cfg.languagePath,
|
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",
|