Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jiedao-app-operator-master
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lanbaoming
jiedao-app-operator-master
Commits
089e73bd
Commit
089e73bd
authored
Jan 06, 2024
by
dragondean@qq.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完善翻译
parent
18983f23
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
190 additions
and
20 deletions
+190
-20
collectI18nMessages.js
collectI18nMessages.js
+31
-19
en_US.json
src/i18n/languages/en_US.json
+159
-1
No files found.
collectI18nMessages.js
View file @
089e73bd
...
@@ -40,7 +40,7 @@ const translateText = (text, fromLang = 'zh', toLang = 'en') => {
...
@@ -40,7 +40,7 @@ const translateText = (text, fromLang = 'zh', toLang = 'en') => {
'
Content-Length
'
:
querystring
.
stringify
(
params
).
length
'
Content-Length
'
:
querystring
.
stringify
(
params
).
length
}
}
};
};
try
{
const
req
=
https
.
request
(
options
,
(
res
)
=>
{
const
req
=
https
.
request
(
options
,
(
res
)
=>
{
let
data
=
''
;
let
data
=
''
;
...
@@ -60,6 +60,10 @@ const translateText = (text, fromLang = 'zh', toLang = 'en') => {
...
@@ -60,6 +60,10 @@ const translateText = (text, fromLang = 'zh', toLang = 'en') => {
req
.
write
(
querystring
.
stringify
(
params
));
req
.
write
(
querystring
.
stringify
(
params
));
req
.
end
();
req
.
end
();
}
catch
(
e
)
{
console
.
log
(
text
+
"
翻译失败:
"
+
e
)
}
})
})
};
};
...
@@ -96,11 +100,19 @@ async function translate(obj){
...
@@ -96,11 +100,19 @@ async function translate(obj){
// 对未翻译内容调用百度翻译进行翻译操作,有变量的不做处理
// 对未翻译内容调用百度翻译进行翻译操作,有变量的不做处理
for
(
let
text
in
obj
){
for
(
let
text
in
obj
){
if
(
obj
[
text
]
||
text
.
includes
(
'
{
'
))
continue
if
(
obj
[
text
]
||
text
.
includes
(
'
{
'
))
continue
try
{
const
textEn
=
await
translateText
(
text
)
const
textEn
=
await
translateText
(
text
)
console
.
log
(
`
${
text
}
=>
${
textEn
}
\n`
)
console
.
log
(
`
${
text
}
=>
${
textEn
}
\n`
)
obj
[
text
]
=
textEn
obj
[
text
]
=
textEn
autoTransCnt
++
autoTransCnt
++
// 每次翻译后保存一次,防止意外退出导致的数据丢失
fs
.
writeFileSync
(
savePath
,
JSON
.
stringify
(
obj
,
null
,
4
))
}
catch
(
e
)
{
console
.
log
(
text
+
"
翻译失败:
"
+
e
)
}
// 账号请求频率限制1ps
// 账号请求频率限制1ps
await
new
Promise
(
resolve
=>
setTimeout
(
resolve
,
1000
))
await
new
Promise
(
resolve
=>
setTimeout
(
resolve
,
1000
))
}
}
...
...
src/i18n/languages/en_US.json
View file @
089e73bd
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment