Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
茶陵後
Translate Mds
提交
40fd3513
T
Translate Mds
项目概览
茶陵後
/
Translate Mds
10 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Translate Mds
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
40fd3513
编写于
11月 20, 2018
作者:
a865501259
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move: debugMsg
上级
57af7b51
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
63 addition
and
34 deletion
+63
-34
src/setObjectKey.js
src/setObjectKey.js
+15
-34
src/util/debugMsg.js
src/util/debugMsg.js
+48
-0
未找到文件。
src/setObjectKey.js
浏览文件 @
40fd3513
const
tjs
=
require
(
'
translation.js-fix
'
)
// log
const
debug
=
require
(
"
debug
"
)(
"
mds:tran
"
)
const
{
logger
,
loggerStart
,
loggerText
,
oneOra
}
=
require
(
'
./config/loggerConfig.js
'
)
// get config.json
...
...
@@ -23,6 +22,7 @@ const { translateLengthEquals } = require("./Fix/lengthEqual.js")
// Fix Too Big Array to Chunk
const
{
fixFileTooBig
,
indexMergeArr
}
=
require
(
"
./Fix/fixFileTooBig.js
"
)
const
{
tc
,
time
,
g
,
y
,
yow
,
m
,
b
,
r
,
relaPath
,
newObject
,
asyncWrite
,
asyncRead
}
=
require
(
'
./util/util.js
'
)
const
debugMsg
=
require
(
"
./util/debugMsg.js
"
)
const
MAXstring
=
1300
...
...
@@ -65,7 +65,7 @@ async function translateValue(value, api) {
return
result
.
result
}
if
(
api
==
"
youdao
"
&&
value
.
length
>
result
.
result
.
length
)
{
if
(
value
.
length
>
result
.
result
.
length
)
{
return
translateValue
(
value
.
slice
(
result
.
result
.
length
),
api
).
then
(
youdao
=>
{
// tjs translate youdao BUG and tjs baidu will return undefined
if
(
youdao
)
{
...
...
@@ -76,16 +76,15 @@ async function translateValue(value, api) {
}
}
return
result
.
result
}).
catch
(
x
=>
logger
.
error
(
`
${
api
}
炸了`
,
x
))
// Promise.reject("bad youdao fanyi no get \\n")
}).
catch
(
x
=>
{
if
(
api
==
"
baidu
"
){
result
.
result
=
result
.
result
.
concat
(
value
.
slice
(
result
.
result
.
length
))
}
return
result
.
result
})
}
if
(
value
.
length
!=
result
.
result
.
length
){
throw
new
Error
(
`
${
api
}
-error
${
result
.
result
.
length
}
/
${
value
.
length
}
`
)
}
return
[]
return
result
.
result
}).
catch
(
err
=>
{
throw
err
...
...
@@ -210,7 +209,10 @@ async function setObjectKey(obj, opts) {
// result-1 return translate value, break for allAPi
if
(
thisResult
.
length
>
0
&&
thisResult
.
length
>=
thisChunkTran
.
length
)
{
break
}
}
// debug
debugMsg
(
1
,
thisChunkTran
,
thisResult
)
api
=
allAPi
[
i
]
// result-2 return source value
...
...
@@ -235,30 +237,9 @@ async function setObjectKey(obj, opts) {
markChunkTran
=
translateLengthEquals
(
thisChunkTran
,
thisResult
)
// Fix
}
let
BigOne
=
markChunkTran
.
length
>
thisResult
.
length
?
markChunkTran
:
thisResult
let
debugInfo
=
`-- source:
${
markChunkTran
.
length
}
/
${
thisResult
.
length
}
: translte ---`
if
(
debug
.
enabled
)
{
// debug all
debug
(
debugInfo
)
for
(
let
i
in
BigOne
)
{
// Debug
if
(
!
markChunkTran
[
i
]
||
!
thisResult
[
i
]){
debug
(
'
2. set-
'
+
i
+
'
:
'
+
g
(
markChunkTran
[
i
])
+
`
${
tc
.
bgMagenta
(
'
to->
'
)}
${
i
}
: `
+
yow
(
thisResult
[
i
])
)
}
else
{
debug
(
'
2. set-
'
+
i
+
'
:
'
+
g
(
markChunkTran
[
i
])
+
'
to->
'
+
i
+
'
:
'
+
yow
(
thisResult
[
i
])
)
}
}
}
else
if
(
markChunkTran
.
length
!=
thisResult
.
length
)
{
// debug only unequal
if
(
markChunkTran
.
length
!=
thisResult
.
length
)
{
// debug only unequal
loggerText
(
debugInfo
)
for
(
let
i
in
BigOne
)
{
// Debug
if
(
!
markChunkTran
[
i
]
||
!
thisResult
[
i
]){
logger
.
debug
(
'
2. set-
'
+
i
+
'
:
'
+
g
(
markChunkTran
[
i
])
+
`
${
tc
.
bgMagenta
(
'
to->
'
)}
${
i
}
: `
+
yow
(
thisResult
[
i
]))
}
else
{
logger
.
debug
(
'
2. set-
'
+
i
+
'
:
'
+
g
(
markChunkTran
[
i
])
+
'
to->
'
+
i
+
'
:
'
+
yow
(
thisResult
[
i
]))
}
}
debugMsg
(
2
,
thisChunkTran
,
thisResult
)
}
...
...
src/util/debugMsg.js
0 → 100644
浏览文件 @
40fd3513
const
debug
=
require
(
'
debug
'
)(
'
mds:tran
'
);
const
{
tc
,
g
,
y
,
yow
,
m
,
b
,
r
}
=
require
(
'
./util.js
'
);
const
{
logger
,
loggerStart
,
loggerText
,
oneOra
}
=
require
(
'
../config/loggerConfig.js
'
);
module
.
exports
=
debugMsg
=
(
step
,
valueArr
,
resArr
)
=>
{
let
BigOne
=
valueArr
.
length
>
resArr
.
length
?
valueArr
:
resArr
;
let
debugInfo
=
`-- source:
${
valueArr
.
length
}
/
${
resArr
.
length
}
: translte ---`
;
if
(
resArr
.
length
==
0
)
return
;
function
tranSourceShow
(
debug
)
{
for
(
let
i
in
BigOne
)
{
// Debug
if
(
!
valueArr
[
i
]
||
!
resArr
[
i
])
{
debug
(
`2. set-
${
i
}
:
${
g
(
valueArr
[
i
])}
${
tc
.
bgMagenta
(
'
to->
'
)}
${
i
}
:
${
yow
(
resArr
[
i
])}
`
);
}
else
{
debug
(
`2. set-
${
i
}
:
${
g
(
valueArr
[
i
])}
to->
${
i
}
:
${
yow
(
resArr
[
i
])}
`
);
}
}
}
if
(
step
==
1
)
{
if
(
debug
.
enabled
)
{
// debug all
debug
(
debugInfo
);
tranSourceShow
(
debug
);
}
else
{
loggerText
(
debugInfo
);
}
}
else
{
loggerText
(
debugInfo
);
tranSourceShow
(
logger
.
debug
);
}
};
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录