This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change-Id: I3779282126cdd05b047194d356932b9995484115
- Loading branch information
1 parent
2f9bd03
commit 1a98398
Showing
3 changed files
with
148 additions
and
64 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
.. This file is automatically generated. Do not edit this file directly. | ||
Google Translate API Python Samples | ||
=============================================================================== | ||
|
||
This directory contains samples for Google Translate API. With `Google Translate API`, you can dynamically translate text between thousands of language pairs. | ||
|
||
|
||
|
||
|
||
.. _Google Translate API: https://cloud.google.com/translate/docs | ||
|
||
Setup | ||
------------------------------------------------------------------------------- | ||
|
||
|
||
Authentication | ||
++++++++++++++ | ||
|
||
Authentication for this service is done via an `API Key`_. To obtain an API | ||
Key: | ||
|
||
1. Open the `Cloud Platform Console`_ | ||
2. Make sure that billing is enabled for your project. | ||
3. From the **Credentials** page, create a new **API Key** or use an existing | ||
one for your project. | ||
|
||
.. _API Key: | ||
https://developers.google.com/api-client-library/python/guide/aaa_apikeys | ||
.. _Cloud Console: https://console.cloud.google.com/project?_ | ||
|
||
Install Dependencies | ||
++++++++++++++++++++ | ||
|
||
#. Install `pip`_ and `virtualenv`_ if you do not already have them. | ||
|
||
#. Create a virtualenv. Samples are compatible with Python 2.7 and 3.4+. | ||
|
||
.. code-block:: bash | ||
$ virtualenv env | ||
$ source env/bin/activate | ||
#. Install the dependencies needed to run the samples. | ||
|
||
.. code-block:: bash | ||
$ pip install -r requirements.txt | ||
.. _pip: https://pip.pypa.io/ | ||
.. _virtualenv: https://virtualenv.pypa.io/ | ||
|
||
Samples | ||
------------------------------------------------------------------------------- | ||
|
||
Quickstart | ||
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
|
||
|
||
|
||
To run this sample: | ||
|
||
.. code-block:: bash | ||
$ python quickstart.py | ||
Snippets | ||
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
|
||
|
||
|
||
To run this sample: | ||
|
||
.. code-block:: bash | ||
$ python snippets.py | ||
usage: snippets.py [-h] | ||
api_key | ||
{detect-language,list-languages,list-languages-with-target,translate-text} | ||
... | ||
This application demonstrates how to perform basic operations with the | ||
Google Cloud Translate API | ||
For more information, the documentation at | ||
https://cloud.google.com/translate/docs. | ||
positional arguments: | ||
api_key Your API key. | ||
{detect-language,list-languages,list-languages-with-target,translate-text} | ||
detect-language Detects the text's language. | ||
list-languages Lists all available languages. | ||
list-languages-with-target | ||
Lists all available languages and localizes them to | ||
the target language. Target must be an ISO 639-1 | ||
language code. See https://g.co/cloud/translate/v2 | ||
/translate-reference#supported_languages | ||
translate-text Translates text into the target language. Target must | ||
be an ISO 639-1 language code. See | ||
https://g.co/cloud/translate/v2/translate- | ||
reference#supported_languages | ||
optional arguments: | ||
-h, --help show this help message and exit | ||
The client library | ||
------------------------------------------------------------------------------- | ||
This sample uses the `Google Cloud Client Library for Python`_. | ||
You can read the documentation for more details on API usage and use GitHub | ||
to `browse the source`_ and `report issues`_. | ||
.. Google Cloud Client Library for Python: | ||
https://googlecloudplatform.github.io/google-cloud-python/ | ||
.. browse the source: | ||
https://github.com/GoogleCloudPlatform/google-cloud-python | ||
.. report issues: | ||
https://github.com/GoogleCloudPlatform/google-cloud-python/issues | ||
.. _Google Cloud SDK: https://cloud.google.com/sdk/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# This file is used to generate README.rst | ||
|
||
product: | ||
name: Google Translate API | ||
short_name: Translate API | ||
url: https://cloud.google.com/translate/docs | ||
description: > | ||
With `Google Translate API`, you can dynamically translate text between | ||
thousands of language pairs. | ||
|
||
setup: | ||
- auth_api_key | ||
- install_deps | ||
|
||
samples: | ||
- name: Quickstart | ||
file: quickstart.py | ||
- name: Snippets | ||
file: snippets.py | ||
show_help: true | ||
|
||
cloud_client_library: true |