Last updated: 2026-04-13
A tweet recently went viral among developers. @cat88tw shared their attempt to build an EPUB translator using Claude Code and described, in blunt terms, just how much harder it was than expected. The tweet hit 1,671 views -- not because the idea was unusual, but because every developer who's tried the same thing nodded along in recognition.
The pitch sounds simple. EPUBs are just HTML and CSS zipped into a file. Modern AI models can translate text beautifully. So you wire the two together, and you're done in a weekend.
Except you're not. You're done in a weekend only if you're willing to accept broken formatting, garbled chapters, missing images, and translations that fall apart the moment you try to open the file on a Kindle or Kobo. Building a reliable EPUB translator -- one that handles real-world books, not just toy examples -- is a genuine engineering challenge.
Here's why.
An EPUB file is a ZIP archive containing XHTML files, CSS stylesheets, images, fonts, metadata, and a navigation system. The standard (EPUB 2 and EPUB 3) defines how these pieces fit together, but publishers interpret the standard loosely. Very loosely.
Some books split content into one file per chapter. Others put everything in a single monolithic XHTML file. Some use nested <div> structures for sections. Others use <section> tags, or <article> tags, or no semantic markup at all. The table of contents might be an NCX file (EPUB 2), a Navigation Document (EPUB 3), or both. Some books have inline CSS. Others reference external stylesheets. Some embed fonts. Others rely on the reader's system fonts.
Your translator needs to handle all of these variations correctly. The moment you make assumptions about structure -- "chapters are always separate files" or "CSS is always external" -- you'll encounter a real book that breaks your parser.
The OPF manifest file lists every resource in the book and the reading order. If your translator adds, removes, or renames files without updating the manifest, the EPUB becomes invalid. Most e-reader apps will refuse to open it or display it incorrectly.
This is where most DIY projects die. Translating the text is the easy part. Keeping the formatting intact afterward is brutally hard.
Consider a paragraph with mixed formatting:
<p>
The author notes that <em>this particular finding</em> was
<strong>statistically significant</strong> (p < 0.001), as shown in
<a href="chapter3.xhtml#table2">Table 2</a>.
</p>
Your translator needs to:
<) without corrupting itNow multiply this by every formatting pattern in the book: footnotes, superscripts, ruby text annotations, drop caps, pull quotes, epigraphs, poetry with line breaks, mathematical notation, and tables with merged cells. Each one is a special case that your mapping logic needs to handle.
If you naively send the raw HTML to a language model and ask it to translate, the model will frequently mangle the tags, change attribute values, drop closing tags, or rewrite the markup structure entirely. If you strip the HTML first and translate plain text, you lose all formatting and have no way to put it back.
A typical book contains 60,000 to 100,000 words. No current language model can process an entire book in a single API call and return a coherent translation. You have to split the book into chunks.
But splitting introduces its own problems:
Professional translation tools maintain glossaries and context windows that overlap between chunks. Building this correctly requires careful engineering -- not just splitting on paragraph boundaries and hoping for the best.
Translating text changes its length. A 20-word English sentence might become 35 words in German or 12 characters in Chinese. This has cascading effects on layout:
Your translator either needs to adjust CSS properties for the target language or accept that the output will look broken. Neither option is trivial.
If your translator only handles European languages, you might get away with ignoring script-specific issues. The moment you add Chinese, Japanese, Korean, or Arabic support, the complexity doubles.
CJK challenges:
RTL challenges:
Most developers discover these issues only after a user tries to translate a book to or from one of these languages and reports that the output is unreadable.
Generating a valid EPUB that looks correct on every reader app is surprisingly difficult. E-readers are not web browsers -- they each implement a subset of the EPUB standard with their own quirks.
After translation, your output needs to pass EPUB validation (epubcheck) and render correctly on at least the major platforms. Testing across readers is time-consuming and reveals platform-specific bugs that are tedious to fix.
A book is not a single API call. Translating a 300-page book might require 200+ API calls to a language model. Each call can fail -- rate limits, timeouts, malformed responses, content filters, or simply a bad translation.
Your translator needs:
Building reliable infrastructure for hundreds of sequential API calls, with error handling and resumption, is a significant engineering effort on its own.
Every challenge above is solvable. But solving all of them together -- and keeping them solved as EPUB standards evolve, language models change their APIs, and new edge cases appear -- is a full-time job.
This is exactly why EPUBTranslator exists. Instead of spending weeks building and debugging your own pipeline, you upload a file, pick a language, and get back a properly formatted EPUB. The tool handles all the complexity described above: structure parsing, format preservation, chunk management, CSS adjustment, CJK and RTL support, validation, and error recovery.
For developers who enjoy the challenge, building an EPUB translator is a great learning project. You'll gain deep knowledge of the EPUB format, HTML/CSS edge cases, and the practical limits of language model APIs. But if your goal is actually reading a book in another language -- not spending a month debugging edge cases in XHTML parsing -- a purpose-built tool will save you a significant amount of time and frustration.
The developer behind that viral tweet learned this the hard way. You don't have to.
Building an EPUB translator looks simple on the surface: parse some HTML, call a translation API, zip it back up. But the gap between a working prototype and a tool that handles real books reliably is enormous. EPUB structure variation, formatting preservation, context management, script-specific rendering, cross-reader compatibility, and production error handling each add layers of complexity that compound on each other.
If you're a developer who wants to understand these challenges deeply, by all means build one. You'll learn a lot. But if you just want to read a great book that happens to be in another language, use a tool that's already solved these problems. EPUBTranslator handles the hard parts so you can focus on what matters -- actually reading the book.