deepl-python icon indicating copy to clipboard operation
deepl-python copied to clipboard

XML translation - character moves into inline element

Open matsbert opened this issue 3 months ago • 0 comments

I am translating large amounts of XML text. Every time when I translate text, a character that preceeds an inline element (superScript) is being moved into the inline element.

Input:

Problemet är att bokstaven före superScript elementet flyttas in i inline elementet: tank rymmer 48 m<superScript>3</superScript> och tanken rymmer 43 m<superScript>3</superScript>. Lite mer text här.

Translated output:

The problem is that the letter preceding the superScript element is being moved into the inline element: tank holds 48<superScript>m3</superScript> and the tank holds 43<superScript>m3</superScript>. A little more text here.

result = deepl_client.translate_text( text, tag_handling="xml", source_lang="SV", target_lang="EN-GB", model_type="prefer_quality_optimized", split_sentences="nonewlines" )

I have noticed that adding the superScript element to the 'ignore_tags' attribute will help. The unfortunate thing is that the superScript element can also contain other text that must be translated.

matsbert avatar Sep 01 '25 11:09 matsbert