Skip to content

Add chapter context translation mode#830

Open
DygDyg wants to merge 1 commit into
mayocream:mainfrom
DygDyg:feature/chapter-context-translation
Open

Add chapter context translation mode#830
DygDyg wants to merge 1 commit into
mayocream:mainfrom
DygDyg:feature/chapter-context-translation

Conversation

@DygDyg

@DygDyg DygDyg commented Jun 28, 2026

Copy link
Copy Markdown

Summary

This PR adds an optional Chapter Context Translation mode for LLM-based translation.

Instead of translating each page independently, Koharu can now process translation using shared chapter-level context.

Pipeline flow in chapter mode:

  1. Detection across selected pages
  2. OCR across selected pages
  3. Collect OCR blocks with stable block IDs
  4. Chunk blocks into token-limited LLM requests
  5. Translate with validation + retry/fallback
  6. Apply translations back to original nodes
  7. Continue inpainting and rendering

The default page-by-page translation workflow remains unchanged.


Features

Chapter Context Translation

  • Added optional chapter-wide translation mode
  • Stable block IDs (P001-B001, etc.)
  • Translation preserves reading order across pages

Chunking

  • Token-based chunking
  • Configurable token budget
  • Configurable max blocks per chunk

Reliability Improvements

  • Output validation for missing/extra blocks
  • Detection of repetitive malformed output
  • Retry with stricter prompt
  • Single-block fallback for failed chunks
  • All-or-nothing apply preserved

UI

  • Settings toggle for Chapter Context Translation
  • Advanced chunk configuration
  • Progress bubble hint when enabled
  • OCR overlay background customization (RGBA)

Localization

  • Added Russian localization for new UI strings

Notes

  • Standard translation mode is unchanged.
  • Chapter context mode only applies to full pipeline runs.
  • Per-page translation and single-block translation still use the original path.

Tested with:

  • Local LLM providers
  • OpenAI-compatible providers
  • Chapter translation chunk validation
  • UI settings and pipeline hint behavior

@github-actions

Copy link
Copy Markdown

Thanks for your first PR to Koharu.

Please review our contribution guide before review:
https://koharu.rs/contribute/introduction/

In the PR description, include:

  • what changed
  • any user-visible behavior differences
  • how you verified the change

If AI helped produce the patch, a human still needs to review and understand it before submission.

@DygDyg

DygDyg commented Jun 28, 2026

Copy link
Copy Markdown
Author

Notes for maintainer

This PR became larger than initially planned because several related improvements were needed for stable chapter-context translation.

If preferred, I can split this into multiple smaller PRs:

  • core chapter translation
  • UI improvements
  • Windows CUDA build fixes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant