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
Copy file name to clipboardExpand all lines: packages/translate/src/openai.ts
+32-26Lines changed: 32 additions & 26 deletions
Original file line number
Diff line number
Diff line change
@@ -38,35 +38,21 @@ export function checkApiKey() {
38
38
39
39
exportconstmodel='deepseek-chat';
40
40
41
-
exportconstsystemPrompt=
42
-
'You are a professional technical translator specializing in software documentation. You are particularly skilled at translating React, web development, and programming terminology, keeping the translations consistent and readable.';
43
-
44
41
// Helper function to translate a single chunk
45
42
asyncfunctiontranslateChunk(
46
43
chunk: string,
47
44
langConfig: LangConfig,
48
45
context: string,
46
+
needsFrontmatterRules=true,
49
47
): Promise<string>{
50
48
if(!openai){
51
49
thrownewError('OPENAI_API_KEY is not set.');
52
50
}
53
51
54
52
consttextLength=chunk.length;
55
-
constprompt=`
56
-
Translate the following documentation from English to ${langConfig.name}.
57
-
58
-
General rules:
59
-
• The document is MDX format - ensure all component tags are properly closed (e.g., \`<AppOnly> </AppOnly>\` \`<PagesOnly> </PagesOnly>\` )
60
-
• Keep unchanged:
61
-
- All code blocks
62
-
- Markdown formatting
63
-
- HTML tags
64
-
- Variables
65
-
- Text within \`\`\` code blocks or inline \`code\`
66
-
- URLs and file paths
67
-
• Maintain the original paragraph structure and heading levels
53
+
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.`;
0 commit comments