This project aims to quickly translate epub books into Vietnamese. It packages the result as a bilingual book.
You may want to watch the tutorial video - Vietnamese.
- Only need to create a rough translation.
- Maintain the format of the original text.
- Install Go. You can download it from here.
- Install the tool
go install github.com/nguyenvanduocit/epubtrans@latest
To manage the translation content, we need to mark the content that needs to be translated, then translate and mark the translated content. We divide it into 3 commands.
unpack
to extract the epub file.mark
to mark the content that needs to be translated.clean
to clean up erroneous content.translate
to translate the marked content.pack
to package it into a bilingual book.serve
to serve the whole book as a static webserver.
All commands take the path to the epub file to be translated as the first parameter.
- Config env
export ANTHROPIC_KEY=your_anthropic_key
- Unpack the epub file.
epubtrans unpack /path/to/file.epub
- Clean up html files.
epubtrans clean /path/to/unpacked
- Mark the content that needs to be translated.
epubtrans mark /path/to/unpacked
At this point, you will see a folder with the name of the epub, containing the html files of the epub. The content of these html files has been marked.
- Translate the marked content.
epubtrans translate /path/to/unpacked
This process will take some time. At the end of the process, you will have html files with the translated content.
- Apply style to the translated content.
The step is optional. Only when you want to apply some style to the translated content.
epubtrans styling /path/to/unpacked --hide "source|target"
- Package it into a bilingual book.
epubtrans pack /path/to/unpacked
At this point, you will have a repacked epub file with bilingual content.
You can run the command serve
. then the console will show you the address to access the book.
There are some 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 serve
command, you can see that the translated content is editable. After edit and leave the mouse, the content will be saved automatically.
After that, you just need to run the pack
command to package the book again.
You need to add the following CSS to every html file or css file:
[data-content-id] {
display: none !important;
}
You need to add the following CSS to every html file or css file:
[data-content-id] {
opacity: 0.8;
}