Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

magictranslator-0.1.0.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

magictranslator-0.1.0-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file magictranslator-0.1.0.tar.gz.

File metadata

  • Download URL: magictranslator-0.1.0.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.3.1 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.7.7

File hashes

Hashes for magictranslator-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c1868cb27f318205987619b2d90b46f0be49e55f1af827a011f09ac7c1d66d7c
MD5 60fcc9df95cb082eeed8e8aeb3a94766
BLAKE2b-256 419debf3799b391386b93ada34e47801487ee4c2b569bd74e56a0f0c81baf5f4

See more details on using hashes here.

File details

Details for the file magictranslator-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: magictranslator-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.3.1 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.7.7

File hashes

Hashes for magictranslator-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b8cac5b5d49877e74f4a2686380b868a59afbf6ed8a35c5e17e82cc963d584c5
MD5 a7c53c7e6636d7ab0f24cd8838a93c09
BLAKE2b-256 26855e020896a8f284bd7372c9a4bafc97c89d91ffe92ae8f4199921054191b3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page