Skip to content

Commit c8c3086

Browse files
authored
Merge pull request #202667 from laujan/patch-98
Update get-started-with-document-translation.md
2 parents c1b1ef6 + 644b82f commit c8c3086

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

articles/cognitive-services/Translator/document-translation/get-started-with-document-translation.md

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ manager: nitinme
77
ms.service: cognitive-services
88
ms.subservice: translator-text
99
ms.topic: quickstart
10-
ms.date: 02/02/2022
10+
ms.date: 06/23/2022
1111
ms.author: lajanuar
1212
recommendations: false
1313
ms.devlang: csharp, golang, java, javascript, python
@@ -129,8 +129,8 @@ The following headers are included with each Document Translator API request:
129129

130130
* The POST request URL is POST `https://<NAME-OF-YOUR-RESOURCE>.cognitiveservices.azure.com/translator/text/batch/v1.0/batches`
131131
* The POST request body is a JSON object named `inputs`.
132-
* The `inputs` object contains both `sourceURL` and `targetURL` container addresses for your source and target language pairs
133-
* The `prefix` and `suffix` fields (optional) are used to filter documents in the container including folders.
132+
* The `inputs` object contains both `sourceURL` and `targetURL` container addresses for your source and target language pairs.
133+
* The `prefix` and `suffix` are case-sensitive strings to filter documents in the source path for translation. The `prefix` field is often used to delineate subfolders for translation. The `suffix` field is most often used for file extensions.
134134
* A value for the `glossaries` field (optional) is applied when the document is being translated.
135135
* The `targetUrl` for each target language must be unique.
136136

@@ -196,10 +196,7 @@ The following headers are included with each Document Translator API request:
196196
{
197197
"source": {
198198
"sourceUrl": "https://myblob.blob.core.windows.net/source",
199-
"filter": {
200-
"prefix": "myfolder/"
201-
}
202-
},
199+
},
203200
"targets": [
204201
{
205202
"targetUrl": "https://myblob.blob.core.windows.net/target",
@@ -358,7 +355,7 @@ Operation-Location | https://<<span>NAME-OF-YOUR-RESOURCE>.cognitiveservices.a
358355

359356
private static readonly string key = "<YOUR-KEY>";
360357

361-
static readonly string json = ("{\"inputs\": [{\"source\": {\"sourceUrl\": \"https://YOUR-SOURCE-URL-WITH-READ-LIST-ACCESS-SAS\",\"storageSource\": \"AzureBlob\",\"language\": \"en\",\"filter\":{\"prefix\": \"Demo_1/\"} }, \"targets\": [{\"targetUrl\": \"https://YOUR-TARGET-URL-WITH-WRITE-LIST-ACCESS-SAS\",\"storageSource\": \"AzureBlob\",\"category\": \"general\",\"language\": \"es\"}]}]}");
358+
static readonly string json = ("{\"inputs\": [{\"source\": {\"sourceUrl\": \"https://YOUR-SOURCE-URL-WITH-READ-LIST-ACCESS-SAS\",\"storageSource\": \"AzureBlob\",\"language\": \"en\"}, \"targets\": [{\"targetUrl\": \"https://YOUR-TARGET-URL-WITH-WRITE-LIST-ACCESS-SAS\",\"storageSource\": \"AzureBlob\",\"category\": \"general\",\"language\": \"es\"}]}]}");
362359

363360
static async Task Main(string[] args)
364361
{
@@ -407,9 +404,7 @@ let data = JSON.stringify({"inputs": [
407404
"source": {
408405
"sourceUrl": "https://YOUR-SOURCE-URL-WITH-READ-LIST-ACCESS-SAS",
409406
"storageSource": "AzureBlob",
410-
"language": "en",
411-
"filter":{
412-
"prefix": "Demo_1/"
407+
"language": "en"
413408
}
414409
},
415410
"targets": [
@@ -458,9 +453,7 @@ payload= {
458453
"source": {
459454
"sourceUrl": "https://YOUR-SOURCE-URL-WITH-READ-LIST-ACCESS-SAS",
460455
"storageSource": "AzureBlob",
461-
"language": "en",
462-
"filter":{
463-
"prefix": "Demo_1/"
456+
"language": "en"
464457
}
465458
},
466459
"targets": [
@@ -502,7 +495,7 @@ public class DocumentTranslation {
502495

503496
public void post() throws IOException {
504497
MediaType mediaType = MediaType.parse("application/json");
505-
RequestBody body = RequestBody.create(mediaType, "{\n \"inputs\": [\n {\n \"source\": {\n \"sourceUrl\": \"https://YOUR-SOURCE-URL-WITH-READ-LIST-ACCESS-SAS\",\n \"filter\": {\n \"prefix\": \"Demo_1\"\n },\n \"language\": \"en\",\n \"storageSource\": \"AzureBlob\"\n },\n \"targets\": [\n {\n \"targetUrl\": \"https://YOUR-TARGET-URL-WITH-WRITE-LIST-ACCESS-SAS\",\n \"category\": \"general\",\n\"language\": \"fr\",\n\"storageSource\": \"AzureBlob\"\n }\n ],\n \"storageType\": \"Folder\"\n }\n ]\n}");
498+
RequestBody body = RequestBody.create(mediaType, "{\n \"inputs\": [\n {\n \"source\": {\n \"sourceUrl\": \"https://YOUR-SOURCE-URL-WITH-READ-LIST-ACCESS-SAS\",\n },\n \"language\": \"en\",\n \"storageSource\": \"AzureBlob\"\n },\n \"targets\": [\n {\n \"targetUrl\": \"https://YOUR-TARGET-URL-WITH-WRITE-LIST-ACCESS-SAS\",\n \"category\": \"general\",\n\"language\": \"fr\",\n\"storageSource\": \"AzureBlob\"\n }\n ],\n \"storageType\": \"Folder\"\n }\n ]\n}");
506499
Request request = new Request.Builder()
507500
.url(path).post(body)
508501
.addHeader("Ocp-Apim-Subscription-Key", key)
@@ -542,7 +535,7 @@ key := "<YOUR-KEY>"
542535
uri := endpoint + "/batches"
543536
method := "POST"
544537

545-
var jsonStr = []byte(`{"inputs":[{"source":{"sourceUrl":"https://YOUR-SOURCE-URL-WITH-READ-LIST-ACCESS-SAS","storageSource":"AzureBlob","language":"en","filter":{"prefix":"Demo_1/"}},"targets":[{"targetUrl":"https://YOUR-TARGET-URL-WITH-WRITE-LIST-ACCESS-SAS","storageSource":"AzureBlob","category":"general","language":"es"}]}]}`)
538+
var jsonStr = []byte(`{"inputs":[{"source":{"sourceUrl":"https://YOUR-SOURCE-URL-WITH-READ-LIST-ACCESS-SAS","storageSource":"AzureBlob","language":"en"},"targets":[{"targetUrl":"https://YOUR-TARGET-URL-WITH-WRITE-LIST-ACCESS-SAS","storageSource":"AzureBlob","category":"general","language":"es"}]}]}`)
546539

547540
req, err := http.NewRequest(method, endpoint, bytes.NewBuffer(jsonStr))
548541
req.Header.Add("Ocp-Apim-Subscription-Key", key)

0 commit comments

Comments
 (0)