PC SOFT

GRUPOS DE DISCUSSÃO PROFISSIONAL
WINDEVWEBDEV e WINDEV Mobile

Inicio → WINDEV 25 → Google Translator usando Wlanguage
Google Translator usando Wlanguage
Iniciado por Boller, jul., 14 2021 11:06 PM - Sem resposta
Membro registado
3.651 mensagems
Popularité : +175 (223 votes)
Publicado em julho, 14 2021 - 11:06 PM
Procedure Translate_Msg(sText is ANSI string, sLang_Target is string = "pt")

// Autor: Marcelo B. Santos
// Company: Futura Tecnologia

sKey is string = "" // Chave do google Cloud
sURL is ANSI string = "https://translation.googleapis.com/language/translate/v2"
sParam is ANSI string = "?target=" + sLang_Target + "&q=" + sText + "&key=" + sKey

// Lista de idiomas: https://cloud.google.com/translate/docs/languages

// Translate
vCallWS is httpRequest
vCallWS.Method = httpPost
vCallWS.URL = sURL + URLEncode(sParam)
ResponseWS is restResponse = RESTSend(vCallWS)

IF NOT Response_Verify(ResponseWS) THEN
RESULT False
END

// Retorno
// {
// "data": {
// "translations": [
// {
// "translatedText": "Eu amo meu lar",
// "detectedSourceLanguage": "en"
// }
// ]
// }
// }

RESULT ResponseWS.Content // json


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/