This project aims to quickly translate epub books into Vietnamese, packaging the result as a bilingual book. It's designed to maintain the original text format while providing a rough translation.
Watch the tutorial video (Vietnamese)
- Quick Start
- Installation
- Usage
- Web Serving
- Editing Translations
- Contributing
- Limitations and Known Issues
- Install Epub Translator (see Installation)
- Set up your ANTHROPIC_KEY:
export ANTHROPIC_KEY=your_anthropic_key
- Translate a book:
epubtrans unpack /path/to/book.epub epubtrans clean /path/to/unpacked-epub epubtrans mark /path/to/unpacked-epub epubtrans translate /path/to/unpacked-epub --source English --target Vietnamese epubtrans pack /path/to/unpacked
- Windows: PowerShell 5.1 or later
- Linux/macOS: Bash shell
- All systems: Internet connection
- Open PowerShell as Administrator and run:
$ErrorActionPreference = "Stop"
$version = (Invoke-RestMethod "https://api.github.com/repos/nguyenvanduocit/epubtrans/releases/latest").tag_name
$arch = if ([Environment]::Is64BitOperatingSystem) { "amd64" } else { "386" }
$url = "https://github.com/nguyenvanduocit/epubtrans/releases/download/${version}/epubtrans_${version.Substring(1)}_windows_${arch}.tar.gz"
Invoke-WebRequest -Uri $url -OutFile "epubtrans.tar.gz"
tar -xzf epubtrans.tar.gz
Move-Item -Force epubtrans.exe "C:\Windows\System32\"
Remove-Item epubtrans.tar.gz
Write-Host "epubtrans $version has been installed successfully!"
Open a terminal and run:
bash -c "$(curl -fsSL https://raw.githubusercontent.com/nguyenvanduocit/epubtrans/main/scripts/install_unix.sh)"
After installation, verify by running:
epubtrans --version
Usage:
epubtrans [flags]
epubtrans [command]
Available Commands:
clean Clean the html files
completion Generate the autocompletion script for the specified shell
help Help about any command
mark Mark content in EPUB files
pack Zip files in a directory
serve Serve the content of an unpacked EPUB as a web server
styling Style the content of an unpacked EPUB
translate Translate the content of an unpacked EPUB
unpack Unpack a book
upgrade Self update the tool
Flags:
-h, --help help for epubtrans
-v, --version version for epubtrans
-
Configure environment:
export ANTHROPIC_KEY=your_anthropic_key
Note: You need to obtain an ANTHROPIC_KEY from Anthropic's website to use their translation API.
-
Unpack the epub file:
epubtrans unpack /path/to/file.epub
-
Clean up HTML files:
epubtrans clean /path/to/unpacked-epub
-
Mark content for translation:
epubtrans mark /path/to/unpacked-epub
-
Translate marked content:
epubtrans translate /path/to/unpacked-epub --source English --target Vietnamese
-
(Optional) Apply styling:
epubtrans styling /path/to/unpacked --hide "source|target"
the command also make original text to be faded out a little bit, so that the translated text can be more visible.
- Package into a bilingual book:
epubtrans pack /path/to/unpacked
To serve the book on the web:
epubtrans serve /path/to/unpacked
Important endpoints:
- http://localhost:8080/api/info
- http://localhost:8080/toc.html
- http://localhost:3000/api/manifest
- http://localhost:3000/api/spine
When accessing the book via the serve
command, the translated content is editable. After editing, the content is automatically saved when you move the mouse away.
To apply changes, run the pack
command again.
Watch the editing tutorial video
We welcome contributions to the Epub Translator project! Here's how you can help:
- Fork the repository
- Create a new branch for your feature or bug fix
- Make your changes and commit them
- Push to your fork and submit a pull request
Please ensure your code adheres to the project's coding standards and include tests for new features.
- The quality of translation depends on the Anthropic API and may not be perfect for all types of content.
- Large books may take a considerable amount of time to translate.
For any issues or feature requests, please open an issue on the GitHub repository.