Skip to content

ePubLangMerger

ePubLangMerger: two languages, one book, side by side

Docker Pulls GitHub Stars Release License: GPL-3.0-or-later


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.

  • Getting started


    Start the container with the shipped compose file, or run the app from R without Docker.

  • Usage


    Upload the two ePubs, the language you want first as the first file, click Go! and download the merged book.

  • Command line


    script.R merges a pair without the web page, for scripts and many books in a row.

  • Troubleshooting


    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 _2 to every id it 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.epub and MyBook_ES.epub give MyBook_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 shipped docker-compose.yml, built for linux/amd64 only. It serves the page on port 3838 with Shiny Server.
  • Without Docker: R 4.x with the shiny, XML, stringr and Rcompression packages, 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

License

ePubLangMerger is released under the GPL-3.0-or-later license. It is built on Shiny and the XML package.