Skip to content

Commit

Permalink
docs: clarify misleading section in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-jones-dev committed Jan 30, 2024
1 parent f637fae commit 86dc945
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,9 @@ For a detailed explanation of the XML handling options, see the [API documentati

### Translating documents

To translate documents, call `TranslateDocumentAsync()` with the input and output files as either `FileInfo` or `Stream`
To translate documents, call `TranslateDocumentAsync()` with the input and output files as `FileInfo`
objects, and provide the source and target language as above.

Additional `DocumentTranslateOptions` are also available, see [Document translation options](#document-translation-options) below.
Note that file paths are not accepted as strings, to avoid mixing up the file and language arguments.

Expand All @@ -175,6 +176,20 @@ try {
}
```

Alternatively the input and output files may be provided as `Stream` objects; in
that case the input file name (or extension) is required, so the DeepL API can
determine the file type:
```c#
...
await translator.TranslateDocumentAsync(
new MemoryStream(buffer),
"Input file.docx", // An extension like ".docx" is also sufficient
File.OpenWrite(outputDocumentPath),
"EN",
"DE",
new DocumentTranslateOptions { Formality = Formality.More });
```

`TranslateDocumentAsync()` manages the upload, wait until translation is complete, and download steps. If your
application needs to execute these steps individually, you can instead use the following functions directly:

Expand Down

0 comments on commit 86dc945

Please sign in to comment.