0

I am using very simple Text Translation Service but my input is "HTML" string and when the response is returned successfully the inline html text and style attributes are misplaced. Not sure why is happening. I also tried using the same HTML input (checked XML parsing correctness for the input HTML) to directly call the API without any proxy code through postman, still it is the same issue and the text as well as tags are misplaced here and there. Please help.

API Call:

https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&to=es&textType=html" 

Input Payload:

[{text: "<div class=\"customClassCode\"><p><span class=\"ql-size-xlargeplus\" style=\"background-color: rgb(0, 128, 128);\">Simple text should be displayed and translated to the </span><a href=\"https://www.google.com\" rel=\"noopener noreferrer\" target=\"_blank\" class=\"ql-size-xlargeplus\" style=\"background-color: rgb(0, 128, 128);\">new that</a><span class=\"ql-size-xlargeplus\" style=\"background-color: rgb(0, 128, 128);\"> were choosenHow we need to understand that it is so bad experience</span></p></div>"}]

Response (After Success from Text Translator Azure Cognitive Services)

<div class="customClassCode"><p><span class="ql-size-xlargeplus" style="background-color: rgb(0, 128, 128);">El texto simple debe mostrarse y traducirse a los </span><a href="https://www.google.com" rel="noopener noreferrer" target="_blank" class="ql-size-xlargeplus" style="background-color: rgb(0, 128, 128);">nuevos</a> que <span class="ql-size-xlargeplus" style="background-color: rgb(0, 128, 128);"> se eligieronCómo debemos entender que es una experiencia tan mala</span></p></div>

ISSUE: Line from response where it mentions "nuevos</a> que" format, should be "nuevos que</a>" (all inside anchor tag) based on the input text and this is not happening for some strange reason.

Tanuj
  • 53
  • 1
  • 8

1 Answers1

0

After reproducing issue from my side, i have identified the issue is with space. Given input text as provided by you,

[{"text": "<div class=\"customClassCode\"><p><span class=\"ql-size-xlargeplus\" style=\"background-color: rgb(0, 128, 128);\">Simple text should be displayed and translated to the </span><a href=\"https://www.google.com\" rel=\"noopener noreferrer\" target=\"_blank\" class=\"ql-size-xlargeplus\" style=\"background-color: rgb(0, 128, 128);\">new that</a><span class=\"ql-size-xlargeplus\" style=\"background-color: rgb(0, 128, 128);\"> were choosenHow we need to understand that it is so bad experience</span></p></div>"}]

Request Url: https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&to=es&textType=html Request Type: Post

Getting response from postman as shown below, enter image description here

Next tried to give input text as shown below,

[{"text": "<div class=\"customClassCode\"><p><span class=\"ql-size-xlargeplus\" style=\"background-color: rgb(0, 128, 128);\">Simple text should be displayed and translated to the </span><a href=\"https://www.google.com\" rel=\"noopener noreferrer\" target=\"_blank\" class=\"ql-size-xlargeplus\" style=\"background-color: rgb(0, 128, 128);\">newthat</a><span class=\"ql-size-xlargeplus\" style=\"background-color: rgb(0, 128, 128);\"> were choosenHow we need to understand that it is so bad experience</span></p></div>"}]

Getting response from postman now as shown below, enter image description here `Technically, in this scenario, space is used as a delimiter.

vijaya
  • 1,525
  • 1
  • 2
  • 6