Sign in to follow this  
Followers 0
forkinpm

Using AutoIt to build a translation model

2 posts in this topic

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.

Share this post


Link to post
Share on other sites



If you don't know well AutoIt I suggest to start read some finished projects.

Look here

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

MsgBox(0,"",_GoogleTranslate("Hello World", "en", "de"))

When the words fail... music speaks

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0