| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 2cb6c2c commit 29f8066
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -226,9 +226,9 @@ async def translate_text( | |||
| 226 | 226 | ||
| 227 | 227 | from google.cloud import translate_v3 | |
| 228 | 228 | ||
| 229 | - def sample_translate_text(): | ||
| 229 | + async def sample_translate_text(): | ||
| 230 | 230 | # Create a client | |
| 231 | - client = translate_v3.TranslationServiceClient() | ||
| 231 | + client = translate_v3.TranslationServiceAsyncClient() | ||
| 232 | 232 | ||
| 233 | 233 | # Initialize request argument(s) | |
| 234 | 234 | request = translate_v3.TranslateTextRequest( | |
@@ -238,7 +238,7 @@ def sample_translate_text(): | |||
| 238 | 238 | ) | |
| 239 | 239 | ||
| 240 | 240 | # Make the request | |
| 241 | - response = client.translate_text(request=request) | ||
| 241 | + response = await client.translate_text(request=request) | ||
| 242 | 242 | ||
| 243 | 243 | # Handle the response | |
| 244 | 244 | print(response) | |
@@ -420,9 +420,9 @@ async def detect_language( | |||
| 420 | 420 | ||
| 421 | 421 | from google.cloud import translate_v3 | |
| 422 | 422 | ||
| 423 | - def sample_detect_language(): | ||
| 423 | + async def sample_detect_language(): | ||
| 424 | 424 | # Create a client | |
| 425 | - client = translate_v3.TranslationServiceClient() | ||
| 425 | + client = translate_v3.TranslationServiceAsyncClient() | ||
| 426 | 426 | ||
| 427 | 427 | # Initialize request argument(s) | |
| 428 | 428 | request = translate_v3.DetectLanguageRequest( | |
@@ -431,7 +431,7 @@ def sample_detect_language(): | |||
| 431 | 431 | ) | |
| 432 | 432 | ||
| 433 | 433 | # Make the request | |
| 434 | - response = client.detect_language(request=request) | ||
| 434 | + response = await client.detect_language(request=request) | ||
| 435 | 435 | ||
| 436 | 436 | # Handle the response | |
| 437 | 437 | print(response) | |
@@ -568,17 +568,17 @@ async def get_supported_languages( | |||
| 568 | 568 | ||
| 569 | 569 | from google.cloud import translate_v3 | |
| 570 | 570 | ||
| 571 | - def sample_get_supported_languages(): | ||
| 571 | + async def sample_get_supported_languages(): | ||
| 572 | 572 | # Create a client | |
| 573 | - client = translate_v3.TranslationServiceClient() | ||
| 573 | + client = translate_v3.TranslationServiceAsyncClient() | ||
| 574 | 574 | ||
| 575 | 575 | # Initialize request argument(s) | |
| 576 | 576 | request = translate_v3.GetSupportedLanguagesRequest( | |
| 577 | 577 | parent="parent_value", | |
| 578 | 578 | ) | |
| 579 | 579 | ||
| 580 | 580 | # Make the request | |
| 581 | - response = client.get_supported_languages(request=request) | ||
| 581 | + response = await client.get_supported_languages(request=request) | ||
| 582 | 582 | ||
| 583 | 583 | # Handle the response | |
| 584 | 584 | print(response) | |
@@ -717,9 +717,9 @@ async def translate_document( | |||
| 717 | 717 | ||
| 718 | 718 | from google.cloud import translate_v3 | |
| 719 | 719 | ||
| 720 | - def sample_translate_document(): | ||
| 720 | + async def sample_translate_document(): | ||
| 721 | 721 | # Create a client | |
| 722 | - client = translate_v3.TranslationServiceClient() | ||
| 722 | + client = translate_v3.TranslationServiceAsyncClient() | ||
| 723 | 723 | ||
| 724 | 724 | # Initialize request argument(s) | |
| 725 | 725 | document_input_config = translate_v3.DocumentInputConfig() | |
@@ -732,7 +732,7 @@ def sample_translate_document(): | |||
| 732 | 732 | ) | |
| 733 | 733 | ||
| 734 | 734 | # Make the request | |
| 735 | - response = client.translate_document(request=request) | ||
| 735 | + response = await client.translate_document(request=request) | ||
| 736 | 736 | ||
| 737 | 737 | # Handle the response | |
| 738 | 738 | print(response) | |
@@ -802,9 +802,9 @@ async def batch_translate_text( | |||
| 802 | 802 | ||
| 803 | 803 | from google.cloud import translate_v3 | |
| 804 | 804 | ||
| 805 | - def sample_batch_translate_text(): | ||
| 805 | + async def sample_batch_translate_text(): | ||
| 806 | 806 | # Create a client | |
| 807 | - client = translate_v3.TranslationServiceClient() | ||
| 807 | + client = translate_v3.TranslationServiceAsyncClient() | ||
| 808 | 808 | ||
| 809 | 809 | # Initialize request argument(s) | |
| 810 | 810 | input_configs = translate_v3.InputConfig() | |
@@ -826,7 +826,7 @@ def sample_batch_translate_text(): | |||
| 826 | 826 | ||
| 827 | 827 | print("Waiting for operation to complete...") | |
| 828 | 828 | ||
| 829 | - response = operation.result() | ||
| 829 | + response = await operation.result() | ||
| 830 | 830 | ||
| 831 | 831 | # Handle the response | |
| 832 | 832 | print(response) | |
@@ -913,9 +913,9 @@ async def batch_translate_document( | |||
| 913 | 913 | ||
| 914 | 914 | from google.cloud import translate_v3 | |
| 915 | 915 | ||
| 916 | - def sample_batch_translate_document(): | ||
| 916 | + async def sample_batch_translate_document(): | ||
| 917 | 917 | # Create a client | |
| 918 | - client = translate_v3.TranslationServiceClient() | ||
| 918 | + client = translate_v3.TranslationServiceAsyncClient() | ||
| 919 | 919 | ||
| 920 | 920 | # Initialize request argument(s) | |
| 921 | 921 | input_configs = translate_v3.BatchDocumentInputConfig() | |
@@ -937,7 +937,7 @@ def sample_batch_translate_document(): | |||
| 937 | 937 | ||
| 938 | 938 | print("Waiting for operation to complete...") | |
| 939 | 939 | ||
| 940 | - response = operation.result() | ||
| 940 | + response = await operation.result() | ||
| 941 | 941 | ||
| 942 | 942 | # Handle the response | |
| 943 | 943 | print(response) | |
@@ -1101,9 +1101,9 @@ async def create_glossary( | |||
| 1101 | 1101 | ||
| 1102 | 1102 | from google.cloud import translate_v3 | |
| 1103 | 1103 | ||
| 1104 | - def sample_create_glossary(): | ||
| 1104 | + async def sample_create_glossary(): | ||
| 1105 | 1105 | # Create a client | |
| 1106 | - client = translate_v3.TranslationServiceClient() | ||
| 1106 | + client = translate_v3.TranslationServiceAsyncClient() | ||
| 1107 | 1107 | ||
| 1108 | 1108 | # Initialize request argument(s) | |
| 1109 | 1109 | glossary = translate_v3.Glossary() | |
@@ -1119,7 +1119,7 @@ def sample_create_glossary(): | |||
| 1119 | 1119 | ||
| 1120 | 1120 | print("Waiting for operation to complete...") | |
| 1121 | 1121 | ||
| 1122 | - response = operation.result() | ||
| 1122 | + response = await operation.result() | ||
| 1123 | 1123 | ||
| 1124 | 1124 | # Handle the response | |
| 1125 | 1125 | print(response) | |
@@ -1220,9 +1220,9 @@ async def list_glossaries( | |||
| 1220 | 1220 | ||
| 1221 | 1221 | from google.cloud import translate_v3 | |
| 1222 | 1222 | ||
| 1223 | - def sample_list_glossaries(): | ||
| 1223 | + async def sample_list_glossaries(): | ||
| 1224 | 1224 | # Create a client | |
| 1225 | - client = translate_v3.TranslationServiceClient() | ||
| 1225 | + client = translate_v3.TranslationServiceAsyncClient() | ||
| 1226 | 1226 | ||
| 1227 | 1227 | # Initialize request argument(s) | |
| 1228 | 1228 | request = translate_v3.ListGlossariesRequest( | |
@@ -1233,7 +1233,7 @@ def sample_list_glossaries(): | |||
| 1233 | 1233 | page_result = client.list_glossaries(request=request) | |
| 1234 | 1234 | ||
| 1235 | 1235 | # Handle the response | |
| 1236 | - for response in page_result: | ||
| 1236 | + async for response in page_result: | ||
| 1237 | 1237 | print(response) | |
| 1238 | 1238 | ||
| 1239 | 1239 | Args: | |
@@ -1338,17 +1338,17 @@ async def get_glossary( | |||
| 1338 | 1338 | ||
| 1339 | 1339 | from google.cloud import translate_v3 | |
| 1340 | 1340 | ||
| 1341 | - def sample_get_glossary(): | ||
| 1341 | + async def sample_get_glossary(): | ||
| 1342 | 1342 | # Create a client | |
| 1343 | - client = translate_v3.TranslationServiceClient() | ||
| 1343 | + client = translate_v3.TranslationServiceAsyncClient() | ||
| 1344 | 1344 | ||
| 1345 | 1345 | # Initialize request argument(s) | |
| 1346 | 1346 | request = translate_v3.GetGlossaryRequest( | |
| 1347 | 1347 | name="name_value", | |
| 1348 | 1348 | ) | |
| 1349 | 1349 | ||
| 1350 | 1350 | # Make the request | |
| 1351 | - response = client.get_glossary(request=request) | ||
| 1351 | + response = await client.get_glossary(request=request) | ||
| 1352 | 1352 | ||
| 1353 | 1353 | # Handle the response | |
| 1354 | 1354 | print(response) | |
@@ -1444,9 +1444,9 @@ async def delete_glossary( | |||
| 1444 | 1444 | ||
| 1445 | 1445 | from google.cloud import translate_v3 | |
| 1446 | 1446 | ||
| 1447 | - def sample_delete_glossary(): | ||
| 1447 | + async def sample_delete_glossary(): | ||
| 1448 | 1448 | # Create a client | |
| 1449 | - client = translate_v3.TranslationServiceClient() | ||
| 1449 | + client = translate_v3.TranslationServiceAsyncClient() | ||
| 1450 | 1450 | ||
| 1451 | 1451 | # Initialize request argument(s) | |
| 1452 | 1452 | request = translate_v3.DeleteGlossaryRequest( | |
@@ -1458,7 +1458,7 @@ def sample_delete_glossary(): | |||
| 1458 | 1458 | ||
| 1459 | 1459 | print("Waiting for operation to complete...") | |
| 1460 | 1460 | ||
| 1461 | - response = operation.result() | ||
| 1461 | + response = await operation.result() | ||
| 1462 | 1462 | ||
| 1463 | 1463 | # Handle the response | |
| 1464 | 1464 | print(response) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments