Skip to content

Commit 847cd43

Browse files
authored
docs(translation): fix v2 imports, remove v2 sample in README (#9536)
1 parent ee62142 commit 847cd43

File tree

4 files changed

+21
-65
lines changed

4 files changed

+21
-65
lines changed

translate/README.rst

+1-38
Original file line numberDiff line numberDiff line change
@@ -81,41 +81,4 @@ Windows
8181
pip install virtualenv
8282
virtualenv <your-env>
8383
<your-env>\Scripts\activate
84-
<your-env>\Scripts\pip.exe install google-cloud-translate
85-
86-
87-
Example Usage
88-
~~~~~~~~~~~~~
89-
90-
.. code-block:: python
91-
92-
>>> from google.cloud import translate
93-
>>> client = translate.Client()
94-
>>> client.get_languages()
95-
[
96-
{
97-
'language': 'af',
98-
'name': 'Afrikaans',
99-
},
100-
...
101-
]
102-
>>> client.detect_language(['Me llamo', 'I am'])
103-
[
104-
{
105-
'confidence': 0.25830904,
106-
'input': 'Me llamo',
107-
'language': 'es',
108-
}, {
109-
'confidence': 0.17112699,
110-
'input': 'I am',
111-
'language': 'en',
112-
},
113-
]
114-
>>> from google.cloud import translate
115-
>>> client = translate.Client()
116-
>>> client.translate('koszula')
117-
{
118-
'translatedText': 'shirt',
119-
'detectedSourceLanguage': 'pl',
120-
'input': 'koszula',
121-
}
84+
<your-env>\Scripts\pip.exe install google-cloud-translate

translate/docs/index.rst

-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
.. include:: README.rst
22

3-
v2 Usage Guide
4-
--------------------
5-
.. toctree::
6-
:maxdepth: 2
7-
8-
usage
9-
10-
113
API Reference
124
-------------
135

translate/docs/usage.rst

+19-19
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
1-
Using the Translate Client
1+
Translation v2 Usage Guide
22
--------------------------
33

44
To create a client:
55

66
.. doctest::
77

8-
>>> from google.cloud import translate
9-
>>> client = translate.Client()
8+
>>> from google.cloud import translate_v2
9+
>>> client = translate_v2.Client()
1010

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

1515
.. doctest::
1616

17-
>>> from google.cloud import translate
18-
>>> client = translate.Client(target_language='es')
17+
>>> from google.cloud import translate_v2
18+
>>> client = translate_v2.Client(target_language='es')
1919

20-
The Google Cloud Translation API has three supported methods, and they
20+
The Google Cloud Translation v2 API has three supported methods, and they
2121
map to three methods on a client:
22-
:meth:`~google.cloud.translate.client.Client.get_languages`,
23-
:meth:`~google.cloud.translate.client.Client.detect_language` and
24-
:meth:`~google.cloud.translate.client.Client.translate`.
22+
:meth:`~google.cloud.translate_v2.client.Client.get_languages`,
23+
:meth:`~google.cloud.translate_v2.client.Client.detect_language` and
24+
:meth:`~google.cloud.translate_v2.client.Client.translate`.
2525

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

2828
.. doctest::
2929

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

4343
.. doctest::
4444

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

6969
.. doctest::
7070

71-
>>> from google.cloud import translate
72-
>>> client = translate.Client()
71+
>>> from google.cloud import translate_v2
72+
>>> client = translate_v2.Client()
7373
>>> client.translate('koszula')
7474
{
7575
'translatedText': 'shirt',
@@ -81,8 +81,8 @@ If the source language is known:
8181

8282
.. doctest::
8383

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

9494
.. doctest::
9595

96-
>>> from google.cloud import translate
97-
>>> client = translate.Client()
96+
>>> from google.cloud import translate_v2
97+
>>> client = translate_v2.Client()
9898
>>> client.translate(['Me llamo Jeff', 'My name is Jeff'],
9999
... target_language='de')
100100
[

translate/docs/v2.rst

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ v2
55
:maxdepth: 2
66

77
client
8+
usage

0 commit comments

Comments
 (0)