Skip to content

Commit 98a4962

Browse files
committed
feat: update openai prompt
1 parent 90df451 commit 98a4962

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

packages/translate/src/openai.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ async function translateChunk(
6767
'description: React \\`useState\\` 钩子的使用示例',
6868
"description: 缓存功能 'use cache' 的 API 设计和优势",
6969
'description: 组件 "Button" 的使用指南',
70+
'title: Next.js 安全性思考原则',
71+
'title: Next.js 中的安全最佳实践',
7072
],
7173
incorrect: [
7274
'title: \\`public\\` 目录中的静态资源',
@@ -75,6 +77,8 @@ async function translateChunk(
7577
'description: \\`useState\\` 钩子的使用示例',
7678
"description: 'use cache' 的 API 设计和优势",
7779
'description: "Button" 组件的使用指南',
80+
'title: Next.js 安全性:核心概念',
81+
'title: 如何思考 Next.js:安全指南',
7882
],
7983
},
8084
'zh-hant': {
@@ -121,6 +125,8 @@ async function translateChunk(
121125
'description: Примеры использования хука \\`useState\\` в React',
122126
"description: Функциональность кэша 'use cache' и её преимущества API",
123127
'description: Руководство по использованию компонента "Button"',
128+
'title: Принципы безопасности в Next.js',
129+
'title: Безопасность Next.js и лучшие практики',
124130
],
125131
incorrect: [
126132
'title: \\`public\\` директория статических ресурсов',
@@ -129,6 +135,8 @@ async function translateChunk(
129135
'description: \\`useState\\` примеры использования хука',
130136
"description: 'use cache' функциональность и преимущества API",
131137
'description: "Button" руководство по использованию компонента',
138+
'title: Безопасность в Next.js: основные принципы',
139+
'title: Next.js: руководство по безопасности',
132140
],
133141
},
134142
de: {
@@ -214,10 +222,12 @@ async function translateChunk(
214222
• NEVER start a frontmatter value with inline code (text between \`backticks\`)
215223
• NEVER start a frontmatter value with single quotes ('text')
216224
• NEVER start a frontmatter value with double quotes ("text")
225+
• NEVER use colon (:) character in frontmatter values as it conflicts with YAML syntax
217226
• This applies to ALL inline code including \`<Component>\` tags, \`functions\`, variables, etc.
218227
• This applies to ALL quoted text including 'use cache', "API design", 'components', etc.
219228
• In frontmatter (sections between --- marks), ALWAYS rearrange sentences so inline code and quoted text appears AFTER some text
220229
• If a frontmatter value would start with inline code or quotes after translation, ALWAYS rewrite the sentence so that some descriptive text comes before the inline code or quotes. For example, instead of ${langExamples.incorrect[0]}, use ${langExamples.correct[0]}.
230+
• If a translation would include a colon (:), ALWAYS rephrase to avoid it (e.g., "Security in Next.js: principles" becomes "Security principles in Next.js" or "Next.js security principles")
221231
• This rule applies to ALL frontmatter keys (title, description, etc.), not just description.
222232
• ALWAYS preserve both the opening and closing frontmatter delimiters (---) - never omit the closing delimiter
223233
• Maintain the exact structure of frontmatter - beginning with ---, followed by key-value pairs, and ending with ---
@@ -244,7 +254,7 @@ ${langExamples.correct.map((ex) => ` ${ex}`).join('\n')}
244254
---
245255
246256
These rules apply ONLY to frontmatter (between --- marks) and are CRITICAL for proper document rendering.
247-
REMEMBER: You must NEVER start with inline code in frontmatter values and ALWAYS include both opening and closing --- delimiters.`;
257+
REMEMBER: You must NEVER start with inline code in frontmatter values, NEVER use colons (:) in frontmatter values, and ALWAYS include both opening and closing --- delimiters.`;
248258

249259
const prompt = `
250260
${context}

0 commit comments

Comments
 (0)