DeepLcom/deepl-api-issues

The translated text omits the right single straight quotation mark (')

jorge-campo opened this issue · 2 comments

Problem description

When using the DeepL API via Python, the translated text omits the right single quotation mark for words between single quotes. For example, the original EN text:

revision: '1'

Gets translated into ES in the following way:

revisión: '1

More information

  • The glossary doesn't include any single quote or quoted term.
  • The translation is not affected.
  • The problem appears for straight single quotes.

Here is an example taken from a document YAML front matter:

Original (EN):

---
id: 397
revision: '1'
language: en
title: Delete your Status Community
---

Translation (ES):

---
id: 397
revision: '1
language: es
title: Borrar tu Comunidad de Status
---

Python script used (snippet):

import deepl

def translate_text(text, target_language, glossary_id, tags_to_ignore, formality_setting):
    translator = deepl.Translator("my-DeepL-API-key")
    translation = translator.translate_text(
        text,
        target_lang=target_language,
        source_lang="EN",
        glossary=glossary_id,
        tag_handling='xml',
        ignore_tags=tags_to_ignore,
        formality=formality_setting  # Apply formality setting
    )
    return translation.text

def translate_file(...)

tags_to_ignore = []  # Add all tags you want to ignore
formality_setting = 'prefer_less'  # Set formality preference
translate_file('delete-your-status-community.txt', 'delete-your-status-community_ES.txt', 'ES', 'my-DeepL-glossary-ID', tags_to_ignore, 'prefer_less')

Expected result:

The translated text doesn't skip/omits the right single quotation mark.

Hi, our translation works with neural networks, so in edge cases they might not fully respect the formatting of the input in the translation. If you have structured data like this and need the structure to always be preserved, it might be better to parse your structure and only feed the strings to the translation API.

Thanks for your answer, @JanEbbing – It makes sense. I will look for options such as parsing or post-translation text cleaning.

I'll close this issue 👍