How to translate only the source language?
Opened this issue · 1 comments
Use case
I am using this Deepl API for Python to translate phrases:
from deepl import Translator
...
deepl_translator = Translator(api_key)
translated_text_object = deepl_translator.translate_text(
"Contraction of cortical representation zones",
source_lang="ES",
target_lang="FR",
preserve_formatting=True,
glossary=glossary_id
)
print(translated_text_object.text)
print(translated_text_object.detected_source_lang)The wrong result
How it is now:
Contraction des zones de représentation corticale
ES
The expected result
Is there a way to translate only from Spanish so the answer is gonna be
Contraction of cortical representation zones
EN
I think the easiest way to solve this is to not pass the source language, and in your code only use the translation output from our API if the detected_source_language is equal to "ES" in your example. Does this make sense?
Please note that our API cannot handle input text in different languages within the same text (different entries in the array are fine, when using source language detection).
E.g.
text = ["Hallo, Welt!", "Hello, World!"] is fine
text = ["Hallo, Welt! Hello, World!"] is not fine (this specific example will probably work, but more complex ones won't)