Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-47 feat: Add OutputFormat #50

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions DeepL/DocumentTranslateOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,8 @@ public DocumentTranslateOptions(GlossaryInfo glossary) : this() {

/// <summary>Specifies the ID of a glossary to use with the translation.</summary>
public string? GlossaryId { get; set; }

/// <summary>File extension of desired format of translated file, for example: docx. If unspecified, by default the translated file will be in the same format as the input file.</summary>
public string? OutputFormat { get; set; }
}
}
4 changes: 4 additions & 0 deletions DeepL/Translator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,10 @@ public async Task<DocumentHandle> TranslateDocumentUploadAsync(
options?.Formality,
options?.GlossaryId);

if (options?.OutputFormat != null) {
bodyParams.Add(("output_format", options?.OutputFormat!));
}

using var responseMessage = await _client.ApiUploadAsync(
"/v2/document",
cancellationToken,
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ application needs to execute these steps individually, you can instead use the f

- `Formality`: same as in [Text translation options](#text-translation-options).
- `GlossaryId`: same as in [Text translation options](#text-translation-options).
- `OutputFormat`: using the parameter during document upload, you can select alternative output formats. See the [API documentation][api-docs-outputformat-param] for more information and example usage.

### Glossaries

Expand Down Expand Up @@ -467,6 +468,8 @@ terminal while executing the tests. Execute the tests using `dotnet test` with t

[api-docs-glossary-lang-list]: https://www.deepl.com/docs-api/managing-glossaries/?utm_source=github&utm_medium=github-dotnet-readme

[api-docs-outputformat-param]: https://www.deepl.com/docs-api/documents/format-conversions/?utm_source=github&utm_medium=github-dotnet-readme

[api-docs-xml-handling]: https://www.deepl.com/docs-api/handling-xml/?utm_source=github&utm_medium=github-dotnet-readme

[issues]: https://www.github.com/DeepLcom/deepl-dotnet/issues