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

Add support for output_format, code included #47

Open
machj opened this issue Mar 18, 2024 · 1 comment
Open

Add support for output_format, code included #47

machj opened this issue Mar 18, 2024 · 1 comment
Assignees

Comments

@machj
Copy link

machj commented Mar 18, 2024

Describe the bug
The new version of the API https://www.deepl.com/cs/docs-api/documents/translate-document includes support for the optional output_format parameter, but there is no implementation in deepl-dotnet.

To Reproduce
var options = new DocumentTranslateOptions();
options.OutputFormat = "docx";

Expected behavior
DocumentTranslateOptions have an OutputFormat parameter, I can set it to "docx" to change PDF to Word during translation.

Screenshots or sample code
Expected final code:

var translator = new Translator(ServiceApiKey);
var options = new DocumentTranslateOptions();
options.OutputFormat = "docx";
var handle = await translator.TranslateDocumentUploadAsync(filepath, sourceLanguage, targetLanguage, options);

Files to change:

DeepL/DocumentTranslateOptions.cs

    /// <summary>File extension of desired format of translated file, for example: docx.</summary>
    /// If unspecified, by default the translated file will be in the same format as the input file.
    public string? OutputFormat { get; set; }

DeepL/Translator.cs

/// <inheritdoc />
public async Task<DocumentHandle> TranslateDocumentUploadAsync(
      Stream inputFile,
      string inputFileName,
      string? sourceLanguageCode,
      string targetLanguageCode,
      DocumentTranslateOptions? options = null,
      CancellationToken cancellationToken = default) {
  var bodyParams = CreateCommonHttpParams(
        sourceLanguageCode,
        targetLanguageCode,
        options?.Formality,
        options?.GlossaryId);

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

  using var responseMessage =  
(...)
@JuergenRB
Copy link

@daniel-jones-dev May I ask what the status is and if you have any feedback on the change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants