Skip to content

Commit

Permalink
docs(translation): fix v2 imports, remove v2 sample in README (#9536)
Browse files Browse the repository at this point in the history
  • Loading branch information
busunkim96 authored Oct 29, 2019
1 parent 0a4184c commit af4a172
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 65 deletions.
39 changes: 1 addition & 38 deletions packages/google-cloud-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 packages/google-cloud-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 packages/google-cloud-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 packages/google-cloud-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

0 comments on commit af4a172

Please sign in to comment.