@@ -222,6 +222,27 @@ async def translate_text(
222222 ) -> translation_service .TranslateTextResponse :
223223 r"""Translates input text and returns translated text.
224224
225+ .. code-block:: python
226+
227+ from google.cloud import translate_v3
228+
229+ def sample_translate_text():
230+ # Create a client
231+ client = translate_v3.TranslationServiceClient()
232+
233+ # Initialize request argument(s)
234+ request = translate_v3.TranslateTextRequest(
235+ contents=['contents_value_1', 'contents_value_2'],
236+ target_language_code="target_language_code_value",
237+ parent="parent_value",
238+ )
239+
240+ # Make the request
241+ response = client.translate_text(request=request)
242+
243+ # Handle the response
244+ print(response)
245+
225246 Args:
226247 request (Union[google.cloud.translate_v3.types.TranslateTextRequest, dict]):
227248 The request object. The request message for synchronous
@@ -390,6 +411,26 @@ async def detect_language(
390411 ) -> translation_service .DetectLanguageResponse :
391412 r"""Detects the language of text within a request.
392413
414+ .. code-block:: python
415+
416+ from google.cloud import translate_v3
417+
418+ def sample_detect_language():
419+ # Create a client
420+ client = translate_v3.TranslationServiceClient()
421+
422+ # Initialize request argument(s)
423+ request = translate_v3.DetectLanguageRequest(
424+ content="content_value",
425+ parent="parent_value",
426+ )
427+
428+ # Make the request
429+ response = client.detect_language(request=request)
430+
431+ # Handle the response
432+ print(response)
433+
393434 Args:
394435 request (Union[google.cloud.translate_v3.types.DetectLanguageRequest, dict]):
395436 The request object. The request message for language
@@ -513,6 +554,26 @@ async def get_supported_languages(
513554 r"""Returns a list of supported languages for
514555 translation.
515556
557+
558+ .. code-block:: python
559+
560+ from google.cloud import translate_v3
561+
562+ def sample_get_supported_languages():
563+ # Create a client
564+ client = translate_v3.TranslationServiceClient()
565+
566+ # Initialize request argument(s)
567+ request = translate_v3.GetSupportedLanguagesRequest(
568+ parent="parent_value",
569+ )
570+
571+ # Make the request
572+ response = client.get_supported_languages(request=request)
573+
574+ # Handle the response
575+ print(response)
576+
516577 Args:
517578 request (Union[google.cloud.translate_v3.types.GetSupportedLanguagesRequest, dict]):
518579 The request object. The request message for discovering
@@ -638,6 +699,30 @@ async def translate_document(
638699 ) -> translation_service .TranslateDocumentResponse :
639700 r"""Translates documents in synchronous mode.
640701
702+ .. code-block:: python
703+
704+ from google.cloud import translate_v3
705+
706+ def sample_translate_document():
707+ # Create a client
708+ client = translate_v3.TranslationServiceClient()
709+
710+ # Initialize request argument(s)
711+ document_input_config = translate_v3.DocumentInputConfig()
712+ document_input_config.content = b'content_blob'
713+
714+ request = translate_v3.TranslateDocumentRequest(
715+ parent="parent_value",
716+ target_language_code="target_language_code_value",
717+ document_input_config=document_input_config,
718+ )
719+
720+ # Make the request
721+ response = client.translate_document(request=request)
722+
723+ # Handle the response
724+ print(response)
725+
641726 Args:
642727 request (Union[google.cloud.translate_v3.types.TranslateDocumentRequest, dict]):
643728 The request object. A document translation request.
@@ -694,6 +779,40 @@ async def batch_translate_text(
694779 use google.longrunning.Operation.name to poll the status
695780 of the call.
696781
782+
783+ .. code-block:: python
784+
785+ from google.cloud import translate_v3
786+
787+ def sample_batch_translate_text():
788+ # Create a client
789+ client = translate_v3.TranslationServiceClient()
790+
791+ # Initialize request argument(s)
792+ input_configs = translate_v3.InputConfig()
793+ input_configs.gcs_source.input_uri = "input_uri_value"
794+
795+ output_config = translate_v3.OutputConfig()
796+ output_config.gcs_destination.output_uri_prefix = "output_uri_prefix_value"
797+
798+ request = translate_v3.BatchTranslateTextRequest(
799+ parent="parent_value",
800+ source_language_code="source_language_code_value",
801+ target_language_codes=['target_language_codes_value_1', 'target_language_codes_value_2'],
802+ input_configs=input_configs,
803+ output_config=output_config,
804+ )
805+
806+ # Make the request
807+ operation = client.batch_translate_text(request=request)
808+
809+ print("Waiting for operation to complete...")
810+
811+ response = operation.result()
812+
813+ # Handle the response
814+ print(response)
815+
697816 Args:
698817 request (Union[google.cloud.translate_v3.types.BatchTranslateTextRequest, dict]):
699818 The request object. The batch translation request.
@@ -767,6 +886,40 @@ async def batch_translate_document(
767886 google.longrunning.Operation.name to poll the status of
768887 the call.
769888
889+
890+ .. code-block:: python
891+
892+ from google.cloud import translate_v3
893+
894+ def sample_batch_translate_document():
895+ # Create a client
896+ client = translate_v3.TranslationServiceClient()
897+
898+ # Initialize request argument(s)
899+ input_configs = translate_v3.BatchDocumentInputConfig()
900+ input_configs.gcs_source.input_uri = "input_uri_value"
901+
902+ output_config = translate_v3.BatchDocumentOutputConfig()
903+ output_config.gcs_destination.output_uri_prefix = "output_uri_prefix_value"
904+
905+ request = translate_v3.BatchTranslateDocumentRequest(
906+ parent="parent_value",
907+ source_language_code="source_language_code_value",
908+ target_language_codes=['target_language_codes_value_1', 'target_language_codes_value_2'],
909+ input_configs=input_configs,
910+ output_config=output_config,
911+ )
912+
913+ # Make the request
914+ operation = client.batch_translate_document(request=request)
915+
916+ print("Waiting for operation to complete...")
917+
918+ response = operation.result()
919+
920+ # Handle the response
921+ print(response)
922+
770923 Args:
771924 request (Union[google.cloud.translate_v3.types.BatchTranslateDocumentRequest, dict]):
772925 The request object. The BatchTranslateDocument request.
@@ -917,6 +1070,34 @@ async def create_glossary(
9171070 r"""Creates a glossary and returns the long-running operation.
9181071 Returns NOT_FOUND, if the project doesn't exist.
9191072
1073+
1074+ .. code-block:: python
1075+
1076+ from google.cloud import translate_v3
1077+
1078+ def sample_create_glossary():
1079+ # Create a client
1080+ client = translate_v3.TranslationServiceClient()
1081+
1082+ # Initialize request argument(s)
1083+ glossary = translate_v3.Glossary()
1084+ glossary.name = "name_value"
1085+
1086+ request = translate_v3.CreateGlossaryRequest(
1087+ parent="parent_value",
1088+ glossary=glossary,
1089+ )
1090+
1091+ # Make the request
1092+ operation = client.create_glossary(request=request)
1093+
1094+ print("Waiting for operation to complete...")
1095+
1096+ response = operation.result()
1097+
1098+ # Handle the response
1099+ print(response)
1100+
9201101 Args:
9211102 request (Union[google.cloud.translate_v3.types.CreateGlossaryRequest, dict]):
9221103 The request object. Request message for CreateGlossary.
@@ -1004,6 +1185,27 @@ async def list_glossaries(
10041185 r"""Lists glossaries in a project. Returns NOT_FOUND, if the project
10051186 doesn't exist.
10061187
1188+
1189+ .. code-block:: python
1190+
1191+ from google.cloud import translate_v3
1192+
1193+ def sample_list_glossaries():
1194+ # Create a client
1195+ client = translate_v3.TranslationServiceClient()
1196+
1197+ # Initialize request argument(s)
1198+ request = translate_v3.ListGlossariesRequest(
1199+ parent="parent_value",
1200+ )
1201+
1202+ # Make the request
1203+ page_result = client.list_glossaries(request=request)
1204+
1205+ # Handle the response
1206+ for response in page_result:
1207+ print(response)
1208+
10071209 Args:
10081210 request (Union[google.cloud.translate_v3.types.ListGlossariesRequest, dict]):
10091211 The request object. Request message for ListGlossaries.
@@ -1094,6 +1296,26 @@ async def get_glossary(
10941296 r"""Gets a glossary. Returns NOT_FOUND, if the glossary doesn't
10951297 exist.
10961298
1299+
1300+ .. code-block:: python
1301+
1302+ from google.cloud import translate_v3
1303+
1304+ def sample_get_glossary():
1305+ # Create a client
1306+ client = translate_v3.TranslationServiceClient()
1307+
1308+ # Initialize request argument(s)
1309+ request = translate_v3.GetGlossaryRequest(
1310+ name="name_value",
1311+ )
1312+
1313+ # Make the request
1314+ response = client.get_glossary(request=request)
1315+
1316+ # Handle the response
1317+ print(response)
1318+
10971319 Args:
10981320 request (Union[google.cloud.translate_v3.types.GetGlossaryRequest, dict]):
10991321 The request object. Request message for GetGlossary.
@@ -1176,6 +1398,30 @@ async def delete_glossary(
11761398 glossary isn't created yet. Returns NOT_FOUND, if the glossary
11771399 doesn't exist.
11781400
1401+
1402+ .. code-block:: python
1403+
1404+ from google.cloud import translate_v3
1405+
1406+ def sample_delete_glossary():
1407+ # Create a client
1408+ client = translate_v3.TranslationServiceClient()
1409+
1410+ # Initialize request argument(s)
1411+ request = translate_v3.DeleteGlossaryRequest(
1412+ name="name_value",
1413+ )
1414+
1415+ # Make the request
1416+ operation = client.delete_glossary(request=request)
1417+
1418+ print("Waiting for operation to complete...")
1419+
1420+ response = operation.result()
1421+
1422+ # Handle the response
1423+ print(response)
1424+
11791425 Args:
11801426 request (Union[google.cloud.translate_v3.types.DeleteGlossaryRequest, dict]):
11811427 The request object. Request message for DeleteGlossary.
0 commit comments