You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/ai-services/translator/document-translation/quickstarts/includes/sdk/csharp.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ author: laujan
5
5
manager: nitinme
6
6
ms.service: azure-ai-translator
7
7
ms.topic: include
8
-
ms.date: 06/14/2024
8
+
ms.date: 06/17/2024
9
9
ms.author: lajanuar
10
10
recommendations: false
11
11
---
@@ -165,7 +165,7 @@ Here's a snippet of the expected output:
165
165
166
166
## Synchronous translation code sample
167
167
168
-
You can download our [document translation sample document](https://raw.githubusercontent.com/Azure-Samples/cognitive-services-REST-api-samples/master/curl/Translator/document-translation-sample.pdf) for this quickstart. The source language is English.
168
+
You can download our [document translation sample document](https://raw.githubusercontent.com/Azure-Samples/cognitive-services-REST-api-samples/master/curl/Translator/document-translation-sample.docx) for this quickstart. The source language is English.
@@ -363,7 +363,7 @@ Here's a snippet of the expected output:
363
363
364
364
## Synchronous translation code sample
365
365
366
-
You can download our [document translation sample document](https://raw.githubusercontent.com/Azure-Samples/cognitive-services-REST-api-samples/master/curl/Translator/document-translation-sample.pdf) for this quickstart. The source language is English.
366
+
You can download our [document translation sample document](https://raw.githubusercontent.com/Azure-Samples/cognitive-services-REST-api-samples/master/curl/Translator/document-translation-sample.docx) for this quickstart. The source language is English.
1. For this project, you need a **source document** uploaded to your **source container**. You can download our [document translation sample document](https://raw.githubusercontent.com/Azure-Samples/cognitive-services-REST-api-samples/master/curl/Translator/document-translation-sample.pdf) for this quickstart. The source language is English.
30
30
31
31
1. In your Python application file, create variables for your resource key and custom endpoint. For more information, *see*[Retrieve your key and custom domain endpoint](../../../how-to-guides/use-rest-api-programmatically.md#retrieve-your-key-and-custom-domain-endpoint).
32
32
33
33
```python
34
-
key ="<your-key>"
35
-
endpoint ="<your-custom-endpoint>"
36
-
34
+
key ="{your-api-key}"
35
+
endpoint ="{your-document-translation-endpoint}"
36
+
37
37
```
38
38
39
39
1. Initialize a `DocumentTranslationClient` object that contains your `endpoint` and `key` parameters.
@@ -60,7 +60,7 @@ Install the latest version of the Document Translation client library:
60
60
***targetUri** The SAS URI, with a SAS token appended as a query string,for the target container to which the translated documents are written.
61
61
***targetLanguageCode**. The language code for the translated documents. You can find language codes on our [Language support](../../../../language-support.md) page.
62
62
63
-
### Code Sample
63
+
##Asynchronous translation code sample
64
64
65
65
> [!IMPORTANT]
66
66
> Remember to remove the key from your code when you're done, and never post it publicly. For production, use a secure way of storing and accessing your credentials like [Azure Key Vault](../../../../../../key-vault/general/overview.md). For more information, *see* Azure AI services [security](../../../../../../ai-services/security-features.md).
@@ -74,45 +74,45 @@ from azure.core.credentials import AzureKeyCredential
74
74
from azure.ai.translation.document import DocumentTranslationClient
75
75
76
76
# create variables for your resource key, custom endpoint, sourceUrl, targetUrl, and targetLanguage
77
-
key ="<your-key>"
78
-
endpoint ="<your-custom-endpoint>"
79
-
sourceUri ="<your-container-sourceUrl>"
80
-
targetUri ="<your-container-targetUrl>"
81
-
targetLanguage ="<target-language-code>"
77
+
key ='{your-api-key}'
78
+
endpoint ='{your-document-translation-endpoint}'
79
+
sourceUri ='<your-container-sourceUrl>'
80
+
targetUri ='<your-container-targetUrl>'
81
+
targetLanguage ='<target-language-code>'
82
82
83
83
84
-
# initialize a new instance of the DocumentTranslationClient object to interact with the Document Translation feature
84
+
# initialize a new instance of the DocumentTranslationClient object to interact with the asynchronous Document Translation feature
print("Translated to language: {}\n".format(document.translated_to))
112
+
print('Translated to language: {}\n'.format(document.translated_to))
113
113
else:
114
114
print(
115
-
"Error Code: {}, Message: {}\n".format(
115
+
'Error Code: {}, Message: {}\n'.format(
116
116
document.error.code, document.error.message
117
117
)
118
118
)
@@ -130,4 +130,52 @@ Here's a snippet of the expected output:
130
130
131
131
:::image type="content" source="../../../../media/quickstarts/python-output-document.png" alt-text="Screenshot of the Python output in the terminal window. ":::
132
132
133
-
That's it! You just created a program to translate documents in a storage container using the Python client library.
133
+
## Synchronous translation code sample
134
+
135
+
You can download our [document translation sample document](https://raw.githubusercontent.com/Azure-Samples/cognitive-services-REST-api-samples/master/curl/Translator/document-translation-sample.docx) for this quickstart. The source language is English.
136
+
137
+
```python
138
+
import os
139
+
from azure.core.credentials import AzureKeyCredential
140
+
from azure.ai.translation.document import SingleDocumentTranslationClient
141
+
from azure.ai.translation.document.models import DocumentTranslateContent
142
+
143
+
144
+
defsample_single_document_translation():
145
+
146
+
# create variables for your resource api key, document translation endpoint, and target language
147
+
key ="<your-api-key>"
148
+
endpoint ="<your-document-translation-endpoint>"
149
+
target_language ="{target-language-code}"
150
+
151
+
# initialize a new instance of the SingleDocumentTranslationClient object to interact with the synchronous Document Translation feature
0 commit comments