Zinthose Posted September 2, 2008 Share Posted September 2, 2008 The title Says it all! expandcollapse popup#Region - Demo _GoogleToMsgBox("Hello World", "en", "en") _GoogleToMsgBox("Hello World", "en", "ja") _GoogleToMsgBox("Hello World", "en", "es") _GoogleToMsgBox("Hello World", "en", "it") _GoogleToMsgBox("Hello World", "en", "zh-cn") _GoogleToMsgBox("Hello World", "en", "ar") _GoogleToMsgBox("Hello World", "en", "bg") _GoogleToMsgBox("Hello World", "en", "fr") _GoogleToMsgBox("Hello World", "en", "de") _GoogleToMsgBox(InputBox("You try it!", "Enter some text to translate to Russian", "In Soviet Russia, code document you!"), "en", "ru") Func _GoogleToMsgBox($sText, $sFrom, $sTo) Msgbox(4096, "Google Translate [" & $sFrom & ":" & $sTo & "]", $sText & @TAB & @TAB & @TAB & @CRLF & @CRLF & _GoogleTranslate($sText, $sFrom, $sTo)) EndFunc #EndRegion Func _GoogleTranslate($sText, $sFrom = "en", $sTo = "ja") Local Const $FileName = "Translation.jsn" Local Const $Pattern = '"translatedText":"([^"]+)"' Local $GoogleURL = "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=%s&langpair=%s%%7C%s" Local $File $GoogleURL = StringFormat($GoogleURL, $sText, $sFrom, $sTo) If Not InetGet($GoogleURL, $FileName, 1) Then Return SetError(1, 0, 0) $File = FileOpen($FileName, 4) FileGetSize($FileName) $Translation = FileRead($File, FileGetSize($FileName)) FileClose($File) FileDelete($FileName) $Translation = BinaryToString($Translation, 4) If StringRegExp($Translation , $Pattern) Then $Translation = StringRegExp($Translation , $Pattern, 1) $Translation = $Translation[0] Return $Translation EndIf EndFunc --- TTFN Link to comment Share on other sites More sharing options...
gseller Posted September 2, 2008 Share Posted September 2, 2008 Very Good discovery and way to use regex with the web, have you seen this post? http://www.autoitscript.com/forum/index.php?showtopic=65961 Might help you alot with further development.. Link to comment Share on other sites More sharing options...
Zinthose Posted September 3, 2008 Author Share Posted September 3, 2008 Very Good discovery and way to use regex with the web, have you seen this post? http://www.autoitscript.com/forum/index.php?showtopic=65961 Might help you alot with further development.. Boo! someone beat me to it... No I didn't see that post. Oh, well... at least mine "looks" simpler. And here I was all excited that I found something new.Is the search capability of the forum broke? It seams like a search usually yields everything but the kitchen sink when I search for "Kitchen Sink". --- TTFN Link to comment Share on other sites More sharing options...
gseller Posted September 3, 2008 Share Posted September 3, 2008 I agree.. LOL Seems like it only pulls the sticky's then whatever is the most popular post at the time... Google is what I mainly use to search the forum tho. Start it out with like: autoit blah blah and it does pretty well.. Apples292 1 Link to comment Share on other sites More sharing options...
Zenhari Posted July 7, 2009 Share Posted July 7, 2009 Hello Friend Can you help me? I want a program that could translator a website with google translate tanks Link to comment Share on other sites More sharing options...
corgano Posted January 29, 2010 Share Posted January 29, 2010 (edited) if you set translate to "en" from "auto", is there a way to get what language Google says it is? You can do this manually by translating language detect to English from (auto detect) according to waht the script does, "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=In Soviet Russia, code document you!&langpair=en%7Cru" is normal, but this "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=In Soviet Russia, code document you!&langpair=auto%7Cru" won't work. Why? That is what the Google URL uses when you translate manually. Edited January 29, 2010 by corgano 0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now