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
"""Use AI to intelligently position translated content in the target file"""
281
-
282
-
prompt=f"""You are an expert documentation editor. Your task is to intelligently merge new translated content into an existing documentation file.
288
+
289
+
iftranslated_content.strip():
290
+
new_content_section=f"""- New translated content to be inserted:
291
+
```
292
+
{translated_content}
293
+
```"""
294
+
else:
295
+
new_content_section= (
296
+
"- New translated content to be inserted: (NONE — this change ONLY "
297
+
"REMOVES content).\n"
298
+
" IMPORTANT: This is a deletion-only change. You must return the "
299
+
"current target file EXACTLY as it is, changing NOTHING except the "
300
+
"removal of the parts that correspond to the lines deleted in the "
301
+
"git diff. Do NOT translate, re-translate, rephrase, reformat, "
302
+
"reorder or otherwise touch any other part of the file. Every line "
303
+
"that is not the one being removed must remain byte-for-byte "
304
+
"identical to the current target file content shown above."
305
+
)
306
+
307
+
prompt=f"""You are an expert documentation editor. Your task is to intelligently merge the changes shown in a git diff into an existing translated documentation file.
283
308
284
309
CONTEXT:
285
-
- Original source file (the file that was modified):
310
+
- Original source file (the file that was modified):
286
311
```
287
312
{original_source_content}
288
313
```
289
314
290
-
- Current target file content (where the translation should be inserted):
315
+
- Current target file content (where the change should be applied):
Analyze the changes shown in the git diff and intelligently insert the translated content into the appropriate position in the current target file.
328
+
Analyze the changes shown in the git diff and apply the equivalent change to the current target file. Changes may ADD, MODIFY, or REMOVE content.
307
329
308
330
RULES:
309
-
1. **Understand the context**: Look at where the changes were made in the source file
331
+
1. **Understand the context**: Look at where the changes were made in the source file (lines starting with '+' were added, lines starting with '-' were removed)
310
332
2. **Find the equivalent position**: Locate the corresponding section in the target file
311
-
3. **Insert appropriately**:
333
+
3. **Insert appropriately**:
312
334
- If it's a NEW section/content: Insert it in the same relative position
313
335
- If it's a MODIFICATION: Replace the existing content with the new translation
314
336
- If it's an ADDITION to existing section: Add it in the correct place within that section
315
-
4. **Preserve structure**: Maintain the overall document structure and hierarchy
316
-
5. **Keep formatting**: Preserve all markdown formatting, spacing, and line breaks
337
+
4. **Avoid duplication (CRITICAL)**: Before inserting anything, check whether that content — or its equivalent already-translated version — is ALREADY present in the current target file. If it is, do NOT add it again: leave that part of the file unchanged. The result must be IDEMPOTENT — if the change was already applied in a previous run, re-applying it must produce no further changes. Never create a second copy of a sentence, list item, paragraph or section that already exists in the target file.
338
+
5. **Handle deletions**: If the git diff shows removed lines (starting with '-' with no '+' counterpart), locate the sentence, paragraph or list item in the target file that corresponds to the removed source text and REMOVE only that part. Do NOT translate or re-insert the removed text. Everything else in the file must stay untouched — do NOT translate, re-translate, rephrase or reformat any surrounding content; leave it exactly as it currently is.
339
+
6. **Preserve structure**: Maintain the overall document structure and hierarchy. Do not add, remove or reword any content other than what the git diff indicates. Any content not affected by the diff must remain identical to the current target file, character for character.
340
+
7. **Keep formatting**: Preserve all markdown formatting, spacing, and line breaks
317
341
318
342
OUTPUT FORMAT:
319
343
Return the COMPLETE updated target file content with the translated content properly positioned.
0 commit comments