Wrapper library for multiple translation APIs
Project description
Magic Translator
Magic translator is a wrapper library of multiple translation APIs. For different source languages, you can configure which translation API to use and/or which destination language to translate to.
Installation
The library is developed and tested in Python 3.7
pip install magictranslator
Usage
from magictranslator import translator
t = translator.FromJSONConfigFile('config.json')
res = t.Translate('hola amigo buenas noches')
print(res.translated_text)
Config JSON file structure
MagicTranslator accepts JSON-like data config as input. The config JSON data (example can be found in config.json) has the following structure. All language codes are valid two-character ISO-639-1 codes, such as 'en', 'ar', 'ko'
translators
List of translators to use. Each object in the list has the following items
- name (required): Name of translator. Currently supported names are: googletrans, google, aws, yandex
- optional data specific to each translator
- googletrans: no additional data is needed
- google: "service_account" is required with path to the service account JSON file
- aws: "region" is required for the AWS Translate API region name
- yandex: "api_key" is required
default_translator
Name of the default translator. Should be one of the translators in "translators" section
default_dest
Default destination language code to translate to
no_translates
List of language codes not to translate
src_langs
List of source languages to configure specifically. All other languages not in this list will be translated to default_dest by default_translator.
Each object in the list has three fields
- src (required): Source language code
- dest (optional): Destination language code, if different from default_dest
- translator (optional): Name of translator to use, if different from default_translator
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for magictranslator-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b8cac5b5d49877e74f4a2686380b868a59afbf6ed8a35c5e17e82cc963d584c5 |
|
MD5 | a7c53c7e6636d7ab0f24cd8838a93c09 |
|
BLAKE2b-256 | 26855e020896a8f284bd7372c9a4bafc97c89d91ffe92ae8f4199921054191b3 |