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
*(applies only when ${targetLanguage} = Japanese)*
233
259
- Insert a half‑width space before and after all alphanumeric terms.
234
-
- Add a half‑width space just outside markdown emphasis markers: \` **太字** \` (good) vs \`** 太字 **\` (bad).
260
+
- Add a half‑width space just outside markdown emphasis markers: \` **bold** \` (good) vs \`** bold **\` (bad).
235
261
236
262
#########################
237
263
## DO NOT TRANSLATE ##
@@ -251,6 +277,15 @@ ${specificTerms}
251
277
${specificInstructions}
252
278
- When translating Markdown tables, preserve the exact table structure, including all delimiters (|), header separators (---), and row/column counts. Only translate the cell contents. Do not add, remove, or reorder columns or rows.
253
279
280
+
#########################
281
+
## VALIDATION STEPS ##
282
+
#########################
283
+
Before returning the final title, run this mental checklist and fix issues if any:
284
+
- No occurrences of: \`**\\s+[^*]*\\s+**\`, \`__\\s+[^_]*\\s+__\`.
285
+
- No heading without a space: lines starting with \`#{1,6}\` must be followed by a space.
286
+
- No list marker without a space: lines starting with \`-\`, \`+\`, or a single \`*\` must be followed by a space.
287
+
- No spaces just inside \`[ ... ]\` or \`![ ... ]\` labels.
288
+
254
289
#########################
255
290
## IF UNSURE ##
256
291
#########################
@@ -324,12 +359,33 @@ You must return **only** the translated markdown. Do not include any commentary,
324
359
- Link URLs inside \`[label](URL)\` – translate the label, never the URL.
325
360
- The internal links like [{label here}](path here) must be kept as-is.
326
361
362
+
#########################
363
+
## HARD CONSTRAINTS ##
364
+
#########################
365
+
- Never insert spaces immediately inside emphasis markers. Use \`**bold**\`, not \`** bold **\`.
366
+
- Preserve the number of emphasis markers from the source: if the source uses \`**\` or \`__\`, keep the same pair count.
367
+
- Ensure one space after heading markers: \`##Heading\` -> \`## Heading\`.
368
+
- Ensure one space after list markers: \`-Item\` -> \`- Item\`, \`*Item\` -> \`* Item\` (does not apply to \`**\`).
*(applies only when ${targetLanguage} = Japanese)*
331
387
- Insert a half‑width space before and after all alphanumeric terms.
332
-
- Add a half‑width space just outside markdown emphasis markers: \` **太字** \` (good) vs \`** 太字 **\` (bad). Review this rule again before returning the translated text.
388
+
- Add a half‑width space just outside markdown emphasis markers: \` **bold** \` (good) vs \`** bold **\` (bad). Review this rule again before returning the translated text.
333
389
334
390
#########################
335
391
## DO NOT TRANSLATE ##
@@ -373,6 +429,11 @@ Follow the following workflow to translate the given markdown text data:
373
429
- any errors or rooms for improvements in terms of Markdown text format -- A common error is to have spaces within special syntax like * or _. You must have spaces after special syntax like * or _, but it's NOT the same for the parts inside special syntax (e.g., ** bold ** must be **bold**)
374
430
- you should not have any unnecessary spaces outside of tags; especially for the ones you replace with the "TERM-SPECIFIC" list
375
431
- any parts that are not compatible with *.mdx files -- In the past, you've generated an expression with acorn like {#title-here} in h2 (##) level but it was neither necessary nor valid
432
+
- Run a final regex check in your head and fix if any of these patterns appear in your output:
433
+
- \`**\\s+[^*]*\\s+**\` or \`__\\s+[^_]*\\s+__\` (spaces inside emphasis)
434
+
- Lines starting with \`#{1,6}\` not followed by a space
435
+
- Lines starting with \`-\`, \`+\`, or a single \`*\` not followed by a space
436
+
- Avoid spaces directly inside link or image labels: use \`[Label](url)\`, not \`[ Label ](url)\` or \`\`.
376
437
4. If improvements are necessary, refine the content without changing the original meaning.
377
438
5. Continue improving the translation until you are fully satisfied with the result.
378
439
6. Once the final output is ready, return **only** the translated markdown text. No extra commentary.
@@ -386,7 +447,13 @@ async function callAgent(
386
447
instructions: string,
387
448
model: string=OPENAI_MODEL,
388
449
): Promise<string>{
389
-
constagent=newAgent({name: 'translator', instructions, model });
0 commit comments