Skip to content

kasteph/pygtaw

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pygtaw

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.

About

Python Google Translate API Wrapper

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages