[PR #6688] [MERGED] fix(narration): strip internal vn tags from translation source and ha… #7286

Closed
opened 2026-10-23 04:18:17 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/6688
Author: @menemorofaan
Created: 9/25/2026
Status: ✅ Merged
Merged: 9/26/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/vn-dialogue-translation-tags


📝 Commits (6)

  • beae328 fix(narration): strip internal vn tags from translation source and harden dialogue parser
  • 7f14ea4 Merge branch 'staging' into fix/vn-dialogue-translation-tags
  • 63e65b4 fix(narration): isolate inline readable placeholders with newlines
  • 1030dbe Merge branch 'staging' into fix/vn-dialogue-translation-tags
  • 07dd518 Merge branch 'staging' into fix/vn-dialogue-translation-tags
  • 087543b test(game): cover translated dialogue tags and inline readables

📊 Changes

3 files changed (+84 additions, -29 deletions)

View changed files

📝 CHANGELOG.md (+2 -0)
📝 e2e/game-translation-edits.e2e.ts (+67 -0)
📝 packages/client/src/components/game/GameNarration.tsx (+15 -29)

📄 Description

Linked issue

Closes #6687

Why this change

Follow-up to #6615 / #6618. In Game mode, unedited GM messages bypass getGameTranslationSource segment reassembly and pass raw markup like [The Unnamed] [main] [patient]: "..." directly to external translators.

Translators often translate or alter these internal channel and sprite tokens (e.g. [главный] [пациент]). Upon receiving the translated text:

  1. partyLineRegex rejects the line because translated channel tokens no longer match the English keywords (main, side, etc.).
  2. Both instances of compactDialogueRegex reject lines having 3 bracketed tokens before the colon (they only supported up to 2 brackets).
  3. As a joint consequence, both dialogue regex paths miss, dropping the dialogue line into narration fallback. It gets merged into the preceding narration segment, collapsing segment counts and shifting all subsequent segment indices.

What changed

  • packages/client/src/components/game/GameNarration.tsx:
    • getGameTranslationSource(): Gated the early plainSource() return to non-GM messages (if (!isGmMessage && !hasGameSegmentOverrides(...))). Clean segment reassembly now runs consistently for all GM messages, ensuring dialogue lines are stripped of internal channel and sprite tags before translation, emitting strictly [${withEdit.speaker}]: ${dialogueBody} (where dialogueBody handles its own quote wrapping).
    • parseNarrationSegments(): Hardened both duplicated definitions of compactDialogueRegex (lines ~6592 and ~6768) to tolerate arbitrary bracketed tokens before the colon while preserving the 3 capture groups (dialogueMatch[1] speaker, dialogueMatch[2] expression/sprite, dialogueMatch[3] dialogue text) required by downstream logic. This prevents multi-bracketed translated dialogue lines from dropping into fallback narration.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) — N/A for translation regex and reassembly
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

  1. Production client build and pnpm check completed with 0 errors.
  2. Verified in real browser with live, unedited assistant messages containing multi-bracket VN dialogue ([Speaker] [main] [emotion]: "..."):
    • Confirmed that translated output no longer contains translated channel/sprite tags.
    • Confirmed that dialogue lines are parsed as distinct dialogue segments and never merge into preceding narration.
    • Confirmed 1:1 segment index alignment across all paragraphs in the message.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

UI evidence (if applicable)

No UI layout changes — internal translation source sanitization and regex parsing resilience.

Summary by CodeRabbit

  • Bug Fixes
    • Translations now stay aligned when speaker labels change and preserve notes or books embedded in narration.
    • Dialogue with additional bracketed labels between the speaker and text is now parsed correctly, including when detecting interrupted dialogue.
    • Rebuilt assistant, narrator, and system dialogue now follows a consistent format without party-type, whisper-target, or sprite labels.
    • User dialogue uses its original text when no segment edits or deletions have been made; otherwise, the translation reflects the edited segments.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/6688 **Author:** [@menemorofaan](https://github.com/menemorofaan) **Created:** 9/25/2026 **Status:** ✅ Merged **Merged:** 9/26/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/vn-dialogue-translation-tags` --- ### 📝 Commits (6) - [`beae328`](https://github.com/Pasta-Devs/Marinara-Engine/commit/beae3282113726be05deddd373403d66df973f8a) fix(narration): strip internal vn tags from translation source and harden dialogue parser - [`7f14ea4`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7f14ea4838e447113e4eef411b2b261eb54830c3) Merge branch 'staging' into fix/vn-dialogue-translation-tags - [`63e65b4`](https://github.com/Pasta-Devs/Marinara-Engine/commit/63e65b46f1b6a656344a0112e11affa04b8cf227) fix(narration): isolate inline readable placeholders with newlines - [`1030dbe`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1030dbeef464b63579c18e077e3e4cb456c7d72e) Merge branch 'staging' into fix/vn-dialogue-translation-tags - [`07dd518`](https://github.com/Pasta-Devs/Marinara-Engine/commit/07dd5185f7c8c7115af3ddd95db4076a441fee60) Merge branch 'staging' into fix/vn-dialogue-translation-tags - [`087543b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/087543be5e81811d8aac9702982f687f2ba3e196) test(game): cover translated dialogue tags and inline readables ### 📊 Changes **3 files changed** (+84 additions, -29 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -0) 📝 `e2e/game-translation-edits.e2e.ts` (+67 -0) 📝 `packages/client/src/components/game/GameNarration.tsx` (+15 -29) </details> ### 📄 Description ## Linked issue Closes #6687 ## Why this change Follow-up to #6615 / #6618. In Game mode, unedited GM messages bypass `getGameTranslationSource` segment reassembly and pass raw markup like `[The Unnamed] [main] [patient]: "..."` directly to external translators. Translators often translate or alter these internal channel and sprite tokens (e.g. `[главный] [пациент]`). Upon receiving the translated text: 1. `partyLineRegex` rejects the line because translated channel tokens no longer match the English keywords (`main`, `side`, etc.). 2. Both instances of `compactDialogueRegex` reject lines having 3 bracketed tokens before the colon (they only supported up to 2 brackets). 3. As a joint consequence, both dialogue regex paths miss, dropping the dialogue line into narration fallback. It gets merged into the preceding narration segment, collapsing segment counts and shifting all subsequent segment indices. ## What changed - `packages/client/src/components/game/GameNarration.tsx`: - `getGameTranslationSource()`: Gated the early `plainSource()` return to non-GM messages (`if (!isGmMessage && !hasGameSegmentOverrides(...))`). Clean segment reassembly now runs consistently for all GM messages, ensuring dialogue lines are stripped of internal channel and sprite tags before translation, emitting strictly `[${withEdit.speaker}]: ${dialogueBody}` (where `dialogueBody` handles its own quote wrapping). - `parseNarrationSegments()`: Hardened both duplicated definitions of `compactDialogueRegex` (lines ~6592 and ~6768) to tolerate arbitrary bracketed tokens before the colon while preserving the 3 capture groups (`dialogueMatch[1]` speaker, `dialogueMatch[2]` expression/sprite, `dialogueMatch[3]` dialogue text) required by downstream logic. This prevents multi-bracketed translated dialogue lines from dropping into fallback narration. ## Validation - [x] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [x] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) — N/A for translation regex and reassembly - [x] Above manual verification completed (describe below) - [x] Read and followed `CONTRIBUTING.md` ### Manual verification notes 1. Production client build and `pnpm check` completed with 0 errors. 2. Verified in real browser with live, unedited assistant messages containing multi-bracket VN dialogue (`[Speaker] [main] [emotion]: "..."`): - Confirmed that translated output no longer contains translated channel/sprite tags. - Confirmed that dialogue lines are parsed as distinct dialogue segments and never merge into preceding narration. - Confirmed 1:1 segment index alignment across all paragraphs in the message. ## Docs and release impact - [x] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) No UI layout changes — internal translation source sanitization and regex parsing resilience. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Translations now stay aligned when speaker labels change and preserve notes or books embedded in narration. * Dialogue with additional bracketed labels between the speaker and text is now parsed correctly, including when detecting interrupted dialogue. * Rebuilt assistant, narrator, and system dialogue now follows a consistent format without party-type, whisper-target, or sprite labels. * User dialogue uses its original text when no segment edits or deletions have been made; otherwise, the translation reflects the edited segments. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:18:17 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#7286
No description provided.