You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -11,6 +11,7 @@ import { type Usage, addUsage } from './usage';
11
11
12
12
interfaceLangConfig{
13
13
name: string;
14
+
locale: string;
14
15
}
15
16
16
17
interfaceTranslateDocumentParams{
@@ -52,87 +53,189 @@ async function translateChunk(
52
53
consttextLength=chunk.length;
53
54
constsystemPrompt=`You are a professional technical translator from English to ${langConfig.name} specializing in software documentation. You are particularly skilled at translating React, web development, and programming terminology, keeping the translations consistent and readable.`;
• NEVER start a frontmatter value with inline code (text between \`backticks\`)
57
183
• This applies to ALL inline code including \`<Component>\` tags, \`functions\`, variables, etc.
58
184
• In frontmatter (sections between --- marks), ALWAYS rearrange sentences so inline code appears AFTER some text
59
-
• If a frontmatter value would start with inline code after translation, ALWAYS rewrite the sentence so that some descriptive text comes before the inline code. For example, instead of \`title: \`public\` 目錄中的靜態資源\`, use \`title: 靜態資源(\`public\` 目錄)\` or \`title: 關於 public 目錄的靜態資源\`.
185
+
• If a frontmatter value would start with inline code after translation, ALWAYS rewrite the sentence so that some descriptive text comes before the inline code. For example, instead of ${langExamples.incorrect[0]}, use ${langExamples.correct[0]}.
60
186
• This rule applies to ALL frontmatter keys (title, description, etc.), not just description.
61
187
• ALWAYS preserve both the opening and closing frontmatter delimiters (---) - never omit the closing delimiter
62
188
• Maintain the exact structure of frontmatter - beginning with ---, followed by key-value pairs, and ending with ---
63
189
• These rules are ABSOLUTELY REQUIRED for proper rendering of the documentation
64
190
65
191
Examples of MDX Frontmatter Translation:
66
192
67
-
# Example 1: Function names
193
+
# Example 1: Never start frontmatter values with inline code
68
194
✓ CORRECT (Always do this):
69
195
Original:
196
+
title: \`public\` directory static assets
70
197
description: API reference for \`getStaticProps\`. Learn how to use \`getStaticProps\`.
71
-
Translation:
72
-
description: API \`getStaticProps\` 参考文档。了解如何使用 \`getStaticProps\`。
73
-
74
-
✗ INCORRECT (Never do this):
75
-
Original:
76
-
description: API reference for \`getStaticProps\`. Learn how to use \`getStaticProps\`.
77
-
Translation:
78
-
description: \`getStaticProps\` API 参考文档。了解如何使用 \`getStaticProps\`。
79
-
80
-
# Example 2: HTML/Component tags
81
-
✓ CORRECT (Always do this):
82
-
Original:
83
198
description: API reference for the \`<Link>\` component.
# Example 2: Frontmatter Structure - always include closing delimiter
94
213
✓ CORRECT (Always do this):
95
214
Original:
96
215
---
97
-
title: Link
98
-
description: API reference for the \`<Link>\` component.
216
+
title: \`public\` directory static assets
99
217
---
100
218
Translation:
101
219
---
102
-
title: Link
103
-
description: 关于 \`<Link>\` 组件的 API 参考文档。
220
+
${langExamples.correct[0]}
104
221
---
105
222
106
223
✗ INCORRECT (Never do this):
107
224
Original:
108
225
---
109
-
title: Link
110
-
description: API reference for the \`<Link>\` component.
226
+
title: \`public\` directory static assets
111
227
---
112
228
Translation:
113
229
---
114
-
title: Link
115
-
description: 关于 \`<Link>\` 组件的 API 参考文档。
230
+
${langExamples.correct[0]}
116
231
(missing closing delimiter)
117
232
118
-
# Example 4: Do NOT start with inline code in any frontmatter key
119
-
✓ CORRECT (Always do this):
120
-
Original:
121
-
title: \`public\` directory static assets
122
-
Translation:
123
-
title: 靜態資源(public 目錄)
124
-
title: 關於 public 目錄的靜態資源
125
-
126
-
✗ INCORRECT (Never do this):
127
-
Original:
128
-
title: \`public\` directory static assets
129
-
Translation:
130
-
title: \`public\` 目錄中的靜態資源
131
-
132
233
These rules apply ONLY to frontmatter (between --- marks) and are CRITICAL for proper document rendering.
133
234
REMEMBER: You must NEVER start with inline code in frontmatter values and ALWAYS include both opening and closing --- delimiters.`;
134
235
135
236
constprompt=`
237
+
${context}
238
+
136
239
Please read the following rules carefully:
137
240
138
241
General rules:
@@ -153,8 +256,6 @@ Output format:
153
256
• No introduction, prefixes, or meta-explanations
154
257
• Just the translation itself
155
258
156
-
${context}
157
-
158
259
⚠️ IMPORTANT: The next message contains the COMPLETE original text that needs to be translated. Please translate the ENTIRE content without omitting any parts, sections, or formatting elements. Preserve all whitespace, line breaks, and structural formatting exactly as they appear in the original, PLEASE TRANSLATE IT TO ${langConfig.name}:
0 commit comments