Document translation failed to translate alt attribute of img tag

雷 刘 6 Reputation points
2022-10-10T01:30:10.607+00:00

This is the development document.
https://learn.microsoft.com/zh-cn/azure/cognitive-services/translator/document-translation/overview

I use document translation to translate html files. The content in the tag can be translated normally, but the inter line attributes of the tag will not be translated, such as the alt attribute of the img tag and the title attribute of the a tag.

248823-aaa.png

248767-aab.png

Inter line attributes are not translated, and 'dir="ltr" is added to each element.
How to solve the problem?

Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
3,632 questions
{count} vote

1 answer

Sort by: Most helpful
  1. romungi-MSFT 48,911 Reputation points Microsoft Employee Moderator
    2022-10-10T08:01:21.187+00:00

    @雷 刘 I think this behavior is consistent with the text translation scenario where the textType=html also shows similar response. I used the below text in one of my text translation requests and the correspond response is below.

    [{'Text':'<p><span style="font-size: 10pt;">This is some test text with a link <a title="This is just a random link title" href="https://www.google.com" target="_blank" rel="noopener">this is a random link for testing</a> <img src="/img.png" alt="this is a test"</span></p>'}]  
    

    Response in french:

            "translations": [  
                {  
                    "text": "<p><span style=\"font-size: 10pt;\">Ceci est un texte de test avec un lien <a title=\"This is just a random link title\" href=\"https://www.google.com\" target=\"_blank\" rel=\"noopener\">, c’est un lien aléatoire pour tester</a> <img src=\"/img.png\" alt=\"this is a test\"</span></p>",  
                    "to": "fr"  
                }  
            ]  
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.