Why Google Translation v3beta1 api uses default mimeType as text/html instead of text/plain ?

48 views
Skip to first unread message

Ankit Chauhan

unread,
Jul 29, 2019, 10:31:02 AM7/29/19
to Google Cloud Translation API
Hi All,

I am using Google Translation v3beta1 API  to get the dynamic translation of a given text. Since default text type for this api is 'text/html', unlike Microsoft Azure Translation api where the default value is plain text. May I know the reason for the default value of mimeType as text/html instead of text/plain. Because, if I am not giving any value to mimeType then it always considers its value as text/HTML and even if I give a plain text to translate, it must have some preprocessing steps to detect whether there exists any HTML tag in the given text or not which may affect overall processing time to get the translation.

Thanks,
Ankit.

Gurkomal Rao

unread,
Aug 6, 2019, 2:40:44 PM8/6/19
to Google Cloud Translation API

The Translation API v3beta1 has the ability to take both plain text or HTML as input. Where there is HTML, the API does not translate any of the HTML tags in the input and the output correctly retains the HTML tags with the plain text translated in between. 


Therefore it is better to use “text/html” because if the mime type is set to "text/plain" and the input for example is html, the result will be partially mangled as the HTML tags would also be incorrectly translated. It is essentially a safety net for certain scenarios, where plain text would  not be as affected by “text/html”.

Nikolay G

unread,
Aug 6, 2019, 3:18:58 PM8/6/19
to Google Cloud Translation API
yes.  If you pass plain text with mime_type “text/html” then the output will be mostly fine except that certain characters can be HTML-escaped (e.g., ').  If you know input type , then it'd be best to just set mimeType  to correct value. 
Reply all
Reply to author
Forward
0 new messages