Coder Social home page Coder Social logo

quantrancse / epub-translator Goto Github PK

View Code? Open in Web Editor NEW
175.0 7.0 37.0 112 KB

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

License: MIT License

Python 100.00%
epub epub-translator ebook ebook-translator light-novel-translator translator python

epub-translator's Introduction

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

epub-translator's People

Contributors

chuiizeet avatar quantrancse avatar zaharchenko-yurka avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

epub-translator's Issues

File path is incorrect!

I have a file that is quite obviously there, locally, and it keeps saying it's not there, regardless of whether the path is in quotes or not...manually typed or not, etc.
Screenshot 2023-08-29 at 1 51 07 PM

Translation fail error

So when i tried to translate epub to ru language it shows me fail every try. This error also similar as at third pc. I think that error was in my wifi. But no, when i use my friend's wifi error was also similar as in past. VPN translates not all epub, but only 20-50% of it. I don't know how to fix it. Help plz.

google_new_transError: 404 (Not Found) from TTS API. Probable cause: Unknown

I'm trying to translate an epub into spanish using the following command:

python epub-translator.py -l es

But the following error is thrown:
google_trans_new.google_trans_new.google_new_transError: 404 (Not Found) from TTS API. Probable cause: Unknown

I'm using python 3.9 on a conda environment. The requirements listed have been installed.

Problem with phrases with footnotes

Hi,

First, your work it's amazing. It helps me a lot!

I translated a lot of books, and I noted just one problem. Phrases with notes at their end are turned into notes.

For example:

image

here, "uma arte de participação. As duas funções, passivos e activos, eram inseparáveis. O próprio mundo sonha, disse ele, e nós ajudar dar-lhe voz." is a normal phrase and the number 5 is the footnote.

I'm studying your code but I don't think I have enough technical knowledge of the tools you're using for now.

Thank you again!

Translation in arabic

The translation in arabic which should be from right to left, is done from left to right. Words should be as they are, but written in the opposite way (right to left)

Table of Contents showing in original language

I was trying to translate a Japanese eBook to English and noticed the TOC is not translated and still in Japanese.

The TOC doesn't seem to be translated into target language.

And then there is this bug with Sumatra Reader that only happens in the translated file and not the original file may be related to this. #3 (comment)

Edit: Android Readers like https://github.com/voice and Evie say that the ePub is damaged.

Edit: Converting the generated ePub to Mobi and then reconverting it back to ePub solves the problem for me.

Won't translate Ao3 Epubs

Hi sorry to bother you, but i found that while trying to translate a few Spanish epubs from https://archiveofourown.org/ that it wasn't translating them to english despite claiming that it did. any suggestions or possible fixes for this? Thank you for your time.

Does not work for a Kobo.

The translated file cannot be opened on a Kobo Glo (Find DRM) while the original untranslated book opens.

Convert en->fr

DOCTYPE mishandled

inside xml gets

html public "-// w3c // dtd xhtml 1.1 // en" "http://www.w3.org/tr/xhtml11/dtd/xhtml11.dtd"

perhaps

if isinstance(ele, element.NavigableString) and str(ele).strip() not in ['', 'html']:
have to be replaced(not debugged yet) (see https://www.crummy.com/software/BeautifulSoup/bs4/doc/#comments-and-other-special-strings)

if isinstance(ele, element.NavigableString) and not (isinstance(ele,bs.Doctype) or isinstance(ele,bs.CData) or isinstance(ele,bs.Declaration)) and str(ele).strip() not in ['', 'html']:

Bug - Just getting jpg from translated version

Good evening, I want to thank you for this great contribution.
I am using the most recent version to date (1.0.1)
It does not bring me text, only images, the resulting file weighs almost the same as the original file.
Thanks in advance, good luck on the day :3

imagen
imagen
imagen

Timeout error

Hi, buddy thanks for this awesome package.
I'm trying to use the repository
This is the command that I run

Captura de pantalla 2023-03-02 a la(s) 14 47 29

but I get a "Timeout" response.
Captura de pantalla 2023-03-02 a la(s) 14 48 38

What could be wrong?

Fail with no specific error.

While attempting to translate an Epub from Italian to English it starts to translate, makes it to between 1 and 2% then Fails twice and makes a translated file.
translator fail

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.