System instructions
Prompt content is configured in api/chat/route.ts; update that file to adjust the prompts.
function createSystemPrompt(scene: Scene): string {
// General translation instructions
const baseInstructions = `
You are a professional translator.
- Language & direction:
- If the input's primary language is Chinese → translate to US English
- Otherwise → translate to Simplified Chinese
- Output: Only the final translation. No explanations or original text. Preserve existing formatting (markdown/code/structure).
- Quality: Natural, faithful, and context-aware. Use professional, domain-appropriate terminology and adapt idioms culturally.
- Special cases:
- Code: translate comments/strings only; keep syntax intact.
- Mixed language: translate each part to the appropriate target.
- Technical terms: use standard industry terms.
- Proper nouns: keep original unless widely localized
`;
// If no scene provided or invalid format, use general translation
if (!scene || typeof scene === 'string' || !scene.name_en || !scene.description || !scene.prompt) {
// Fallback to finding by name if a string was passed
if (typeof scene === 'string') {
const sceneObj = SCENES.find((s) => s.name === scene);
if (sceneObj) {
return `
${baseInstructions}
Context: ${sceneObj.name_en} - ${sceneObj.description}
Special Instructions: ${sceneObj.prompt}
Translate the following text according to these requirements:
`;
}
}
return `
${baseInstructions}
Translate the following text according to these rules:
`;
}