Skip to main content

Polyglot - Automate translations with DeepL

PyPI PyPI - Downloads PyPI - License

Polyglot is a CLI tool that automates translation tasks and can be easily integrated into your python softwares. Using the DeepL API, Polyglot generates a translated file from a given source file.

alt text

Supported files

Polyglot is born to translate JSON and PO files, but now it supports other files. This is the complete list:

  • json
  • po and pot
  • docx (Microsoft Word)
  • pptx (Microsoft PowerPoint)
  • html and htm
  • pdf
  • raw text files like .txt or .dat

⚠️ If you want to translate PDFs, rember to enable the PDF translations from your DeepL API account.

Installation

Install Python if you haven't already done so, then use pip to install Polyglot.

pip install polyglot-translator

Then you can run Polyglot by running:

python -m polyglot

And that's all.

Soon the whole script will be packaged for other package managers like pacman, apt and brew.

Usage

There are four available commands: translate, set_license, print_usage_data and print_supported_languages.

Translate

"Translate" is the main feature of Polyglot. It reads the passed file and creates one or more new files with the translations. It creates a new file with the translations and doesn't edit the source file.

ℹ️ In the case of a PO and POT files, it returns both a PO and an MO file.

Command options

Option Required Description
-s, --source-file yes The file to be translated.
--to, --target-lang yes the code of the language into which you want to translate the source file
-d, --destination-dir no The directory where the output file will be located. Will be used the working directory if this option is invalid or not used.
--from, --source-lang no Source file language code. Detected automatically by DeepL by default. Specifying it can increase performance and make translations more accurate.

Basic usage

E.g.: we have a .json source in English and we want to translate it in Italian.

python -m polyglot translate -s en.json --to IT

Advanced usage

E.g.: we have a .po source in English and we want a .po file translated into Japanese with the corresponding .mo file in our home. We specify the source language to benefit DeepL.

python -m polyglot translate -s en.po --to JA -d $HOME --from EN-US

Set DeepL API key

DeepL provides you with a key that allows you to use its API. So, Polyglot requires this key to work and will ask you for it on your first use. You can use the following command to set or change the key manually.

python -m polyglot set-license

Print usage info

It returns DeepL usage info related to your API key, run with:

python -m polyglot info

Print supported languages

It returns the list of languages currently supported by DeepL, run with:

python -m polyglot languages

Dependencies

Release files for polyglot-translator 2.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for polyglot-translator 2.2.4
File Size Uploaded
polyglot-translator-2.2.4.tar.gz 11.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for polyglot-translator 2.2.4
File Interpreter ABI Platform
polyglot_translator-2.2.4-py3-none-any.whl Python 3 none any Details

Total release size: 25.1 kB

Release files / polyglot-translator-2.2.4.tar.gz

Download URL polyglot-translator-2.2.4.tar.gz
Size 11.9 kB
Tags Source
SHA-256 checksum
How to use checksums
c07b58c9597ec907174332ce445989ec5d85af6f0ed70ce3ec121bcae2408be4
BLAKE2b-256 checksum
How to use checksums
0f0ff296e467bd70973e7071e7065b24ee99685fb08a42579f7fe9c695bd72ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.15

Release files / polyglot_translator-2.2.4-py3-none-any.whl

Download URL polyglot_translator-2.2.4-py3-none-any.whl
Size 13.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f6c6d820fe63979162fc37c1acf9d8d5decc42159170c27187bdd23124bfc80f
BLAKE2b-256 checksum
How to use checksums
342a6b06e6f4b7e279526d840253cc846d29f86e9408123078db4342f45bc198
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.15

Release history Release notifications | RSS feed

This release

2.2.4 This release

2 release files

2.2.3

2 release files

2.2.2

2 release files

2.2.1

2 release files

2.2.0

2 release files

2.1.5

2 release files

2.1.4

2 release files

2.1.3

2 release files

2.1.2

2 release files

2.1.1

2 release files

2.1.0

2 release files

2.0.6

2 release files

2.0.5

2 release files

2.0.4

2 release files

2.0.3

2 release files

2.0.2

2 release files

1.6.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page