Skip to content

Commit d48e425

Browse files
committed
Add .gitignore for node_modules and update translation logic to handle TRANSLATE tags
1 parent 3370e50 commit d48e425

File tree

6 files changed

+27
-17
lines changed

6 files changed

+27
-17
lines changed

Diff for: i18n/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/node_modules

Diff for: i18n/controllers/recurTranslate.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ async function recursivelyTranslate(
331331
If a term exists in the reference file, use that translation without deviation.
332332
Do not modify XML tags, attributes of XML tags and structure. Do not say anything else.
333333
Content to translate:
334-
${chunk}`
334+
<TRANSLATE> ${chunk} </TRANSLATE>`
335335
});
336336
const run = await ai.beta.threads.runs.createAndPoll(thread.id, {
337337
assistant_id: assistant_id
@@ -369,13 +369,13 @@ async function recursivelyTranslate(
369369

370370
clean.on("opentag", node => {
371371
currDepth++;
372-
if (node.name != "WRAPPER") {
372+
if (node.name != "WRAPPER" && node.name != "TRANSLATE") {
373373
translatedChunk += `<${node.name}${formatAttributes(node.attributes)}>`;
374374
}
375375
});
376376

377377
clean.on("closetag", tagName => {
378-
if (tagName != "WRAPPER") {
378+
if (tagName != "WRAPPER" && tagName != "TRANSLATE") {
379379
translatedChunk += `</${tagName}>`;
380380
}
381381
currDepth--;

Diff for: i18n/index.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ export default async function fancyName(path: string) {
1111
(async () => {
1212
try {
1313
await Promise.all([
14-
// fancyName("2")
15-
// fancyName("1.1"),
16-
// fancyName("1.1.2"),
17-
// fancyName("1.1.3"),
18-
// fancyName("1.1.4"),
19-
// fancyName("1.1.5"),
20-
fancyName("1.1.6"),
21-
// fancyName("1.1.7")
14+
// fancyName("2"),
15+
fancyName("1.1"),
16+
fancyName("1.1.2"),
17+
fancyName("1.1.3"),
18+
fancyName("1.1.4"),
19+
fancyName("1.1.5"),
20+
// fancyName("1.1.6"),
21+
// fancyName("1.1.7"),
2222
// fancyName("1.1.8"),
2323
// translate("Chinese", "1"),
2424
]);

Diff for: i18n/package.json

+5
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,10 @@
1111
}
1212
],
1313
"dependencies": {
14+
},
15+
"devDependencies": {
16+
"dotenv": "^16.4.7",
17+
"openai": "^4.81.0",
18+
"sax": "^1.4.1"
1419
}
1520
}

Diff for: package.json

+2-5
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@
3535
"lz-string": "^1.5.0",
3636
"prettier": "^3.5.2",
3737
"xmldom": "^0.6.0",
38-
"xpath": "0.0.33",
39-
"dotenv": "^16.4.7",
40-
"openai": "^4.81.0",
41-
"sax": "^1.4.1"
38+
"xpath": "0.0.33"
4239
},
4340
"resolutions": {
4441
"**/gl": "^8.0.2"
@@ -61,7 +58,7 @@
6158
"try": "cd docs_out; http-server --cors --port 8080",
6259
"tryjson": "http-server --cors --port 8080",
6360
"nodetest": "./scripts/nodetest.sh",
64-
"trans": "npx tsx ./i18n/index.ts"
61+
"trans": "cd ./i18n && yarn install && npx tsx index.ts"
6562
},
6663
"husky": {
6764
"hooks": {

Diff for: yarn.lock

+8-1
Original file line numberDiff line numberDiff line change
@@ -1276,6 +1276,13 @@ clean-stack@^2.0.0:
12761276
resolved "https://registry.yarnpkg.com/clean-stack/-/clean-stack-2.2.0.tgz#ee8472dbb129e727b31e8a10a427dee9dfe4008b"
12771277
integrity sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==
12781278

1279+
cli-progress@^3.12.0:
1280+
version "3.12.0"
1281+
resolved "https://registry.yarnpkg.com/cli-progress/-/cli-progress-3.12.0.tgz#807ee14b66bcc086258e444ad0f19e7d42577942"
1282+
integrity sha512-tRkV3HJ1ASwm19THiiLIXLO7Im7wlTuKnvkYaTkyoAPefqjNg7W7DHKUlGRxy9vxDvbyCYQkQozvptuMkGCg8A==
1283+
dependencies:
1284+
string-width "^4.2.3"
1285+
12791286
clone-deep@^4.0.1:
12801287
version "4.0.1"
12811288
resolved "https://registry.yarnpkg.com/clone-deep/-/clone-deep-4.0.1.tgz#c19fd9bdbbf85942b4fd979c84dcf7d5f07c2387"
@@ -2914,7 +2921,7 @@ ssri@^10.0.0:
29142921
is-fullwidth-code-point "^3.0.0"
29152922
strip-ansi "^6.0.1"
29162923

2917-
string-width@^4.1.0:
2924+
string-width@^4.1.0, string-width@^4.2.3:
29182925
version "4.2.3"
29192926
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
29202927
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==

0 commit comments

Comments
 (0)