Skip to content

A tool for translating epub files to different languages using the Google Translate, with support for custom dictionaries.

License

Notifications You must be signed in to change notification settings

quantrancse/epub-translator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Version MIT License


Logo

epub-translator

A tool for translating epub files to different languages using the Google Translate, with support for custom dictionaries.

Download · Screenshots · Script Usage

Table of Contents

About The Project

A tool for translating epub files to different languages using the Google Translate, with support for custom dictionaries.

Features

  • Autodetect source languages and support multiple destination languages.
  • Keeping the structure of the original epub file (images, table of contents, text style,...)
  • Support custom translation dictionaries (after translated).
  • Support multiprocessing to speed up.
  • Auto checking the new tool version.

Getting Started

Download the execution file below. Run and follow the instructions.

Windows: epub-translator.exe ~ 12MB

Custom Dictionary Usage

The custom dictionary will replace the original translated text by Google Translate with your own text.

  • The custom dictionary is a .txt file with line by line in the format:
    [original_translated_text]:[your_translated_text]
  • Text is case sensitive with special characters (except colon) and spaces are are allowed, separated from the other by the single colon :.

Prerequisites

  • python3
  • google_trans_new
  • requests
  • bs4
  • lxml
  • tqdm
pip install google_trans_new requests bs4 lxml tqdm

or

pip install -r requirements.txt

Important

Script Usage

usage: epub-translator.py [-h] [-v] [-l dest_lang] [-d dict_path] epub_file_path

A tool for translating epub files to different languages 
using the Google Translate, with support for custom dictionaries.

positional arguments:
  epub_file_path        path to the epub file

optional arguments:
  -h, --help            show this help message and exit
  -v, --version         show program's version number and exit
  -l dest_lang, --lang dest_lang
                        destination language
  -d dict_path, --dict dict_path
                        path to the translation dictionary

Notes

  • The translated epub file will be named [original_file]_translated.epub and located in the same folder as the original epub file.
  • Suported destination languages are shown in LANGUAGES variable in the epub-translator.py file.
  • This tool uses autodetect source languages when translating. If you have a problem with it, contact me and maybe I will add the manual select source languages.

Screenshots

Demo

Issues

  • I only tested the tool on some of my favorite books and light novels. 
  • This tool may be buggy. Some books may crash with complex epub structure or some of the text will not be translated.
  • Sometimes, too many translation requests to the Google Translate may cause Google to ban your IP from getting its translation service shortly. If this happens, you should change your IP via VPN.

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Contact