Repository navigation
Translate the book before download, Russian first (1.5.0) - #4
Merged
Merged
Conversation
The main user downloads works that are not in Russian and wants to read them in Russian. Translation runs after the chapters are fetched and before the file is written, so every format gets it: chapter titles, text and end notes, the book title and summary; the language becomes the target. The panel gets a Translate row (off by default, thirteen languages, remembered in storage) and, when on, a line saying chapter text goes to Google Translate; with it off nothing is sent beyond the site itself. The engine is Google's translate_a/t with format=html, which keeps inline markup, behind a small Translator interface. Requests are batched under a character budget, paced, retried on 429/5xx with Retry-After, and abortable; whatever comes back is sanitised again. Whether the book is already in the target language is decided by the language Google reports for the first chapter body with enough text, not by the ru/en guess, so a Ukrainian work with Russian selected is translated. A chapter Google keeps refusing stays in the original and the book is still built, with a note saying how many. Closes #3. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Optional translation of the whole book before download — Russian first, a dozen other languages — so a work that is not in your language arrives in it.
What changes
languagebecomes the target, and the filename uses the translated title.chrome.storage.sync. When translation is on, a line says chapter text goes to Google Translate. With it off, nothing is sent beyond the site itself.translate_a/twithformat=html, which keeps inline markup, behind a smallTranslatorinterface so other engines can be added.Retry-After), and abortable.Checked
npm run check: typecheck, build, and 26 + 19 + 35 tests. The new tests cover markup preservation, batching, retry, abort, the language vote, partial failure, and an EPUB built from a translated book.dc:languageru,em/strong/brcounts identical to the original, and every part parses.🤖 Generated with Claude Code