Skip to content

Commit b43221f

Browse files
a-noyassnsalem95
andauthored
Document translation renames (Azure#19787)
* [documenttranslation] rename details to result and configuration to input * [documenttranslation] general renames * [documenttranslation] update Azure.AI.DocumentTranslation.netstandard2.0.cs * [documenttranslation] reaname sample file Co-authored-by: NourEldin Yasser <noursalem95@gmail.com>
1 parent 23664d2 commit b43221f

40 files changed

+361
-355
lines changed

sdk/documenttranslation/Azure.AI.DocumentTranslation/README.md

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ A `DocumentTranslationClient` is the primary interface for developers using the
8989
- Identifying supported glossary and document formats.
9090

9191
### Translation Input
92-
To start a translation operation you need to create one instance or a list of `DocumentTranslationConfiguration`.
92+
To start a translation operation you need to create one instance or a list of `DocumentTranslationInput`.
9393

9494
A single source URL to documents can be translated to many different languages:
9595

@@ -99,7 +99,7 @@ Uri frenchTargetSasUri = <french target SAS URI>;
9999
Uri arabicTargetSasUri = <arabic target SAS URI>;
100100
Uri spanishTargetSasUri = <spanish target SAS URI>;
101101

102-
var input = new TranslationConfiguration(sourceSasUri, frenchTargetSasUri, "fr");
102+
var input = new DocumentTranslationInput(sourceSasUri, frenchTargetSasUri, "fr");
103103
input.AddTarget(arabicTargetSasUri, "ar");
104104
input.AddTarget(spanishTargetSasUri, "es");
105105
```
@@ -110,10 +110,10 @@ Or multiple different sources can be provided each with their own targets.
110110
Uri source1SasUri = <source1 SAS URI>;
111111
Uri source2SasUri = <source2 SAS URI>;
112112

113-
var inputs = new List<TranslationConfiguration>
113+
var inputs = new List<DocumentTranslationInput>
114114
{
115-
new TranslationConfiguration(source1SasUri, spanishTargetSasUri, "es"),
116-
new TranslationConfiguration(
115+
new DocumentTranslationInput(source1SasUri, spanishTargetSasUri, "es"),
116+
new DocumentTranslationInput(
117117
source: new TranslationSource(source2SasUri),
118118
targets: new List<TranslationTarget>
119119
{
@@ -152,12 +152,12 @@ Note: our `DocumentTranslationClient` provides both synchronous and asynchronous
152152
### Async Examples
153153
* [Start Translation Asynchronously](#start-translation-asynchronously)
154154
* [Operations History Asynchronously](#get-operations-history-asynchronously)
155-
* [Multiple Configurations Asynchronously](#start-translation-with-multiple-configurations-asynchronously)
155+
* [Multiple Inputs Asynchronously](#start-translation-with-multiple-inputs-asynchronously)
156156

157157
### Sync Examples
158158
* [Start Translation](#start-translation)
159159
* [Operations History](#get-operations-history)
160-
* [Multiple Configurations](#start-translation-with-multiple-configurations)
160+
* [Multiple Inputs](#start-translation-with-multiple-inputs)
161161

162162
### Start Translation
163163
Start a translation operation to translate documents in the source container and write the translated files to the target container. `DocumentTranslationOperation` allows you to poll the status of the translation operation and get the status of the individual documents.
@@ -166,7 +166,7 @@ Start a translation operation to translate documents in the source container and
166166
Uri sourceUri = <source SAS URI>;
167167
Uri targetUri = <target SAS URI>;
168168

169-
var input = new TranslationConfiguration(sourceUri, targetUri, "es");
169+
var input = new DocumentTranslationInput(sourceUri, targetUri, "es");
170170

171171
DocumentTranslationOperation operation = client.StartTranslation(input);
172172

@@ -187,13 +187,13 @@ while (!operation.HasCompleted)
187187
Console.WriteLine($" Not started: {operation.DocumentsNotStarted}");
188188
}
189189

190-
foreach (DocumentStatusDetail document in operation.GetValues())
190+
foreach (DocumentStatusResult document in operation.GetValues())
191191
{
192192
Console.WriteLine($"Document with Id: {document.DocumentId}");
193193
Console.WriteLine($" Status:{document.Status}");
194194
if (document.Status == TranslationStatus.Succeeded)
195195
{
196-
Console.WriteLine($" Location: {document.LocationUri}");
196+
Console.WriteLine($" URI: {document.TranslatedDocumentUri}");
197197
Console.WriteLine($" Translated to language: {document.TranslateTo}.");
198198
}
199199
else
@@ -216,7 +216,7 @@ int docsFailed = 0;
216216

217217
TimeSpan pollingInterval = new TimeSpan(1000);
218218

219-
foreach (TranslationStatusDetail translationStatus in client.GetTranslations())
219+
foreach (TranslationStatusResult translationStatus in client.GetTranslations())
220220
{
221221
if (!translationStatus.HasCompleted)
222222
{
@@ -243,27 +243,27 @@ Console.WriteLine($"Failed Document: {docsFailed}");
243243
Console.WriteLine($"Cancelled Documents: {docsCancelled}");
244244
```
245245

246-
### Start Translation with Multiple Configurations
246+
### Start Translation with Multiple Inputs
247247
Start a translation operation to translate documents in multiple source containers to multiple target containers in different languages. `DocumentTranslationOperation` allows you to poll the status of the translation operation and get the status of the individual documents.
248248

249-
```C# Snippet:MultipleConfigurations
249+
```C# Snippet:MultipleInputs
250250
Uri source1SasUriUri = <source1 SAS URI>;
251251
Uri source2SasUri = <source2 SAS URI>;
252252
Uri frenchTargetSasUri = <french target SAS URI>;
253253
Uri arabicTargetSasUri = <arabic target SAS URI>;
254254
Uri spanishTargetSasUri = <spanish target SAS URI>;
255255
Uri frenchGlossarySasUri = <french glossary SAS URI>;
256256

257-
var configuration1 = new TranslationConfiguration(source1SasUriUri, frenchTargetSasUri, "fr", new TranslationGlossary(frenchGlossarySasUri));
258-
configuration1.AddTarget(spanishTargetSasUri, "es");
257+
var input1 = new DocumentTranslationInput(source1SasUriUri, frenchTargetSasUri, "fr", new TranslationGlossary(frenchGlossarySasUri));
258+
input1.AddTarget(spanishTargetSasUri, "es");
259259

260-
var configuration2 = new TranslationConfiguration(source2SasUri, arabicTargetSasUri, "ar");
261-
configuration2.AddTarget(frenchTargetSasUri, "fr", new TranslationGlossary(frenchGlossarySasUri));
260+
var input2 = new DocumentTranslationInput(source2SasUri, arabicTargetSasUri, "ar");
261+
input2.AddTarget(frenchTargetSasUri, "fr", new TranslationGlossary(frenchGlossarySasUri));
262262

263-
var inputs = new List<TranslationConfiguration>()
263+
var inputs = new List<DocumentTranslationInput>()
264264
{
265-
configuration1,
266-
configuration2
265+
input1,
266+
input2
267267
};
268268

269269
DocumentTranslationOperation operation = client.StartTranslation(inputs);
@@ -285,13 +285,13 @@ while (!operation.HasCompleted)
285285
Console.WriteLine($" Not started: {operation.DocumentsNotStarted}");
286286
}
287287

288-
foreach (DocumentStatusDetail document in operation.GetValues())
288+
foreach (DocumentStatusResult document in operation.GetValues())
289289
{
290290
Console.WriteLine($"Document with Id: {document.DocumentId}");
291291
Console.WriteLine($" Status:{document.Status}");
292292
if (document.Status == TranslationStatus.Succeeded)
293293
{
294-
Console.WriteLine($" Location: {document.LocationUri}");
294+
Console.WriteLine($" URI: {document.TranslatedDocumentUri}");
295295
Console.WriteLine($" Translated to language: {document.TranslateTo}.");
296296
}
297297
else
@@ -309,11 +309,11 @@ Start a translation operation to translate documents in the source container and
309309
Uri sourceUri = <source SAS URI>;
310310
Uri targetUri = <target SAS URI>;
311311

312-
var input = new TranslationConfiguration(sourceUri, targetUri, "es");
312+
var input = new DocumentTranslationInput(sourceUri, targetUri, "es");
313313

314314
DocumentTranslationOperation operation = await client.StartTranslationAsync(input);
315315

316-
Response<AsyncPageable<DocumentStatusDetail>> operationResult = await operation.WaitForCompletionAsync();
316+
Response<AsyncPageable<DocumentStatusResult>> operationResult = await operation.WaitForCompletionAsync();
317317

318318
Console.WriteLine($" Status: {operation.Status}");
319319
Console.WriteLine($" Created on: {operation.CreatedOn}");
@@ -324,13 +324,13 @@ Console.WriteLine($" Failed: {operation.DocumentsFailed}");
324324
Console.WriteLine($" In Progress: {operation.DocumentsInProgress}");
325325
Console.WriteLine($" Not started: {operation.DocumentsNotStarted}");
326326

327-
await foreach (DocumentStatusDetail document in operationResult.Value)
327+
await foreach (DocumentStatusResult document in operationResult.Value)
328328
{
329329
Console.WriteLine($"Document with Id: {document.DocumentId}");
330330
Console.WriteLine($" Status:{document.Status}");
331331
if (document.Status == TranslationStatus.Succeeded)
332332
{
333-
Console.WriteLine($" Location: {document.LocationUri}");
333+
Console.WriteLine($" URI: {document.TranslatedDocumentUri}");
334334
Console.WriteLine($" Translated to language: {document.TranslateTo}.");
335335
}
336336
else
@@ -351,7 +351,7 @@ int docsCancelled = 0;
351351
int docsSucceeded = 0;
352352
int docsFailed = 0;
353353

354-
await foreach (TranslationStatusDetail translationStatus in client.GetTranslationsAsync())
354+
await foreach (TranslationStatusResult translationStatus in client.GetTranslationsAsync())
355355
{
356356
if (!translationStatus.HasCompleted)
357357
{
@@ -373,27 +373,27 @@ Console.WriteLine($"Failed Document: {docsFailed}");
373373
Console.WriteLine($"Cancelled Documents: {docsCancelled}");
374374
```
375375

376-
### Start Translation with Multiple Configurations Asynchronously
376+
### Start Translation with Multiple Inputs Asynchronously
377377
Start a translation operation to translate documents in multiple source containers to multiple target containers in different languages. `DocumentTranslationOperation` allows you to poll the status of the translation operation and get the status of the individual documents.
378378

379-
```C# Snippet:MultipleConfigurationsAsync
379+
```C# Snippet:MultipleInputsAsync
380380
Uri source1SasUriUri = <source1 SAS URI>;
381381
Uri source2SasUri = <source2 SAS URI>;
382382
Uri frenchTargetSasUri = <french target SAS URI>;
383383
Uri arabicTargetSasUri = <arabic target SAS URI>;
384384
Uri spanishTargetSasUri = <spanish target SAS URI>;
385385
Uri frenchGlossarySasUri = <french glossary SAS URI>;
386386

387-
var configuration1 = new TranslationConfiguration(source1SasUriUri, frenchTargetSasUri, "fr", new TranslationGlossary(frenchGlossarySasUri));
388-
configuration1.AddTarget(spanishTargetSasUri, "es");
387+
var input1 = new DocumentTranslationInput(source1SasUriUri, frenchTargetSasUri, "fr", new TranslationGlossary(frenchGlossarySasUri));
388+
input1.AddTarget(spanishTargetSasUri, "es");
389389

390-
var configuration2 = new TranslationConfiguration(source2SasUri, arabicTargetSasUri, "ar");
391-
configuration2.AddTarget(frenchTargetSasUri, "fr", new TranslationGlossary(frenchGlossarySasUri));
390+
var input2 = new DocumentTranslationInput(source2SasUri, arabicTargetSasUri, "ar");
391+
input2.AddTarget(frenchTargetSasUri, "fr", new TranslationGlossary(frenchGlossarySasUri));
392392

393-
var inputs = new List<TranslationConfiguration>()
393+
var inputs = new List<DocumentTranslationInput>()
394394
{
395-
configuration1,
396-
configuration2
395+
input1,
396+
input2
397397
};
398398

399399
DocumentTranslationOperation operation = await client.StartTranslationAsync(inputs);
@@ -415,13 +415,13 @@ while (!operation.HasCompleted)
415415
Console.WriteLine($" Not started: {operation.DocumentsNotStarted}");
416416
}
417417

418-
await foreach (DocumentStatusDetail document in operation.GetValuesAsync())
418+
await foreach (DocumentStatusResult document in operation.GetValuesAsync())
419419
{
420420
Console.WriteLine($"Document with Id: {document.DocumentId}");
421421
Console.WriteLine($" Status:{document.Status}");
422422
if (document.Status == TranslationStatus.Succeeded)
423423
{
424-
Console.WriteLine($" Location: {document.LocationUri}");
424+
Console.WriteLine($" URI: {document.TranslatedDocumentUri}");
425425
Console.WriteLine($" Translated to language: {document.TranslateTo}.");
426426
}
427427
else
@@ -440,11 +440,11 @@ When you interact with the Cognitive Services Document Translation client librar
440440
For example, if you submit a request with an empty targets list, a `400` error is returned, indicating "Bad Request".
441441

442442
```C# Snippet:BadRequest
443-
var invalidConfiguration = new TranslationConfiguration(new TranslationSource(sourceSasUri, new List<TranslationTarget>());
443+
var invalidInput = new DocumentTranslationInput(new TranslationSource(sourceSasUri, new List<TranslationTarget>());
444444

445445
try
446446
{
447-
DocumentTranslationOperation operation = client.StartTranslation(invalidConfiguration);
447+
DocumentTranslationOperation operation = client.StartTranslation(invalidInput);
448448
}
449449
catch (RequestFailedException e)
450450
{
@@ -494,7 +494,7 @@ Samples showing how to use the Cognitive Services Document Translation library a
494494
- [Operations History][operations_history_sample]
495495

496496
### Advanced samples
497-
- [Multiple Configurations][multiple_configurations_sample]
497+
- [Multiple Inputs][multiple_Inputs_sample]
498498

499499
## Contributing
500500
See the [CONTRIBUTING.md][contributing] for details on building, testing, and contributing to this library.
@@ -535,7 +535,7 @@ This project has adopted the [Microsoft Open Source Code of Conduct][code_of_con
535535
[start_translation_sample]: https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/documenttranslation/Azure.AI.DocumentTranslation/samples/Sample1_StartTranslation.md
536536
[documents_status_sample]: https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/documenttranslation/Azure.AI.DocumentTranslation/samples/Sample2_PollIndividualDocuments.md
537537
[operations_history_sample]: https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/documenttranslation/Azure.AI.DocumentTranslation/samples/Sample3_OperationsHistory.md
538-
[multiple_configurations_sample]: https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/documenttranslation/Azure.AI.DocumentTranslation/samples/Sample4_MultipleConfigurations.md
538+
[multiple_inputs_sample]: https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/documenttranslation/Azure.AI.DocumentTranslation/samples/Sample4_MultipleInputs.md
539539
540540
[azure_cli]: https://docs.microsoft.com/cli/azure
541541
[azure_sub]: https://azure.microsoft.com/free/

0 commit comments

Comments
 (0)