Consulting

Results 1 to 6 of 6

Thread: Automating the use of translation.babylon.com

  1. #1
    VBAX Newbie
    Joined
    Nov 2013
    Location
    Cikarang, Indonesia
    Posts
    4
    Location

    Automating the use of translation.babylon.com

    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 , 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,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
    
                '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

  2. #2
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,646
    I don't see any online translation facility in Babylon's website.

  3. #3
    VBAX Newbie
    Joined
    Nov 2013
    Location
    Cikarang, Indonesia
    Posts
    4
    Location
    Have you tried: translation.babylon.com


  4. #4
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,646
    That's not a valid URL.

  5. #5
    VBAX Newbie
    Joined
    Nov 2013
    Location
    Cikarang, Indonesia
    Posts
    4
    Location
    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.

  6. #6
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    http://translation.babylon.com/

    default is English To Spanish
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •