Alternatief Google Translator

Status
Niet open voor verdere reacties.

richard99

Gebruiker
Lid geworden
17 apr 2010
Berichten
95
Kan iemand mij helpen voor het zoeken van een alternatief voor Google Translator?
Ik heb een vba code werken waar ik teksten vertaal van Nederlands naar Duits, Engels, Frans en Spaans.
Deze programma had ik al een tijdje niet meer gebruikt en vandaag kwam ik erachter dat Google Translator in december gestopt is met deze gratis service.

Mijn originele syntaxis is:

Public Function GoogleTranslate(strFromCountry As String, strToCountry As String, strText As String) As String
Dim cstrText As Long
Dim objHTML As Object
Dim objHTTP As Object
Dim strCharacter As String
Dim strTextConvert As String
Dim strRes As String

On Error GoTo ErrorDuringRunning

For cstrText = 1 To Len(strText)
strCharacter = Mid(strText, cstrText, 1)
Select Case strCharacter
Case "0" To "9", "A" To "Z", "a" To "z"
strTextConvert = strTextConvert & strCharacter
Case Else
strTextConvert = strTextConvert & "%" & Right("0" & Hex(Asc(strCharacter)), 2)
End Select
Next

strTemp = "http://translate.google.com/translate_a/t?client=t&text=" & strTextConvert & "&hl=en&sl=" & strFromCountry & "&tl=" & strToCountry & "&multires=1&pc=0&rom=1&sc=1"

Set objHTTP = CreateObject("MSXML2.XMLHTTP")
Set objHTML = CreateObject("HTMLFILE")
On Error GoTo eerrr
With objHTTP
.Open "GET", strTemp, False
.send
strRes = .responseText
End With

GoogleTranslate = Replace(Replace(Split(strRes, ",")(0), "[", ""), """", "")

Set objHTTP = Nothing
Set objHTML = Nothing

ErrorDuringRunning:
If Err.number > 0 Then
strMessage = Err.number & " _ " & Err.Description
Debug.Print strTemp
End If
End Function
 
Misbruik door deze code niet toegestaan.
Code:
[SIZE=1]Option Explicit

Public Function GoogleTranslate(strFromCountry As String, strToCountry As String, strText As String) As String
'http://ctrlq.org/code/19909-google-translate-api
'http://stackoverflow.com/questions/26714426/what-is-the-meaning-of-google-translate-query-params
'http://blog.goo.ne.jp/xmldtp/e/7651ed08da079c715c942822e12e7874
'http://www.asahi-net.or.jp/~zn3y-ngi/YNxv212.html
    Dim strResponseText As String
    With CreateObject("ScriptControl")
        .Language = "JScript"
        strText = .CodeObject.encodeURIComponent(strText)
        With CreateObject("MSXML2.XMLHTTP")
            .Open "GET", "https://translate.googleapis.com/translate_a/single?client=gtx&sl=" & strFromCountry & "&tl=" & strToCountry & "&dt=t&q=" & strText, False 'am_2015
            .send
            strResponseText = .ResponseText
        End With
        GoogleTranslate = .Eval("(" + strResponseText + ")[0][0][0]")
    End With
End Function[/SIZE]
 

Bijlagen

Laatst bewerkt:
Alleen du=de anders werkt het Duits niet (bij mij althans)....
PS: wel handig zo bij elkaar 3 talen....
Voetbal is oorlog Football is war
Voetbal is oorlog Fußball ist Krieg
Voetbal is oorlog Le football est la guerre
 
Laatst bewerkt:
Bij mij werkte "sp" niet meer echter werkt "es" weer wel dus had dat ook gelijk opgelost.
 
Nieuw bestand in bericht#2, met link naar landencodes.
 
Status
Niet open voor verdere reacties.

Nieuwste berichten

Terug
Bovenaan Onderaan