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.
- package/.babelrc +13 -13
- package/README.MD +470 -466
- package/TestFile/output/lang/BRPT.json +24 -0
- package/TestFile/output/lang/CN.json +24 -0
- package/TestFile/output/lang/CS.json +24 -0
- package/TestFile/output/lang/DE.json +24 -0
- package/TestFile/output/lang/EN.json +24 -0
- package/TestFile/output/lang/ES.json +24 -0
- package/TestFile/output/lang/FR.json +24 -0
- package/TestFile/output/lang/HU.json +24 -0
- package/TestFile/output/lang/IT.json +24 -0
- package/TestFile/output/lang/KO.json +24 -0
- package/TestFile/output/lang/LAES.json +24 -0
- package/TestFile/output/lang/NL.json +24 -0
- package/TestFile/output/lang/PL.json +24 -0
- package/TestFile/output/lang/PT.json +24 -0
- package/TestFile/output/lang/RO.json +24 -0
- package/TestFile/output/lang/RU.json +24 -0
- package/TestFile/output/lang/TR.json +24 -0
- package/TestFile/output/lang/UK.json +24 -0
- package/TestFile/output/lang/ZH.json +24 -0
- package/TestFile/output/lang/brpt/translate.json +23 -0
- package/TestFile/output/lang/cn/translate.json +23 -0
- package/TestFile/output/lang/cs/translate.json +23 -0
- package/TestFile/output/lang/de/translate.json +23 -0
- package/TestFile/output/lang/es/translate.json +23 -0
- package/TestFile/output/lang/fr/translate.json +23 -0
- package/TestFile/output/lang/hu/translate.json +23 -0
- package/TestFile/output/lang/it/translate.json +23 -0
- package/TestFile/output/lang/ko/translate.json +23 -0
- package/TestFile/output/lang/laes/translate.json +23 -0
- package/TestFile/output/lang/nl/translate.json +23 -0
- package/TestFile/output/lang/pl/translate.json +23 -0
- package/TestFile/output/lang/pt/translate.json +23 -0
- package/TestFile/output/lang/ro/translate.json +23 -0
- package/TestFile/output/lang/ru/translate.json +23 -0
- package/TestFile/output/lang/tr/translate.json +23 -0
- package/TestFile/output/lang/uk/translate.json +23 -0
- package/TestFile/output/lang/zh/translate.json +23 -0
- package/TestFile/output/lang.json +25 -0
- package/b28n.js +739 -739
- package/b28nPigeonhole/11ac_ecos_b28n.js +677 -677
- package/b28nPigeonhole/11ac_linux_b28n_async.js +709 -709
- package/b28nPigeonhole/4G03_b28n_async.js +708 -708
- package/b28nPigeonhole/G5310P_b28n.js +650 -650
- package/b28nPigeonhole/es5b28n.js +711 -711
- package/b28nPigeonhole/es6b28n.js +857 -857
- package/b28nPigeonhole/readMe.md +20 -20
- package/b28nPigeonhole//345/276/256/344/274/201/350/267/257/347/224/261b28n.js +916 -916
- package/dist/ExtractLangExcel.js +138 -45
- package/dist/cmd.js +14 -9
- package/dist/excel2json.js +215 -54
- package/dist/extract/extract-html.js +2 -2
- package/dist/extract/extract-js.js +2 -2
- package/dist/extract/extract-regexp.js +2 -2
- package/dist/extract/extract-vue.js +9 -9
- package/dist/extract/extract.js +4 -4
- package/dist/extract/extractRegexp/index.js +6 -6
- package/dist/extract/vue/html-parser.js +16 -16
- package/dist/extract/vue/util.js +2 -2
- package/dist/extract/vue/vue-compiler.js +2 -2
- package/dist/extractOrigin/extract.js +2 -2
- package/dist/extractOrigin/extract_html_ori.js +2 -2
- package/dist/extractOrigin/extract_js_ori.js +2 -2
- package/dist/handle.js +57 -7
- package/dist/index.js +36 -7
- package/dist/mergeExcel.js +407 -0
- package/dist/mergeJson.js +423 -2
- package/dist/util/config.js +90 -32
- package/dist/util/index.js +48 -41
- package/index.js +5 -5
- package/package.json +63 -62
- package/result.txt +53 -53
- package/test.js +182 -182
package/test.js
CHANGED
|
@@ -1,182 +1,182 @@
|
|
|
1
|
-
var s = `{
|
|
2
|
-
content: '邮箱地址格式错误',
|
|
3
|
-
content: _('邮箱地址格式错误1'),
|
|
4
|
-
position: 'right-center',
|
|
5
|
-
trigger: 'manual',
|
|
6
|
-
value: !isAddrCheckPassed
|
|
7
|
-
}`;
|
|
8
|
-
|
|
9
|
-
const MSG = {
|
|
10
|
-
"邮箱地址格式错误": "Mail Addr Error"
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
function transStr(content) {
|
|
14
|
-
console.log(111)
|
|
15
|
-
//替换js中的翻译不会自动加上翻译函数,需要手动根据输出的日志文件进行添加
|
|
16
|
-
// var res = content.replace(/(_\(")(.*?)(]\))|(")(.*?)([^\\]")|(_\(")(.*?)("\))/g, function(key) {
|
|
17
|
-
return content.replace(
|
|
18
|
-
/(_\(".*?[^\\]",.*?]?\)|_\('.*?[^\\]',.*?]?\)|_\(".*?[^\\]"\)|_\('.*?[^\\]'\))/g,
|
|
19
|
-
function (key) {
|
|
20
|
-
var quote = '"',
|
|
21
|
-
singleQuote = "'";
|
|
22
|
-
|
|
23
|
-
//解决key翻译中带有\"导致未翻译的问题
|
|
24
|
-
// key = key.replace(/(\\")/g, '"');
|
|
25
|
-
//解决key翻译中带有\\导致未翻译的问题
|
|
26
|
-
// key = key.replace(/(\\\\)/g, "\\");
|
|
27
|
-
//_("",[]) || _("",xxx)情况
|
|
28
|
-
if (/(_\(")(.*?)(",)/g.test(key)) {
|
|
29
|
-
//翻译中参数带翻译
|
|
30
|
-
key = "_(" + transStr(key.slice(2, -1)) + ")";
|
|
31
|
-
key = key.replace(/(")(.*?)("),/, function (keyRep) {
|
|
32
|
-
keyRep = keyRep.slice(1, -2).replace(/(^\s*)|(\s*$)/g, "");
|
|
33
|
-
|
|
34
|
-
if (MSG[keyRep]) {
|
|
35
|
-
// return quote + MSG[keyRep].replace(/"/g, '\\"') + quote + ",";
|
|
36
|
-
return quote + MSG[keyRep] + quote + ",";
|
|
37
|
-
} else {
|
|
38
|
-
// untranswords.push(key);
|
|
39
|
-
return quote + keyRep + quote + ",";
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
return key;
|
|
44
|
-
} else if (/(_\(')(.*?)(',)/g.test(key)) {
|
|
45
|
-
//_('',xxx) || _('',[])情况
|
|
46
|
-
key = "_(" + transStr(key.slice(2, -1)) + ")";
|
|
47
|
-
|
|
48
|
-
key = key.replace(/(')(.*?)('),/, function (keyRep) {
|
|
49
|
-
keyRep = keyRep.slice(1, -2).replace(/(^\s*)|(\s*$)/g, "");
|
|
50
|
-
|
|
51
|
-
if (MSG[keyRep]) {
|
|
52
|
-
return (
|
|
53
|
-
// singleQuote + MSG[keyRep].replace(/'/g, "\\'") + singleQuote + ","
|
|
54
|
-
singleQuote + MSG[keyRep] + singleQuote + ","
|
|
55
|
-
);
|
|
56
|
-
} else {
|
|
57
|
-
// untranswords.push(key);
|
|
58
|
-
return singleQuote + keyRep + singleQuote + ",";
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
return key;
|
|
62
|
-
} else if (/(_\(")(.*?)("\))/g.test(key)) {
|
|
63
|
-
//下划线翻译处理
|
|
64
|
-
if (key !== "") {
|
|
65
|
-
key = key.slice(3, -2).replace(/(^\s*)|(\s*$)/g, "");
|
|
66
|
-
|
|
67
|
-
if (MSG[key]) {
|
|
68
|
-
// return "_(" + quote + MSG[key].replace(/"/g, '\\"') + quote + ")";
|
|
69
|
-
return "_(" + quote + MSG[key] + quote + ")";
|
|
70
|
-
} else {
|
|
71
|
-
// untranswords.push(key);
|
|
72
|
-
return "_(" + quote + key + quote + ")";
|
|
73
|
-
}
|
|
74
|
-
} else {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
} else if (/(_\(')(.*?)('\))/g.test(key)) {
|
|
78
|
-
//下划线翻译处理
|
|
79
|
-
if (key !== "") {
|
|
80
|
-
key = key.slice(3, -2).replace(/(^\s*)|(\s*$)/g, "");
|
|
81
|
-
|
|
82
|
-
if (MSG[key]) {
|
|
83
|
-
return (
|
|
84
|
-
"_(" +
|
|
85
|
-
singleQuote +
|
|
86
|
-
// MSG[key].replace(/"/g, '\\"') +
|
|
87
|
-
MSG[key] +
|
|
88
|
-
singleQuote +
|
|
89
|
-
")"
|
|
90
|
-
);
|
|
91
|
-
} else {
|
|
92
|
-
// untranswords.push(key);
|
|
93
|
-
return "_(" + quote + key + quote + ")";
|
|
94
|
-
}
|
|
95
|
-
} else {
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
} else {
|
|
99
|
-
key = key.slice(1, -1).replace(/(^\s*)|(\s*$)/g, "");
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
if (/[\u4e00-\u9fa5]/.test(key) || /[a-zA-Z]/.test(key)) {
|
|
103
|
-
// untranswords.push(key);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// return quote + key.replace(/"/g, '\\"') + quote;
|
|
107
|
-
return quote + key + quote;
|
|
108
|
-
}
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function filter(keys, key, index) {
|
|
113
|
-
return keys.some(function (v) {
|
|
114
|
-
//added by zy 考虑如下情况 import "xxx" key.lastIndexOf(v) === index-v.length //true 所有要先判断是否为-1
|
|
115
|
-
if (
|
|
116
|
-
v === key ||
|
|
117
|
-
(key.lastIndexOf(v) !== -1 && key.lastIndexOf(v) === index - v.length)
|
|
118
|
-
)
|
|
119
|
-
return true;
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
function getWords(content) {
|
|
124
|
-
pageRemark = [];
|
|
125
|
-
var regqutoe = new RegExp(/((["'])(?:\\.|[^\\\n])*?\2)/g); //获取""和''内的内容包括引号
|
|
126
|
-
var matchKeyWord = ["_("];
|
|
127
|
-
var maxBackLen = 25; //定义最长回溯长度,一般js里的关键字长度不会超过25
|
|
128
|
-
|
|
129
|
-
var ret = [];
|
|
130
|
-
|
|
131
|
-
//对于已注释的代码不进行提取操作
|
|
132
|
-
//去除 /* xxx */ 或者// 注释的代码段
|
|
133
|
-
content = content.replace(
|
|
134
|
-
/((\/\*)((.|\s)*?)(\*\/))|((\/\/)((?:\\.|[^\\\n])*?)(\n))/g,
|
|
135
|
-
""
|
|
136
|
-
);
|
|
137
|
-
//end
|
|
138
|
-
|
|
139
|
-
content.replace(regqutoe, function (matchString) {
|
|
140
|
-
matchString = matchString.slice(1, matchString.length - 1);
|
|
141
|
-
if (matchString.trim().length > 0) {
|
|
142
|
-
if (/[\u4e00-\u9fa5]/.test(matchString)) {
|
|
143
|
-
//是否含有中文
|
|
144
|
-
if (/_\(['"].*?['"][\),]/.test(matchString)) {
|
|
145
|
-
//说明是在引号中间包裹的_("")
|
|
146
|
-
//分为带参数,不带参数
|
|
147
|
-
//双引号 单引号的四种情况
|
|
148
|
-
matchString = matchString
|
|
149
|
-
.split("_('")
|
|
150
|
-
.pop()
|
|
151
|
-
.split(`_("`)
|
|
152
|
-
.pop()
|
|
153
|
-
.split("',")[0]
|
|
154
|
-
.split(`",`)[0]
|
|
155
|
-
.split(`")`)[0]
|
|
156
|
-
.split(`')`)[0];
|
|
157
|
-
}
|
|
158
|
-
ret.push(matchString);
|
|
159
|
-
} else {
|
|
160
|
-
if (matchString.trim().length > 1 && /[a-z]/i.test(matchString)) {
|
|
161
|
-
var backLength =
|
|
162
|
-
arguments[3] >= maxBackLen ? maxBackLen : arguments[3]; //计算回溯长度,一般js里的关键字长度不会超过25
|
|
163
|
-
|
|
164
|
-
var backStr = content.substr(arguments[3] - backLength, backLength);
|
|
165
|
-
if (
|
|
166
|
-
filter(matchKeyWord, backStr, backLength) ||
|
|
167
|
-
(matchString.indexOf(" ") > -1 &&
|
|
168
|
-
!/^[#\.]|/.test(trim(matchString)))
|
|
169
|
-
) {
|
|
170
|
-
//回溯查找
|
|
171
|
-
ret.push(matchString);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
return ret;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
console.log(getWords(s));
|
|
182
|
-
console.log(transStr(s));
|
|
1
|
+
var s = `{
|
|
2
|
+
content: '邮箱地址格式错误',
|
|
3
|
+
content: _('邮箱地址格式错误1'),
|
|
4
|
+
position: 'right-center',
|
|
5
|
+
trigger: 'manual',
|
|
6
|
+
value: !isAddrCheckPassed
|
|
7
|
+
}`;
|
|
8
|
+
|
|
9
|
+
const MSG = {
|
|
10
|
+
"邮箱地址格式错误": "Mail Addr Error"
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
function transStr(content) {
|
|
14
|
+
console.log(111)
|
|
15
|
+
//替换js中的翻译不会自动加上翻译函数,需要手动根据输出的日志文件进行添加
|
|
16
|
+
// var res = content.replace(/(_\(")(.*?)(]\))|(")(.*?)([^\\]")|(_\(")(.*?)("\))/g, function(key) {
|
|
17
|
+
return content.replace(
|
|
18
|
+
/(_\(".*?[^\\]",.*?]?\)|_\('.*?[^\\]',.*?]?\)|_\(".*?[^\\]"\)|_\('.*?[^\\]'\))/g,
|
|
19
|
+
function (key) {
|
|
20
|
+
var quote = '"',
|
|
21
|
+
singleQuote = "'";
|
|
22
|
+
|
|
23
|
+
//解决key翻译中带有\"导致未翻译的问题
|
|
24
|
+
// key = key.replace(/(\\")/g, '"');
|
|
25
|
+
//解决key翻译中带有\\导致未翻译的问题
|
|
26
|
+
// key = key.replace(/(\\\\)/g, "\\");
|
|
27
|
+
//_("",[]) || _("",xxx)情况
|
|
28
|
+
if (/(_\(")(.*?)(",)/g.test(key)) {
|
|
29
|
+
//翻译中参数带翻译
|
|
30
|
+
key = "_(" + transStr(key.slice(2, -1)) + ")";
|
|
31
|
+
key = key.replace(/(")(.*?)("),/, function (keyRep) {
|
|
32
|
+
keyRep = keyRep.slice(1, -2).replace(/(^\s*)|(\s*$)/g, "");
|
|
33
|
+
|
|
34
|
+
if (MSG[keyRep]) {
|
|
35
|
+
// return quote + MSG[keyRep].replace(/"/g, '\\"') + quote + ",";
|
|
36
|
+
return quote + MSG[keyRep] + quote + ",";
|
|
37
|
+
} else {
|
|
38
|
+
// untranswords.push(key);
|
|
39
|
+
return quote + keyRep + quote + ",";
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
return key;
|
|
44
|
+
} else if (/(_\(')(.*?)(',)/g.test(key)) {
|
|
45
|
+
//_('',xxx) || _('',[])情况
|
|
46
|
+
key = "_(" + transStr(key.slice(2, -1)) + ")";
|
|
47
|
+
|
|
48
|
+
key = key.replace(/(')(.*?)('),/, function (keyRep) {
|
|
49
|
+
keyRep = keyRep.slice(1, -2).replace(/(^\s*)|(\s*$)/g, "");
|
|
50
|
+
|
|
51
|
+
if (MSG[keyRep]) {
|
|
52
|
+
return (
|
|
53
|
+
// singleQuote + MSG[keyRep].replace(/'/g, "\\'") + singleQuote + ","
|
|
54
|
+
singleQuote + MSG[keyRep] + singleQuote + ","
|
|
55
|
+
);
|
|
56
|
+
} else {
|
|
57
|
+
// untranswords.push(key);
|
|
58
|
+
return singleQuote + keyRep + singleQuote + ",";
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
return key;
|
|
62
|
+
} else if (/(_\(")(.*?)("\))/g.test(key)) {
|
|
63
|
+
//下划线翻译处理
|
|
64
|
+
if (key !== "") {
|
|
65
|
+
key = key.slice(3, -2).replace(/(^\s*)|(\s*$)/g, "");
|
|
66
|
+
|
|
67
|
+
if (MSG[key]) {
|
|
68
|
+
// return "_(" + quote + MSG[key].replace(/"/g, '\\"') + quote + ")";
|
|
69
|
+
return "_(" + quote + MSG[key] + quote + ")";
|
|
70
|
+
} else {
|
|
71
|
+
// untranswords.push(key);
|
|
72
|
+
return "_(" + quote + key + quote + ")";
|
|
73
|
+
}
|
|
74
|
+
} else {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
} else if (/(_\(')(.*?)('\))/g.test(key)) {
|
|
78
|
+
//下划线翻译处理
|
|
79
|
+
if (key !== "") {
|
|
80
|
+
key = key.slice(3, -2).replace(/(^\s*)|(\s*$)/g, "");
|
|
81
|
+
|
|
82
|
+
if (MSG[key]) {
|
|
83
|
+
return (
|
|
84
|
+
"_(" +
|
|
85
|
+
singleQuote +
|
|
86
|
+
// MSG[key].replace(/"/g, '\\"') +
|
|
87
|
+
MSG[key] +
|
|
88
|
+
singleQuote +
|
|
89
|
+
")"
|
|
90
|
+
);
|
|
91
|
+
} else {
|
|
92
|
+
// untranswords.push(key);
|
|
93
|
+
return "_(" + quote + key + quote + ")";
|
|
94
|
+
}
|
|
95
|
+
} else {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
} else {
|
|
99
|
+
key = key.slice(1, -1).replace(/(^\s*)|(\s*$)/g, "");
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (/[\u4e00-\u9fa5]/.test(key) || /[a-zA-Z]/.test(key)) {
|
|
103
|
+
// untranswords.push(key);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// return quote + key.replace(/"/g, '\\"') + quote;
|
|
107
|
+
return quote + key + quote;
|
|
108
|
+
}
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function filter(keys, key, index) {
|
|
113
|
+
return keys.some(function (v) {
|
|
114
|
+
//added by zy 考虑如下情况 import "xxx" key.lastIndexOf(v) === index-v.length //true 所有要先判断是否为-1
|
|
115
|
+
if (
|
|
116
|
+
v === key ||
|
|
117
|
+
(key.lastIndexOf(v) !== -1 && key.lastIndexOf(v) === index - v.length)
|
|
118
|
+
)
|
|
119
|
+
return true;
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function getWords(content) {
|
|
124
|
+
pageRemark = [];
|
|
125
|
+
var regqutoe = new RegExp(/((["'])(?:\\.|[^\\\n])*?\2)/g); //获取""和''内的内容包括引号
|
|
126
|
+
var matchKeyWord = ["_("];
|
|
127
|
+
var maxBackLen = 25; //定义最长回溯长度,一般js里的关键字长度不会超过25
|
|
128
|
+
|
|
129
|
+
var ret = [];
|
|
130
|
+
|
|
131
|
+
//对于已注释的代码不进行提取操作
|
|
132
|
+
//去除 /* xxx */ 或者// 注释的代码段
|
|
133
|
+
content = content.replace(
|
|
134
|
+
/((\/\*)((.|\s)*?)(\*\/))|((\/\/)((?:\\.|[^\\\n])*?)(\n))/g,
|
|
135
|
+
""
|
|
136
|
+
);
|
|
137
|
+
//end
|
|
138
|
+
|
|
139
|
+
content.replace(regqutoe, function (matchString) {
|
|
140
|
+
matchString = matchString.slice(1, matchString.length - 1);
|
|
141
|
+
if (matchString.trim().length > 0) {
|
|
142
|
+
if (/[\u4e00-\u9fa5]/.test(matchString)) {
|
|
143
|
+
//是否含有中文
|
|
144
|
+
if (/_\(['"].*?['"][\),]/.test(matchString)) {
|
|
145
|
+
//说明是在引号中间包裹的_("")
|
|
146
|
+
//分为带参数,不带参数
|
|
147
|
+
//双引号 单引号的四种情况
|
|
148
|
+
matchString = matchString
|
|
149
|
+
.split("_('")
|
|
150
|
+
.pop()
|
|
151
|
+
.split(`_("`)
|
|
152
|
+
.pop()
|
|
153
|
+
.split("',")[0]
|
|
154
|
+
.split(`",`)[0]
|
|
155
|
+
.split(`")`)[0]
|
|
156
|
+
.split(`')`)[0];
|
|
157
|
+
}
|
|
158
|
+
ret.push(matchString);
|
|
159
|
+
} else {
|
|
160
|
+
if (matchString.trim().length > 1 && /[a-z]/i.test(matchString)) {
|
|
161
|
+
var backLength =
|
|
162
|
+
arguments[3] >= maxBackLen ? maxBackLen : arguments[3]; //计算回溯长度,一般js里的关键字长度不会超过25
|
|
163
|
+
|
|
164
|
+
var backStr = content.substr(arguments[3] - backLength, backLength);
|
|
165
|
+
if (
|
|
166
|
+
filter(matchKeyWord, backStr, backLength) ||
|
|
167
|
+
(matchString.indexOf(" ") > -1 &&
|
|
168
|
+
!/^[#\.]|/.test(trim(matchString)))
|
|
169
|
+
) {
|
|
170
|
+
//回溯查找
|
|
171
|
+
ret.push(matchString);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
return ret;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
console.log(getWords(s));
|
|
182
|
+
console.log(transStr(s));
|