@alauda/doom 0.16.1-alpha.1 → 0.16.1
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/lib/cli/translate.js +9 -6
- package/package.json +6 -9
package/lib/cli/translate.js
CHANGED
|
@@ -6,6 +6,7 @@ import { removeLeadingSlash } from '@rspress/shared';
|
|
|
6
6
|
import { logger } from '@rspress/shared/logger';
|
|
7
7
|
import { Command } from 'commander';
|
|
8
8
|
import { render } from 'ejs';
|
|
9
|
+
import { merge } from 'es-toolkit/compat';
|
|
9
10
|
import matter from 'gray-matter';
|
|
10
11
|
import { AzureOpenAI, RateLimitError } from 'openai';
|
|
11
12
|
import { pRateLimit } from 'p-ratelimit';
|
|
@@ -36,7 +37,8 @@ const DEFAULT_SYSTEM_PROMPT = `
|
|
|
36
37
|
* 容器组 -> Pods
|
|
37
38
|
* global 集群 -> global cluster
|
|
38
39
|
- 移除 {/* reference-start */}, {/* reference-end */}, <!-- reference-start --> 和 <!-- reference-end --> 相关的注释
|
|
39
|
-
- 翻译过程中务必保留原文中的 \\< 转义字符不要做任何转义变更
|
|
40
|
+
- 翻译过程中务必保留原文中的 \\< 和 \\{ 转义字符不要做任何转义变更
|
|
41
|
+
- 翻译过程中不要破坏原有的 Markdown 格式,如 frontmatter, 代码块、列表、表格等,其中 frontmatter 的内容不用做任何翻译,只需要原样返回即可
|
|
40
42
|
|
|
41
43
|
## 策略
|
|
42
44
|
分四步进行翻译工作:
|
|
@@ -172,20 +174,21 @@ export const translateCommand = new Command('translate')
|
|
|
172
174
|
targetBase: path.dirname(targetFilePath),
|
|
173
175
|
translating: { source, target, copy },
|
|
174
176
|
};
|
|
177
|
+
const normalizedSourceContent = processor.stringify({
|
|
178
|
+
...ast,
|
|
179
|
+
children: ast.children.map((it) => normalizeImgSrc(it, normalizeImgSrcOptions)),
|
|
180
|
+
});
|
|
175
181
|
targetContent = await translate({
|
|
176
182
|
...config.translate,
|
|
177
183
|
source,
|
|
178
|
-
sourceContent:
|
|
179
|
-
...ast,
|
|
180
|
-
children: ast.children.map((it) => normalizeImgSrc(it, normalizeImgSrcOptions)),
|
|
181
|
-
}),
|
|
184
|
+
sourceContent: normalizedSourceContent,
|
|
182
185
|
target,
|
|
183
186
|
targetContent: force ? '' : targetContent,
|
|
184
187
|
additionalPrompts: targetFrontmatter?.i18n?.additionalPrompts ??
|
|
185
188
|
sourceFrontmatter.i18n?.additionalPrompts,
|
|
186
189
|
});
|
|
187
190
|
const { data, content } = matter(targetContent);
|
|
188
|
-
const newFrontmatter = {
|
|
191
|
+
const newFrontmatter = merge({}, sourceFrontmatter, targetFrontmatter, data);
|
|
189
192
|
newFrontmatter.sourceSHA = sourceSHA;
|
|
190
193
|
if (sourceFrontmatter.i18n?.title?.[target]) {
|
|
191
194
|
newFrontmatter.title = sourceFrontmatter.i18n.title[target];
|
package/package.json
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alauda/doom",
|
|
3
|
-
"version": "0.16.1
|
|
3
|
+
"version": "0.16.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Doctor Doom making docs.",
|
|
6
|
-
"repository":
|
|
7
|
-
"type": "git",
|
|
8
|
-
"url": "git+https://gitlab-ce.alauda.cn/idp/Doom.git"
|
|
9
|
-
},
|
|
6
|
+
"repository": "https://gitlab-ce.alauda.cn/idp/Doom.git",
|
|
10
7
|
"packageManager": "yarn@4.7.0",
|
|
11
8
|
"engines": {
|
|
12
9
|
"node": ">=18.17.0 <20 || >=20.1.0"
|
|
@@ -47,7 +44,7 @@
|
|
|
47
44
|
"@openapi-contrib/openapi-schema-to-json-schema": "^5.1.0",
|
|
48
45
|
"@playwright/browser-chromium": "^1.51.1",
|
|
49
46
|
"@rsbuild/plugin-yaml": "^1.0.2",
|
|
50
|
-
"@rspress/core": "1.43.
|
|
47
|
+
"@rspress/core": "1.43.9",
|
|
51
48
|
"@shikijs/transformers": "^3.2.1",
|
|
52
49
|
"chokidar": "^4.0.3",
|
|
53
50
|
"cli-progress": "^3.12.0",
|
|
@@ -73,7 +70,7 @@
|
|
|
73
70
|
"simple-git": "^3.27.0",
|
|
74
71
|
"swagger2openapi": "^7.0.8",
|
|
75
72
|
"tinyglobby": "^0.2.12",
|
|
76
|
-
"type-fest": "^4.
|
|
73
|
+
"type-fest": "^4.38.0",
|
|
77
74
|
"yaml": "^2.7.0",
|
|
78
75
|
"yoctocolors": "^2.1.1"
|
|
79
76
|
},
|
|
@@ -83,9 +80,9 @@
|
|
|
83
80
|
"@swc/core": "1.11.13",
|
|
84
81
|
"@types/cli-progress": "^3.11.6",
|
|
85
82
|
"@types/ejs": "^3.1.5",
|
|
86
|
-
"@types/node": "^18.19.
|
|
83
|
+
"@types/node": "^18.19.83",
|
|
87
84
|
"@types/picomatch": "^3.0.2",
|
|
88
|
-
"@types/react": "^18.3.
|
|
85
|
+
"@types/react": "^18.3.20",
|
|
89
86
|
"@types/react-dom": "^18.3.5",
|
|
90
87
|
"@types/swagger2openapi": "^7.0.4",
|
|
91
88
|
"@unts/patch-package": "^8.1.1",
|