'italien: ita
'anglais: eng
'allemand: ger
'espagnol: spa
Sub test()
MsgBox translate_In_Out("bonjour a tous sur ExcelDownloads", "fra", "spa")
End Sub
Function translate_In_Out(Texte, Optional LgIn$ = "fra", Optional LgOut$ = "eng")
Dim req
Set req = CreateObject("microsoft.xmlhttp")
URL = "https://api.reverso.net/translate/v1/translation/"
req.Open "get", URL, False
req.SetRequestHeader "Accept", "application/json, text/javascript, */*; q=0.01"
req.SetRequestHeader "Content-Type", "application/json; charset=utf-8"
req.SetRequestHeader "Referer", "https://www.reverso.net/translationresults.aspx?lang=FR&direction=francais-anglais"
req.SetRequestHeader "Accept-Language", "fr-FR"
req.SetRequestHeader "Origin", "https://www.reverso.net"
req.SetRequestHeader "Accept-Encoding", "gzip, deflate"
req.SetRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko/20100101 Firefox/22.0"
req.SetRequestHeader "Host", "api.reverso.net"
req.SetRequestHeader "DNT", 1
req.SetRequestHeader "Connection", "Keep - Alive"
req.SetRequestHeader "Cache-Control", "no-cache"
req.send "{""input"":""" & Texte & """,""from"":""" & LgIn & """,""to"":""" & LgOut & """,""format"":""text"",""options"":{""origin"":""reversodesktop"",""sentenceSplitter"":true,""contextResults"":true,""languageDetection"":false}}"
translate_In_Out = Split(Split(req.responsetext, "translation"":[""")(1), Chr(34))(0)
End Function