Google Translator

baha17

Board Regular
Joined
May 12, 2010
Messages
183
Hello Everyone,
Couple of days ago I found below code for google translation in excel spreadsheets. the reason was our users are restricted to surf on internet and I just want to grand access to one file so that they can use that spread sheet for short translations. The file works great, but only works for the Latin alphabet. I keep on getting “?” on English translation when I type Chinese. Below is the code for the file.</SPAN>
Code:
Public Function getGoogleTranslation(strSource As String, strSourceLang As String, strDestLang As String) As String
    Dim strURL As String, x As String
    strURL = "[URL]http://translate.google.com/translate_a/t?client=t&text[/URL]=" & _
             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
        .send
        x = .responseText
    End With
    getGoogleTranslation = Replace(Replace(Split(x, ",")(0), "[", ""), """", "")
    'getGoogleTranslation = Replace(Replace(Split(x, Chr(34) & "," & Chr(34))(0), "[", ""), """", "")
End Function

here is the formula goes to cell which translates into English

Code:
=IF($C4<>"",getGoogleTranslation($C4,$B4,E$3),"")

Where
C4:"Chinese text that I typed"
B4:zh-TW (Code for Traditional Chinese)
E3: en (code for English)
I am sure there is something with ASCII setting but could not able to get.
If you want to see the original excel file you can downloaded below link(excelforum link)

Excel Help Forum

Thank you very much for your kind attention.

Baha
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Forum statistics

Threads
1,223,934
Messages
6,175,488
Members
452,648
Latest member
Candace H

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