Skip to content

Array translations returned as single result with concatenated string #67

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

Closed
krisloekkegaard opened this issue Mar 19, 2025 · 1 comment

Comments

@krisloekkegaard
Copy link

Describe the bug
When submitting an array of strings for translation, I am getting a single TextResult object back, whose text field is a concatenation of all the translations, comma-separated.

The documentation states that a list of TextResult objects should be returned, and this is also the behavior I used to see. I didn't update anything in our code nor update the version of the deepl-node package.

To Reproduce
Steps to reproduce the behavior:

import * as deepl from 'deepl-node';

const translator = new deepl.Translator('***');
const targetLang: deepl.TargetLanguageCode = 'fr';
const results = await translator.translateText(['Hello, world!', 'How are you?'], null, targetLang);
console.log(results);

The output I'm seeing currently is:

[
  {
    text: 'Bonjour le monde, comment allez-vous ?',
    detectedSourceLang: 'en',
    billedCharacters: 26,
    modelTypeUsed: undefined
  }
]

Expected behavior
The result should be an array of TextResult objects, each containing the translated text of the corresponding string from the input array.

The output I was expecting (and was previously getting) is:

[
  {
    text: 'Bonjour le monde',
    detectedSourceLang: 'en',
    ...
  },
  {
    text: 'Comment allez-vous ?',
    detectedSourceLang: 'en',
    ...
  }
]
@krisloekkegaard
Copy link
Author

Closing as I believe this is a duplicate of #66

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

No branches or pull requests

1 participant