A Calibre plugin to translate ebook into a specified language (optionally keeping the original content).
- Support languages supported by the selected translation engine (e.g. Google Translate supports 134 languages)
- Support multiple translation engines, including Google Translate, ChatGPT, and DeepL
- Support for custom translation engines (you can configure to parse response in JSON or XML format)
- Support all ebook formats supported by Calibre (48 input formats, 20 output formats)
- Support to translate more than one ebooks. The translation process of each book is carried out simultaneously without affecting one another
- Support caching translated content, with no need to re-translate after request failure or network interruption
- Provide a large number of customization settings, such as saving translated ebooks to Calibre library or designated location
Please make sure Calibre is installed on your OS, and install the plugin via either ways below:
[ Install from Calibre ]
- Click Calibre Menu [Preference... → Plug-ins → Get new plugins].
- Select Ebook Translator from the plugin list, and click [Install].
- Reboot Calibre.
[ Load from file ]
- Download the plugin zip file from releases page.
- Click Calibre Menu [Preference... → Plug-ins → Load plug-in from file], and choose the zip file you downloaded.
- Reboot Calibre.
If you want to install the latest plugin, run the following commands to download the latest plugin file from GitHub repository:
git clone https://github.com/bookfere/Ebook-Translator-Calibre-Plugin.git
cd Ebook-Translator-Calibre-Plugin
git archive --format zip --output ../Ebook-Translator-Calibre-Plugin.zip master
If the "Translate Book" plugin is not showing up on Calibre menu, you need to add it from [Preference... → Toolbars & menus], choose [The main toolbar], find the plugin and click [>], and [Apply].
- Select the ebook(s), and click the plugin icon "Translate Book".
- Select the Target Language (and Output Format if needed).
- Click [TRANSLATE] button.
After that, you can check the translation process by clicking "Jobs" at the bottom right. Double clicking the job item, you can check the real-time translation log from the window it prompts.
You can customize the plugin through "Content" and "Setting" panels.
[ Translation Position ]
- Add after original [default]: Add the translation text after original text
- Add before original: Add the translation text before original text
- Add without original: Add the translation text and delete original text
[ Translation Color ]
- Color Value: CSS color value, e.g., #666666, grey, rgb(80, 80, 80)
You can click the [Select] button to select a color from color palette, or enter the color value manually. Please refer to "color value" on MDN documentation for details. If left blank no customized color will be applied.
[ Merge to Translate ]
- Enable [default unchecked]: Enable to merge to translate
You can specify the number of characters to translate at one time, default value is 2000.
[ Translation Glossary ]
- Enable [default unchecked]: Enable to use the selected translation glossary file
A translation glossary serves to define precise translations for particular terms and to direct the translation engine to exclude specific terms from translation.
The glossary file is a plain text file with extension .txt. It has the following format: if a term requires a specific translation, it is presented as a pair of two lines, the first one with the original term and the second one with its translation; If a term needs to be ignored in translation, it is presented as a single line per term. The groups of terms are separated by a blank line.
La Torre Eiffel The Eiffel Tower La Estatua de la Libertad
[ Do not Translate ]
- Normal [default]: Exclude paragraph by keyword (one keyword per line)
- Normal(case-sensitive): Exclude paragraph by case-sensitive keyword (one keyword per line)
- Regular Expression: Exclude paragraph by Regular Expression rule (one rule per line)
For regular expression syntax, please refer to "Regular Expression Syntax" on Python documentation.
[ Output Path ]
- Library [default]: After the ebook is translated, it will be placed in Calibre library
- Path: After the ebook is translated, it will be stored in specified directory
[ Translation Engine ]
- Google(Free) [default]: Free translation engine
- ChatGPT: API key required
- DeepL: API key required
- DeepL(Pro): API key required
- DeepL(Free): Free translation engine (Unstable)
- Youdao: APP key and secret required
- Baidu: APP id and key required
- [Custom]: Customize your own translation engine
Except for Google(Free) and DeepL(Free), who does not require an API key, other built-in translation engines require you to register a corresponding account and pay to obtain an API key.
If you opt for a paid translation engine, we recommend you to refer to its official documentation for pricing rules. For example, ChatGPT uses its official tool, Tokenizer, to estimate the number of tokens required to translate a given amount of text in order to provide a cost estimate.
You can click the [Test] button to test the selected translation engine. If translation engine provides quota information, it will be displayed at the bottom of Test Translation Engine window.
Click the [Custom] button, you will enter the "Custom Translation Engine" interface, where you can add, delete and configure a translation engine.
The data to configure a custom translation engine is in JSON format. Each time you add a new custom translation engine, a data template, as shown below, will be displayed for your reference:
{
"name": "New Engine - 36e05",
"languages": {
"source": {
"Source Language": "code"
},
"target": {
"Target Language": "code"
}
},
"request": {
"url": "https://example.api",
"method": "POST",
"headers": {
"Content-Type": "application/json"
},
"data": {
"source": "<source>",
"target": "<target>",
"text": "<text>"
}
},
"response": "response"
}
The above data template contains 4 name/value pairs, which will be explained as below. You can update the template as needed.
name
: The name of the translation engine displayed on the UI, for example, Bing.languages
: The language codes supported by the translation engine. The format is{'Language Name': 'language code'}
. Please refer to the documentation of the translation engine API for details. You can also specify the source language and target language respectively.source
: The source language. The format is the same as for languages.target
: The target language. The format is the same as for languages.
request
: Request data, including the following name/value pairs:url
: The API URL, as specified in the documentation of the translation engine API.method
: The request method (optional), with a default value ofGET
.headers
: The request header (optional). You can refer to the documentation of the translation engine API for details.
data
: Request data, can be either adict
object which will be encoded and sent as application/x-www-form-urlencoded
data or a string which will be sent as is. If you use a string you should also set theContent-Type
header appropriately. It includes 3 built-in variables:<source>
,<target>
, and<text>
.<source>
and<target>
correspond to the language codes set earlier, and can be ignored if not needed;<text>
refers to the original text sent to the translation engine, which must be included to save. Please refer to the documentation of the translation engine API for details.response
: The expression used to parse the response data to obtain the translation text. The response data is included in theresponse
variable, which is a JSON object (if the response from the translation engine is in JSON format) or an Element object of lxml (if the response from the translation engine is in XML format).
Once you have completed the data for the custom translation engine, you can click the [Verify] button to check whether the data format is valid, and click the [Save] button to save all the changes.
[ ChatGPT Prompt ]
- For auto detecting source language: Customize ChatGPT prompt to translate from 'Auto detect' source language
- For specifying source language: Customize ChatGPT prompt to translate from specified source language
[ Preferred Language ]
- Target Language [default UI language]:Set the preferred target language.
[ Network Proxy ]
- Enable [default unchecked]: Enable network proxy
- Host: IP or domain name
- Port: Range 0-65536
- Test: Test the connectivity of proxy
[ Cache ]
- Enable [default checked]: Enable to cache translated content
- Clear: Delete all caches
Enabling the caching function can avoid re-translation of the translated content after request failure or network interruption. You can also check the amount of disk space occupied by the cache here, and click [Clear] button to delete all caches. Note that if a translation job is currently in progress, the [Clear] button will be disabled to use.
[ Request ]
- Attempt Times [default 3]: The number of times to attempt if failed to request translation engine
- Maximum Interval [default 5 seconds]: The maximum time interval to request translation engine
A single request to translation engine can last up to 300 seconds. After the timeout, it will retry according to the specified attempt times, and the waiting time for each retry will be gradually increased. The request interval will be a random number between 1 and the maximum interval specified.
When using Google Translate API, which is currently available for free, we recommend you to increase the "Maximum Interval" to an appropriate value (more than 5 seconds is recommended) to prevent it from being flagged as abusive behavior, which could lead to translation interruptions or denial of service. For paid translation engines, the "Maximum Interval" can be set to 1.
[ Log ]
- Display translation [Default checked]: The translation content will be displayed in real time from the respective log window of the translation job
GNU General Public License v3.0