forkinpm Posted September 20, 2009 Share Posted September 20, 2009 Hall yet again! This is my third post today as a newbie. I am building a platform to translate my English texts into German. Anyone helping me with scripts, could have access over time to my translation model. Regards and have a nice day, forkinpm. Link to comment Share on other sites More sharing options...
Andreik Posted September 20, 2009 Share Posted September 20, 2009 If you don't know well AutoIt I suggest to start read some finished projects.Look hereFunc _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 MsgBox(0,"",_GoogleTranslate("Hello World", "en", "de")) When the words fail... music speaks. 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