Using translation.babylon.com

danielgpratidya

New Member
Joined
Mar 21, 2014
Messages
1
Hi,

I am new in this forum, but have monitored long time and have 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 function which work perfectly with google translate using msxml2.xmlhttp and tried to modify it using the same method 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 this from this marvelous forum as well ;) ):

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

strURL = "http://translate.google.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 results returned 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,suffix,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


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:

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

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
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

Forum statistics

Threads
1,214,651
Messages
6,120,744
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top