PDA

View Full Version : Automating the use of translation.babylon.com



danielgp
03-21-2014, 08:20 PM
Hi,

I am new in this forum, but have monitored for a very long time and had become a big fans of it.
This forum had helped me a lot in vba excel problems.
However this time I couldn't find any answer for my new issue to use translation.babylon.com.
I have this function which work perfectly with google translate using msxml2.xmlhttp method and tried to modify it but I have lost because don't understand how to compose the url.

Here's the code I used for a long time using google translate and worked charmly. I got it from this marvelous forum as well :clap:, and as I cannot post comments with links yet, please replace 2 [dot] with the real "." and remove the "[" and "]" from the "[http]" in code below:



Function getGoogleTranslation(strSource As String, strSourceLang As String, strDestLang As String) As String Dim strURL As String, x As String

strURL = "[http]://translate[dot]google[dot]com/translate_a/t?client=t&text=" & _
Replace(strSource, " ", "%20") & _
"&hl=en&sl=" & strSourceLang & _
"&tl=" & strDestLang & "&multires=1&pc=0&rom=1&sc=1"

With CreateObject("msxml2.xmlhttp")
.Open "get", strURL, False
DoEvents
.send
DoEvents
x = .responseText
End With
getGoogleTranslation = x

End Function


To use this function I used below codes extracting the returned results by analyzing any word functions available.
This below codes is not relevant though to my question (just need to describe what it does entirely).



Sub Translate()

'Translated Words will be divided as each word functions
WordFunction = Split("conjunction,preposition,verb,noun,particle,adjective,prefix,interjection,su ffix,complement", ",")

With ActiveSheet

SourceLang = "" 'Auto Detect so I leave it blank.
TargetLang = GetLang(.Range("B1")) 'GetLang is another function to convert eg: english > en, french > fr, etc...

'Get the total rows of data source
lRow = .Range("A" & .Rows.Count).End(xlUp).Row

'Run a cycle through each rows
For r = 2 To lRow

'Get the English term from each row in column A
str = ConvertUTF8(.Range("A" & r)) 'There's another function to convert the word to UTF8


If Not IsEmpty(str) Then
translateResults = getGoogleTranslation(str, SourceLang, TargetLang)

'Main Translated words
.Range("B" & r) = Replace(Replace(Split(translateResults, Chr(34) & "," & Chr(34))(0), "[", ""), """", "")

'Other words
col = 0
For Each c In WordFunction
WFpos = InStr(1, translateResults, c)
If WFpos > 0 Then
intStart = InStr(WFpos, translateResults, ",[") + 3
intEnd = InStr(intStart, translateResults, "],")
otherWords = Split(Replace(Mid(translateResults, intStart, intEnd - intStart), Chr(34), ""), ",")
For Each w In otherWords
.Cells(r, 3 + col) = w
col = col + 1
Next w
End If
Next c
End If

Next r

End With

End Sub


It would be great if someone can give me a clue on how to compose the correct url to use the translation babylon website like used in above function with google translate.

I hope I am not confusing you, excuse me for my english, I am from Indonesia.
Thank you all excel expert, really appreciate your time to read this :)

Best Wishes,
Daniel G. Pratidya

snb
03-22-2014, 06:24 AM
I don't see any online translation facility in Babylon's website.

danielgp
03-22-2014, 07:33 AM
Have you tried: translation.babylon.com

snb
03-22-2014, 09:00 AM
That's not a valid URL.

danielgp
03-22-2014, 09:44 AM
Well, as I said I cannot post the valid url yet (because I am new here).
The valid url is to insert [http]:// without the [ and ] symbols before "translation.babylon.com"
Despite I believe if you just copy-paste translation.babylon.com into your url field and hit enter on any browsers, you should see the page.

mancubus
03-22-2014, 10:08 AM
http://translation.babylon.com/

default is English To Spanish