Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 1 addition & 38 deletions translate/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,41 +81,4 @@ Windows
pip install virtualenv
virtualenv <your-env>
<your-env>\Scripts\activate
<your-env>\Scripts\pip.exe install google-cloud-translate


Example Usage
~~~~~~~~~~~~~

.. code-block:: python

>>> from google.cloud import translate
>>> client = translate.Client()
>>> client.get_languages()
[
{
'language': 'af',
'name': 'Afrikaans',
},
...
]
>>> client.detect_language(['Me llamo', 'I am'])
[
{
'confidence': 0.25830904,
'input': 'Me llamo',
'language': 'es',
}, {
'confidence': 0.17112699,
'input': 'I am',
'language': 'en',
},
]
>>> from google.cloud import translate
>>> client = translate.Client()
>>> client.translate('koszula')
{
'translatedText': 'shirt',
'detectedSourceLanguage': 'pl',
'input': 'koszula',
}
<your-env>\Scripts\pip.exe install google-cloud-translate
8 changes: 0 additions & 8 deletions translate/docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
.. include:: README.rst

v2 Usage Guide
--------------------
.. toctree::
:maxdepth: 2

usage


API Reference
-------------

Expand Down
38 changes: 19 additions & 19 deletions translate/docs/usage.rst
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
Using the Translate Client
Translation v2 Usage Guide
--------------------------

To create a client:

.. doctest::

>>> from google.cloud import translate
>>> client = translate.Client()
>>> from google.cloud import translate_v2
>>> client = translate_v2.Client()

By default, the client targets English when doing detections
and translations, but a non-default value can be used as
well:

.. doctest::

>>> from google.cloud import translate
>>> client = translate.Client(target_language='es')
>>> from google.cloud import translate_v2
>>> client = translate_v2.Client(target_language='es')

The Google Cloud Translation API has three supported methods, and they
The Google Cloud Translation v2 API has three supported methods, and they
map to three methods on a client:
:meth:`~google.cloud.translate.client.Client.get_languages`,
:meth:`~google.cloud.translate.client.Client.detect_language` and
:meth:`~google.cloud.translate.client.Client.translate`.
:meth:`~google.cloud.translate_v2.client.Client.get_languages`,
:meth:`~google.cloud.translate_v2.client.Client.detect_language` and
:meth:`~google.cloud.translate_v2.client.Client.translate`.

To get a list of languages supported by the Google Cloud Translation API

.. doctest::

>>> from google.cloud import translate
>>> client = translate.Client()
>>> from google.cloud import translate_v2
>>> client = translate_v2.Client()
>>> client.get_languages()
[
{
Expand All @@ -42,8 +42,8 @@ To detect the language that some given text is written in:

.. doctest::

>>> from google.cloud import translate
>>> client = translate.Client()
>>> from google.cloud import translate_v2
>>> client = translate_v2.Client()
>>> client.detect_language(['Me llamo', 'I am'])
[
{
Expand All @@ -68,8 +68,8 @@ the source language:

.. doctest::

>>> from google.cloud import translate
>>> client = translate.Client()
>>> from google.cloud import translate_v2
>>> client = translate_v2.Client()
>>> client.translate('koszula')
{
'translatedText': 'shirt',
Expand All @@ -81,8 +81,8 @@ If the source language is known:

.. doctest::

>>> from google.cloud import translate
>>> client = translate.Client()
>>> from google.cloud import translate_v2
>>> client = translate_v2.Client()
>>> client.translate('camisa', source_language='es')
{
'translatedText': 'shirt',
Expand All @@ -93,8 +93,8 @@ or to use a non-default target language:

.. doctest::

>>> from google.cloud import translate
>>> client = translate.Client()
>>> from google.cloud import translate_v2
>>> client = translate_v2.Client()
>>> client.translate(['Me llamo Jeff', 'My name is Jeff'],
... target_language='de')
[
Expand Down
1 change: 1 addition & 0 deletions translate/docs/v2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ v2
:maxdepth: 2

client
usage