ePubLangMerger¶
ePubLangMerger takes two ePub files of the same book in two languages and makes one ePub in which every paragraph and heading of the second language comes right after the matching one in the first. Reading a translation next to the original otherwise means two books open at once and finding your place twice on every page, and bilingual editions exist for few books. It is a small web page that runs in Docker, plus a script for batch runs. Start with Getting started, then Usage.
-
Start the container with the shipped compose file, or run the app from R without Docker.
-
Upload the two ePubs, the language you want first as the first file, click Go! and download the merged book.
-
script.Rmerges a pair without the web page, for scripts and many books in a row. -
Why pairs drift apart, what is not merged, and what to put in a bug report.
What it does¶
- Puts each
<p>and<h1>to<h5>of the second language right after the element in the same position in the first language, chapter by chapter. - Keeps the rest of the first ePub as it is: its images, styles, table of contents and metadata.
- Adds
_2to everyidit copies from the second ePub, so the copies do not repeat the ids of the first language. - Names the result from the two file names:
MyBook_EN.epubandMyBook_ES.epubgiveMyBook_EN_ES.epub. See the filename convention. - Merging the same pair again in the same browser session returns the first result without redoing the work.
How it runs¶
- One container,
drumsergio/epublangmerger, pinned to a release tag in the shippeddocker-compose.yml, built forlinux/amd64only. It serves the page on port 3838 with Shiny Server. - Without Docker: R 4.x with the
shiny,XML,stringrandRcompressionpackages, on the port you choose. See Getting started. - A merge unpacks both books, edits the chapter files of the first and zips the result. How it works has the four steps.
What it does not do¶
- It does not match paragraphs by meaning. It pairs them by position, so two editions that split paragraphs differently drift apart. See Troubleshooting.
- Text outside
<p>and<h1>to<h5>elements, such as list items and table cells, stays in the first language only. - It reads chapters only from the
OEBPS/folder, and only files whose names end in.xhtml. - It does not change the book's title or language in its metadata: a reader shows those of the first ePub.
- It accepts files of up to 50 MB each, and it has no login: anyone who can reach port 3838 can use it.
Privacy¶
- The books stay on the machine that runs the app. It makes no network requests of its own.
- The unpacked books and the merged file sit in a temporary folder for your browser session and are deleted when the session ends.
Getting help¶
- Something broken: read Troubleshooting, then open an issue with the details it lists.
- A security problem: follow the security policy, never a public issue.
- What changed between versions: the releases on GitHub.
- Running the tests, building the image and releasing: Development.
- Other ePub tools: AskePub, a Telegram bot that annotates ePubs with GPT-4, and epub-and-vtt-to-llm, which fine-tunes LLMs on ePub and subtitle text.
License¶
ePubLangMerger is released under the GPL-3.0-or-later license. It is built on Shiny and the XML package.