Skip to content

Commit c6a835b

Browse files
authored
Add snippet using 'source_language' argument to 'Client.translate'. (googleapis#5592)
Closes googleapis#5324.
1 parent 7052eff commit c6a835b

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

docs/translate/usage.rst

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ The `confidence`_ value is an optional floating point value between 0 and 1.
9494
The closer this value is to 1, the higher the confidence level for the
9595
language detection. This member is not always available.
9696

97-
To translate text:
97+
To translate text into the default destination language without knowing
98+
the source language:
9899

99100
.. code::
100101
@@ -107,6 +108,18 @@ To translate text:
107108
'input': 'koszula',
108109
}
109110
111+
If the source language is known:
112+
113+
.. code::
114+
115+
>>> from google.cloud import translate
116+
>>> client = translate.Client()
117+
>>> client.translate('camisa', source_language='es')
118+
{
119+
'translatedText': 'shirt',
120+
'input': 'camisa',
121+
}
122+
110123
or to use a non-default target language:
111124

112125
.. code::

0 commit comments

Comments
 (0)