Skip to main content

A tiny Google Translate API wrapper written in Python.

Project description

A tiny Google Translate API wrapper written in Python. An API key is needed to use this. More information on obtaining the API key can be found on the Google Translate API site.

The full list of supported languages.

Usage

To install: pip install pygtaw.

Identify your api key and make a new Client object.

>>> import pygtaw
>>> api_key = 'ENTER_API_KEY'
>>> client = pygtaw.Client(api_key)

To make the translation request:

>>> query = 'Hello, world!'
>>> target = 'Korean'
>>> source = 'English'
>>> translation = client.translate(query, target, source)
>>>
>>> print translation.translated_text
안녕하세요

You can send a translation request without a source as well–the Google Translate API can detect the source language:

>>> translation = client.translate('Hello', target='Spanish')
>>> print translation.translated_text
Hola
>>> print translation.detected_source_language
English

Tests

Currently, tests are made by making requests to Google Translate API. To run the tests, make a key file in the tests folder and make sure it’s added to .gitignore.

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

pygtaw-0.0.9.tar.gz (3.3 kB view details)

Uploaded Source

File details

Details for the file pygtaw-0.0.9.tar.gz.

File metadata

  • Download URL: pygtaw-0.0.9.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pygtaw-0.0.9.tar.gz
Algorithm Hash digest
SHA256 d354d7fe0146f4fa8f5a80ce324148499b4c5588c8ed40e6a7eb64d1bce41ba9
MD5 39fc1fee51a0a0e26e4e6ccca9320b1b
BLAKE2b-256 421a7876ded6bcc0ebfe41989ab11f638fc8428c1f0dadf97d27fffc43080c94

See more details on using hashes here.

Supported by

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