b28-cli 1.7.1 → 1.7.2

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.
Files changed (74) hide show
  1. package/.babelrc +13 -13
  2. package/README.MD +470 -466
  3. package/TestFile/output/lang/BRPT.json +24 -0
  4. package/TestFile/output/lang/CN.json +24 -0
  5. package/TestFile/output/lang/CS.json +24 -0
  6. package/TestFile/output/lang/DE.json +24 -0
  7. package/TestFile/output/lang/EN.json +24 -0
  8. package/TestFile/output/lang/ES.json +24 -0
  9. package/TestFile/output/lang/FR.json +24 -0
  10. package/TestFile/output/lang/HU.json +24 -0
  11. package/TestFile/output/lang/IT.json +24 -0
  12. package/TestFile/output/lang/KO.json +24 -0
  13. package/TestFile/output/lang/LAES.json +24 -0
  14. package/TestFile/output/lang/NL.json +24 -0
  15. package/TestFile/output/lang/PL.json +24 -0
  16. package/TestFile/output/lang/PT.json +24 -0
  17. package/TestFile/output/lang/RO.json +24 -0
  18. package/TestFile/output/lang/RU.json +24 -0
  19. package/TestFile/output/lang/TR.json +24 -0
  20. package/TestFile/output/lang/UK.json +24 -0
  21. package/TestFile/output/lang/ZH.json +24 -0
  22. package/TestFile/output/lang/brpt/translate.json +23 -0
  23. package/TestFile/output/lang/cn/translate.json +23 -0
  24. package/TestFile/output/lang/cs/translate.json +23 -0
  25. package/TestFile/output/lang/de/translate.json +23 -0
  26. package/TestFile/output/lang/es/translate.json +23 -0
  27. package/TestFile/output/lang/fr/translate.json +23 -0
  28. package/TestFile/output/lang/hu/translate.json +23 -0
  29. package/TestFile/output/lang/it/translate.json +23 -0
  30. package/TestFile/output/lang/ko/translate.json +23 -0
  31. package/TestFile/output/lang/laes/translate.json +23 -0
  32. package/TestFile/output/lang/nl/translate.json +23 -0
  33. package/TestFile/output/lang/pl/translate.json +23 -0
  34. package/TestFile/output/lang/pt/translate.json +23 -0
  35. package/TestFile/output/lang/ro/translate.json +23 -0
  36. package/TestFile/output/lang/ru/translate.json +23 -0
  37. package/TestFile/output/lang/tr/translate.json +23 -0
  38. package/TestFile/output/lang/uk/translate.json +23 -0
  39. package/TestFile/output/lang/zh/translate.json +23 -0
  40. package/TestFile/output/lang.json +25 -0
  41. package/b28n.js +739 -739
  42. package/b28nPigeonhole/11ac_ecos_b28n.js +677 -677
  43. package/b28nPigeonhole/11ac_linux_b28n_async.js +709 -709
  44. package/b28nPigeonhole/4G03_b28n_async.js +708 -708
  45. package/b28nPigeonhole/G5310P_b28n.js +650 -650
  46. package/b28nPigeonhole/es5b28n.js +711 -711
  47. package/b28nPigeonhole/es6b28n.js +857 -857
  48. package/b28nPigeonhole/readMe.md +20 -20
  49. package/b28nPigeonhole//345/276/256/344/274/201/350/267/257/347/224/261b28n.js +916 -916
  50. package/dist/ExtractLangExcel.js +138 -45
  51. package/dist/cmd.js +14 -9
  52. package/dist/excel2json.js +215 -54
  53. package/dist/extract/extract-html.js +2 -2
  54. package/dist/extract/extract-js.js +2 -2
  55. package/dist/extract/extract-regexp.js +2 -2
  56. package/dist/extract/extract-vue.js +9 -9
  57. package/dist/extract/extract.js +4 -4
  58. package/dist/extract/extractRegexp/index.js +6 -6
  59. package/dist/extract/vue/html-parser.js +16 -16
  60. package/dist/extract/vue/util.js +2 -2
  61. package/dist/extract/vue/vue-compiler.js +2 -2
  62. package/dist/extractOrigin/extract.js +2 -2
  63. package/dist/extractOrigin/extract_html_ori.js +2 -2
  64. package/dist/extractOrigin/extract_js_ori.js +2 -2
  65. package/dist/handle.js +57 -7
  66. package/dist/index.js +36 -7
  67. package/dist/mergeExcel.js +407 -0
  68. package/dist/mergeJson.js +423 -2
  69. package/dist/util/config.js +90 -32
  70. package/dist/util/index.js +48 -41
  71. package/index.js +5 -5
  72. package/package.json +63 -62
  73. package/result.txt +53 -53
  74. package/test.js +182 -182
@@ -28,9 +28,9 @@ var LOG_TYPE = {
28
28
  DONE: 4
29
29
  };
30
30
 
31
- /**
32
- * 对字符串重新编码,字符串前面加上8位的特殊编码
33
- * @param {String} key 需要进行重新编码的字符串
31
+ /**
32
+ * 对字符串重新编码,字符串前面加上8位的特殊编码
33
+ * @param {String} key 需要进行重新编码的字符串
34
34
  */
35
35
  function formatKey(key) {
36
36
  var arr = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"],
@@ -41,9 +41,9 @@ function formatKey(key) {
41
41
  return code.replace(/\{0\}/g, arr[Math.floor(Math.random() * l)]).replace(/\{1\}/g, arr[Math.floor(Math.random() * l)]).replace(/\{2\}/g, arr[Math.floor(Math.random() * l)]).replace(/\{3\}/g, arr[Math.floor(Math.random() * l)]) + key;
42
42
  }
43
43
 
44
- /**
45
- * 对重新编码的字符串进行解码
46
- * @param {String} key 需要解码的字符串
44
+ /**
45
+ * 对重新编码的字符串进行解码
46
+ * @param {String} key 需要解码的字符串
47
47
  */
48
48
  function decodeKey(key) {
49
49
  if (!key) {
@@ -60,10 +60,10 @@ function getDirname(filePath) {
60
60
  return filePath;
61
61
  }
62
62
 
63
- /**
64
- * 异步加载json文件
65
- * 返回Promise,
66
- * @param {String} src 文件绝对路径
63
+ /**
64
+ * 异步加载json文件
65
+ * 返回Promise,
66
+ * @param {String} src 文件绝对路径
67
67
  */
68
68
  function loadFile(src) {
69
69
  return new Promise(function (resolve, reject) {
@@ -86,10 +86,10 @@ function loadFileSync(src) {
86
86
  }
87
87
  }
88
88
 
89
- /**
90
- * 异步加载json文件
91
- * 返回Promise,参数为Object
92
- * @param {String} src 文件绝对路径
89
+ /**
90
+ * 异步加载json文件
91
+ * 返回Promise,参数为Object
92
+ * @param {String} src 文件绝对路径
93
93
  */
94
94
  function loadJson(src) {
95
95
  return loadFile(src).then(function (data) {
@@ -100,10 +100,10 @@ function loadJson(src) {
100
100
  });
101
101
  }
102
102
 
103
- /**
104
- * 同步加载json文件
105
- * 返回Promise,参数为Object
106
- * @param {String} src 文件绝对路径
103
+ /**
104
+ * 同步加载json文件
105
+ * 返回Promise,参数为Object
106
+ * @param {String} src 文件绝对路径
107
107
  */
108
108
  function loadJsonSync(src) {
109
109
  try {
@@ -152,10 +152,10 @@ var styles = {
152
152
  yellowBG: ["\x1B[43m", "\x1B[49m"]
153
153
  };
154
154
 
155
- /**
156
- * 不同类型的日志打印
157
- * @param {String} message 日志信息
158
- * @param {Number} type 日志类型
155
+ /**
156
+ * 不同类型的日志打印
157
+ * @param {String} message 日志信息
158
+ * @param {Number} type 日志类型
159
159
  */
160
160
  function log(message) {
161
161
  var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : LOG_TYPE.LOG;
@@ -179,9 +179,9 @@ function log(message) {
179
179
  }
180
180
  }
181
181
 
182
- /**
183
- * 读取excel
184
- * @param {String} xlsxPath excel文件地址
182
+ /**
183
+ * 读取excel
184
+ * @param {String} xlsxPath excel文件地址
185
185
  */
186
186
  function loadExcel(xlsxPath, sheetName) {
187
187
  var data = _yhNodeXlsx2.default.parse(xlsxPath);
@@ -205,10 +205,10 @@ function loadExcel(xlsxPath, sheetName) {
205
205
  return outData;
206
206
  }
207
207
 
208
- /**
209
- *
210
- * @param {Array} data 写入excel中的数据
211
- * @param {String} outPath 导出的excel文件名+地址(绝对路径)
208
+ /**
209
+ *
210
+ * @param {Array} data 写入excel中的数据
211
+ * @param {String} outPath 导出的excel文件名+地址(绝对路径)
212
212
  */
213
213
  function writeExcel(data, outPath, sheetName) {
214
214
  createFolder(_path2.default.dirname(outPath));
@@ -261,10 +261,10 @@ function createFolder(folder) {
261
261
  }
262
262
  }
263
263
 
264
- /**
265
- * 深度合并
266
- * @param {Object} oldObj 被合并对象
267
- * @param {Object} newObj 合并对象
264
+ /**
265
+ * 深度合并
266
+ * @param {Object} oldObj 被合并对象
267
+ * @param {Object} newObj 合并对象
268
268
  */
269
269
  function deepMerge(oldObj, newObj) {
270
270
  for (var key in newObj) {
@@ -292,10 +292,17 @@ function mergeObject(main, other) {
292
292
 
293
293
  for (var key in other) {
294
294
  var data = other[key];
295
- if (main[key] !== undefined && (0, _typeof3.default)(main[key]) === "object" && (typeof data === "undefined" ? "undefined" : (0, _typeof3.default)(data)) === "object") {
295
+ // 跳过undefined值,避免污染合并结果
296
+ if (data === undefined) {
297
+ continue;
298
+ }
299
+ if (main[key] !== undefined && (0, _typeof3.default)(main[key]) === "object" && main[key] !== null && (typeof data === "undefined" ? "undefined" : (0, _typeof3.default)(data)) === "object" && data !== null) {
296
300
  main[key] = mergeObject(main[key], data);
297
301
  } else {
298
- main[key] = data;
302
+ // 只赋值非undefined的值
303
+ if (data !== undefined) {
304
+ main[key] = data;
305
+ }
299
306
  }
300
307
  }
301
308
 
@@ -317,8 +324,8 @@ function partMerge(obj, main) {
317
324
  return outData;
318
325
  }
319
326
 
320
- /**
321
- * 扫描文件夹内的文件
327
+ /**
328
+ * 扫描文件夹内的文件
322
329
  */
323
330
  function scanFolder(folder) {
324
331
  var fileList = [],
@@ -377,8 +384,8 @@ function copyFile(src, dist) {
377
384
  _fs2.default.createReadStream(src).pipe(_fs2.default.createWriteStream(dist));
378
385
  }
379
386
 
380
- /**
381
- * 修正路劲
387
+ /**
388
+ * 修正路劲
382
389
  */
383
390
  function correctPath(filePath) {
384
391
  filePath += "";
@@ -392,8 +399,8 @@ function correctPath(filePath) {
392
399
  return filePath.replace(/\\/g, "/");
393
400
  }
394
401
 
395
- /**
396
- * 移除空格
402
+ /**
403
+ * 移除空格
397
404
  */
398
405
  function trim(text) {
399
406
  return text.replace(/(^\s+)|(\s+$)/g, "");
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
- #!/usr/bin/env node
2
-
3
- const start = require("./dist/index");
4
-
5
- start.default();
1
+ #!/usr/bin/env node
2
+
3
+ const start = require("./dist/index");
4
+
5
+ start.default();
package/package.json CHANGED
@@ -1,62 +1,63 @@
1
- {
2
- "name": "b28-cli",
3
- "version": "1.7.1",
4
- "description": "translate, ExcelToJson, JsonToExcel, getText, l18n",
5
- "main": "./src/index.js",
6
- "bin": {
7
- "b28-cli": "./index.js"
8
- },
9
- "author": "moshang",
10
- "keywords": [
11
- "translation",
12
- "b28",
13
- "Excel2JSON",
14
- "JSON2Excel",
15
- "translate file",
16
- "mergeJSON",
17
- "mergeObject",
18
- "getWords",
19
- "gettext",
20
- "checkLangExcel"
21
- ],
22
- "license": "ISC",
23
- "repository": {
24
- "type": "git",
25
- "url": "https://github.com/moshang-xc/translate-cli.git"
26
- },
27
- "scripts": {
28
- "compile": "babel -d dist/ src/",
29
- "build": "npm run compile",
30
- "test": "cd test & jest",
31
- "patch": "npm version patch",
32
- "minor": "npm version minor",
33
- "major": "npm version major"
34
- },
35
- "devDependencies": {
36
- "babel-cli": "^6.26.0",
37
- "babel-plugin-transform-runtime": "^6.23.0",
38
- "babel-polyfill": "^6.26.0",
39
- "babel-preset-env": "^1.7.0",
40
- "babel-preset-es2015": "^6.24.1",
41
- "babel-preset-stage-0": "^6.24.1",
42
- "babel-runtime": "^6.26.0",
43
- "jest": "^23.6.0"
44
- },
45
- "dependencies": {
46
- "babel-generator": "^6.26.0",
47
- "babylon": "^6.18.0",
48
- "figlet": "^1.2.1",
49
- "htmlparser2": "^3.10.1",
50
- "iconv-lite": "^0.5.0",
51
- "inquirer": "^6.2.2",
52
- "jschardet": "^2.1.1",
53
- "jsdom": "^10.0.0",
54
- "minimatch": "^3.0.4",
55
- "xregexp": "^4.2.4",
56
- "yh-node-xlsx": "0.0.3"
57
- },
58
- "engines": {
59
- "node": ">=6.1.3",
60
- "npm": "~3.10.0"
61
- }
62
- }
1
+ {
2
+ "name": "b28-cli",
3
+ "version": "1.7.2",
4
+ "description": "translate, ExcelToJson, JsonToExcel, getText, l18n",
5
+ "main": "./src/index.js",
6
+ "bin": {
7
+ "b28-cli": "./index.js"
8
+ },
9
+ "author": "moshang",
10
+ "keywords": [
11
+ "translation",
12
+ "b28",
13
+ "Excel2JSON",
14
+ "JSON2Excel",
15
+ "translate file",
16
+ "mergeJSON",
17
+ "mergeObject",
18
+ "getWords",
19
+ "gettext",
20
+ "checkLangExcel"
21
+ ],
22
+ "license": "ISC",
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "https://github.com/moshang-xc/translate-cli.git"
26
+ },
27
+ "scripts": {
28
+ "compile": "babel -d dist/ src/",
29
+ "build": "npm run compile",
30
+ "test": "cd test & jest",
31
+ "patch": "npm version patch",
32
+ "minor": "npm version minor",
33
+ "major": "npm version major"
34
+ },
35
+ "devDependencies": {
36
+ "babel-cli": "^6.26.0",
37
+ "babel-plugin-transform-runtime": "^6.23.0",
38
+ "babel-polyfill": "^6.26.0",
39
+ "babel-preset-env": "^1.7.0",
40
+ "babel-preset-es2015": "^6.24.1",
41
+ "babel-preset-stage-0": "^6.24.1",
42
+ "babel-runtime": "^6.26.0",
43
+ "jest": "^23.6.0"
44
+ },
45
+ "dependencies": {
46
+ "babel-generator": "^6.26.0",
47
+ "babylon": "^6.18.0",
48
+ "figlet": "^1.2.1",
49
+ "fs-extra": "^8.1.0",
50
+ "htmlparser2": "^3.10.1",
51
+ "iconv-lite": "^0.5.0",
52
+ "inquirer": "^6.2.2",
53
+ "jschardet": "^2.1.1",
54
+ "jsdom": "^10.0.0",
55
+ "minimatch": "^3.0.4",
56
+ "xregexp": "^4.2.4",
57
+ "yh-node-xlsx": "0.0.3"
58
+ },
59
+ "engines": {
60
+ "node": ">=6.1.3",
61
+ "npm": "~3.10.0"
62
+ }
63
+ }
package/result.txt CHANGED
@@ -1,53 +1,53 @@
1
- b28-cli
2
- ├── .babelrc
3
- ├── .eslintrc.js
4
- ├── .gitignore
5
- ├── .npmignore
6
- ├── B28.exe
7
- ├── b28n.js ## 浏览器中使用的翻译文件
8
- ├── index.js ## 入口文件
9
- ├── package-lock.json
10
- ├── package.json
11
- ├── README.MD
12
- ├── test ## 单元测试
13
- ├── src
14
- | ├── checkLangExcel.js ## excel翻译检查
15
- | ├── cmd.js ## 命令行交互指令处理
16
- | ├── encode.js ## 文件转码
17
- | ├── excel2json.js ## excel转接送
18
- | ├── ExtractFile.js ## 提取、翻译词条入口文件
19
- | ├── ExtractFileOrigin.js ## 原厂代码提取、翻译词条入口文件
20
- | ├── ExtractLangExcel.js ## 语言包excel解析处理
21
- | ├── handle.js ## 各功能输入参数处理
22
- | ├── index.js ## 工具入口文件
23
- | ├── json2excel.js ## json转excel
24
- | ├── mergeJson.js ## json合并
25
- | ├── util ## 工具类函数
26
- | | ├── config.js
27
- | | ├── getOption.js
28
- | | └── index.js
29
- | ├── extractOrigin ## 原厂代码处理
30
- | | ├── extract.js
31
- | | ├── extract_html_ori.js
32
- | | └── extract_js_ori.js
33
- | ├── extract ## 提取、翻译核心代码
34
- | | ├── extract-html.js ## html文件处理
35
- | | ├── extract-js.js ## js文件处理
36
- | | ├── extract-regexp.js ## 其它类型文件处理
37
- | | ├── extract-vue.js ## vue文件处理
38
- | | ├── extract.js ## 文件处理基类
39
- | | ├── vue
40
- | | | ├── html-parser.js ## vue template解析
41
- | | | ├── util.js ## 工具函数
42
- | | | └── vue-compiler.js ## Vue SPC解析
43
- | | ├── extractRegexp ## 通过正则进行文件解析核心代码
44
- | | | ├── index.js
45
- | | | └── lib.js
46
- | ├── debug ## 开发调试配置
47
- | | ├── index.js ## 调试入口
48
- | | └── test.js ## 调试用例
49
- ├── .vscode
50
- | └── launch.json ## vscode 调试配置文件
51
- ├── img
52
- └── dist
53
-
1
+ b28-cli
2
+ ├── .babelrc
3
+ ├── .eslintrc.js
4
+ ├── .gitignore
5
+ ├── .npmignore
6
+ ├── B28.exe
7
+ ├── b28n.js ## 浏览器中使用的翻译文件
8
+ ├── index.js ## 入口文件
9
+ ├── package-lock.json
10
+ ├── package.json
11
+ ├── README.MD
12
+ ├── test ## 单元测试
13
+ ├── src
14
+ | ├── checkLangExcel.js ## excel翻译检查
15
+ | ├── cmd.js ## 命令行交互指令处理
16
+ | ├── encode.js ## 文件转码
17
+ | ├── excel2json.js ## excel转接送
18
+ | ├── ExtractFile.js ## 提取、翻译词条入口文件
19
+ | ├── ExtractFileOrigin.js ## 原厂代码提取、翻译词条入口文件
20
+ | ├── ExtractLangExcel.js ## 语言包excel解析处理
21
+ | ├── handle.js ## 各功能输入参数处理
22
+ | ├── index.js ## 工具入口文件
23
+ | ├── json2excel.js ## json转excel
24
+ | ├── mergeJson.js ## json合并
25
+ | ├── util ## 工具类函数
26
+ | | ├── config.js
27
+ | | ├── getOption.js
28
+ | | └── index.js
29
+ | ├── extractOrigin ## 原厂代码处理
30
+ | | ├── extract.js
31
+ | | ├── extract_html_ori.js
32
+ | | └── extract_js_ori.js
33
+ | ├── extract ## 提取、翻译核心代码
34
+ | | ├── extract-html.js ## html文件处理
35
+ | | ├── extract-js.js ## js文件处理
36
+ | | ├── extract-regexp.js ## 其它类型文件处理
37
+ | | ├── extract-vue.js ## vue文件处理
38
+ | | ├── extract.js ## 文件处理基类
39
+ | | ├── vue
40
+ | | | ├── html-parser.js ## vue template解析
41
+ | | | ├── util.js ## 工具函数
42
+ | | | └── vue-compiler.js ## Vue SPC解析
43
+ | | ├── extractRegexp ## 通过正则进行文件解析核心代码
44
+ | | | ├── index.js
45
+ | | | └── lib.js
46
+ | ├── debug ## 开发调试配置
47
+ | | ├── index.js ## 调试入口
48
+ | | └── test.js ## 调试用例
49
+ ├── .vscode
50
+ | └── launch.json ## vscode 调试配置文件
51
+ ├── img
52
+ └── dist
53
+