1- Using the Translate Client
1+ Translation v2 Usage Guide
22--------------------------
33
44To 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
1111By default, the client targets English when doing detections
1212and translations, but a non-default value can be used as
1313well:
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
2121map 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
2626To 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 [
0 commit comments