From b164625289ea75dac8be2ee39a5fe1b6296c8e39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Rosenthal-Buroh?= <22403655+JuergenRB@users.noreply.github.com> Date: Wed, 10 Apr 2024 09:49:39 +0200 Subject: [PATCH] feat: Add OutputFormat Add OutputFormat to DocumentTranslateOptions --- DeepL/DocumentTranslateOptions.cs | 3 +++ DeepL/Translator.cs | 4 ++++ README.md | 3 +++ 3 files changed, 10 insertions(+) diff --git a/DeepL/DocumentTranslateOptions.cs b/DeepL/DocumentTranslateOptions.cs index d24101e..273cef2 100644 --- a/DeepL/DocumentTranslateOptions.cs +++ b/DeepL/DocumentTranslateOptions.cs @@ -26,5 +26,8 @@ public DocumentTranslateOptions(GlossaryInfo glossary) : this() { /// Specifies the ID of a glossary to use with the translation. public string? GlossaryId { get; set; } + + /// 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. + public string? OutputFormat { get; set; } } } diff --git a/DeepL/Translator.cs b/DeepL/Translator.cs index f609193..a501336 100644 --- a/DeepL/Translator.cs +++ b/DeepL/Translator.cs @@ -629,6 +629,10 @@ public async Task TranslateDocumentUploadAsync( options?.Formality, options?.GlossaryId); + if (options?.OutputFormat != null) { + bodyParams.Add(("output_format", options?.OutputFormat!)); + } + using var responseMessage = await _client.ApiUploadAsync( "/v2/document", cancellationToken, diff --git a/README.md b/README.md index dea989d..f0ec0ce 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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