Thanks to visit codestin.com
Credit goes to github.com

Skip to content

This project provides a tool to parse DRM-free ebooks and automatically translate their content using the DeepL API.

License

Notifications You must be signed in to change notification settings

mess/ebook-translator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EBook Translator

A Java application that automatically translates DRM-free EPUB files using DeepL's translation API while preserving the book's structure and formatting.

Demo

⚠️ Important Disclaimers

  1. Copyright Compliance: This application should only be used to translate EPUB files that you legally own or have permission to modify. The authors of this software disclaim any responsibility for misuse or copyright infringement. Always respect intellectual property rights and applicable laws in your jurisdiction.

  2. DRM-Free Only: This tool works exclusively with DRM-free EPUB files. It cannot and will not attempt to remove DRM protection from encrypted ebooks.

What it does

The application:

  • Extracts DRM-free EPUB files and identifies translatable content (HTML/XHTML files)
  • Translates text content using DeepL's powerful neural translation API
  • Preserves the original book structure, formatting, images, and metadata
  • Creates a new translated EPUB file with "_translated" suffix
  • Supports progress tracking and resume functionality for large books

Download & Run

Prerequisites

Download

  1. Go to the Releases page
  2. Download the latest ebook-translator-{version}-all.jar file from the Assets section
  3. Optionally download the .sha256 file to verify the integrity

Run

# Set your DeepL API key (option 1: environment variable)
export DEEPL_API_KEY="your-api-key-here"

# Run the application
java -jar ebook-translator-{version}-all.jar "book.epub" EN IT

# Alternative: Set API key as system property
java -DDEEPL_API_KEY="your-api-key" -jar ebook-translator-{version}-all.jar "book.epub" EN IT

Usage Parameters

java -jar ebook-translator-{version}-all.jar <epub-path> <source-lang> <dest-lang> [api-type] [output-dir]

Required Parameters

  • epub-path: Path to the EPUB file to translate

    • Can be absolute path: /path/to/book.epub
    • Can be relative path: ./books/book.epub
    • Can be filename if in current directory: book.epub
  • source-lang: Source language code (e.g., EN, DE, FR, ES, IT)

  • dest-lang: Destination language code (e.g., IT, ES, FR, DE, EN)

Optional Parameters

  • api-type (default: PRO): DeepL API type

    • PRO: DeepL Pro API (faster, no rate limits)
    • FREE: DeepL Free API (slower, with rate limiting)
  • output-dir: Directory where translated files will be saved

    • Default: Same directory as the input EPUB file
    • Example: /path/to/output/

Examples

# Basic usage (current directory)
java -jar ebook-translator.jar "book.epub" EN IT

# With specific API type
java -jar ebook-translator.jar "book.epub" EN IT FREE

# With custom output directory
java -jar ebook-translator.jar "book.epub" EN IT PRO "/home/user/translated-books/"

# Full path with all parameters
java -jar ebook-translator.jar "/home/user/books/book.epub" EN IT PRO "/home/user/translated/"

Progress Tracking & Resume

The application features intelligent progress tracking that allows you to safely interrupt and resume translations:

How it works

  • Creates a temporary working directory: .ebook-translator-temp/{book-name}/
  • Maintains a progress.xml file tracking which chapters have been translated
  • If interrupted, simply rerun the same command to resume from where it left off
  • Only untranslated chapters will be processed on resume

File Structure

your-epub-directory/
├── book.epub                    # Original file
├── book_translated.epub         # Final translated file (when complete)
└── .ebook-translator-temp/
    └── book/
        ├── progress.xml         # Translation progress tracker
        ├── input/               # Extracted original files
        └── output/              # Translated files

Benefits

  • Resilient: Handles interruptions, network issues, or quota limits gracefully
  • Efficient: Only processes untranslated content on restart
  • Safe: Original files are never modified
  • Clean: Temporary files can be safely deleted after completion

API Configuration

DeepL API Types

FREE API

  • Cost: Free tier with monthly character limit
  • Speed: Slower due to built-in rate limiting (1 request per second)
  • Quota: Limited characters per month
  • URL: Uses api-free.deepl.com
  • Best for: Small books, testing, personal use

PRO API

  • Cost: Paid subscription required
  • Speed: Full speed, no artificial delays
  • Quota: Based on your subscription plan
  • URL: Uses api.deepl.com
  • Best for: Large books, frequent use, production

Getting an API Key

  1. Visit DeepL API Plans
  2. Choose between Free or Pro plan
  3. Create an account and verify your email
  4. Go to your DeepL Account
  5. Navigate to the "API" section
  6. Copy your authentication key

Setting the API Key

Option 1: Environment Variable (Recommended)

# Linux/macOS
export DEEPL_API_KEY="your-api-key-here"

# Windows
set DEEPL_API_KEY=your-api-key-here

Option 2: System Property

java -DDEEPL_API_KEY="your-api-key" -jar ebook-translator.jar [options]

Supported Languages

DeepL supports many language pairs. Common codes include:

  • EN - English
  • DE - German
  • FR - French
  • ES - Spanish
  • IT - Italian
  • PT - Portuguese
  • RU - Russian
  • JA - Japanese
  • ZH - Chinese

For the complete list, see DeepL's Language Documentation.

Building from Source

# Clone the repository
git clone https://github.com/mess/ebook-translator.git
cd ebook-translator

# Build with Maven
./mvnw clean package

# Run the generated JAR
java -jar target/ebook-translator-*-jar-with-dependencies.jar [options]

System Requirements

  • Java: Version 11 or higher
  • Memory: Minimum 256MB RAM (more for large books)
  • Storage: Temporary space equal to ~3x the EPUB file size
  • Network: Internet connection for DeepL API calls

License

This project is open source. Please see the LICENSE file for details.


Note: This tool is not affiliated with or endorsed by DeepL SE. DeepL is a trademark of DeepL SE.

About

This project provides a tool to parse DRM-free ebooks and automatically translate their content using the DeepL API.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published