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

Translating HTML with English text to French adds HTML Tags and full sentence that is not in the input text #42

Open
wilhelmberghammer opened this issue Mar 9, 2024 · 1 comment

Comments

@wilhelmberghammer
Copy link

Describe the bug
When translating a English text with HTML elements to French, the response contains unexpected additional HTML Tags and often a full sentence that was not in the input.

To Reproduce
Minimal JS Script to reproduce the Error (last tested on March 9th 2024 6PM CET)

const deepl = require('deepl-node')
const authKey = "<authkey>"
const translator = new deepl.Translator(authKey)

async function translate(targetLang) {
	const result = await translator.translateText('<p><strong>Testing the system</strong></p>', 'en', targetLang, tag_handling = 'html')
	console.log(result)
}

translate('de')
translate('fr')

This results in the following responses:

{
  text: '<p><strong>Test des Systems</strong></p>',
  detectedSourceLang: 'en'
}
{
  text: "</p><strong>Tester le système</strong></p><strong></p><strong>La mise en place d'un système de gestion de l'information est une priorité.",
  detectedSourceLang: 'en'
}

The German translation is correct but the French translation has <strong></p><strong>La mise en place d'un système de gestion de l'information est une priorité. appended to a seemingly correct result.

I've noticed that without the <strong> Tag it does not happen but I have not tested that exhaustively.

Thank you very much.

@wilhelmberghammer wilhelmberghammer changed the title Translating HTML with English text to Frech adds HTML Tags and full sentence that is not in the input text Translating HTML with English text to French adds HTML Tags and full sentence that is not in the input text Mar 9, 2024
@macleanweb
Copy link

@wilhelmberghammer I think your syntax is a bit off from the documentation. Try this, where tag_handling is converted to camelCase and passed inside of an "options" object.

const result = await translator.translateText(
  '<p><strong>Testing the system</strong></p>', 
  'en',
  targetLang, 
  {tagHandling: 'html'}
);

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

2 participants