AZJIO Posted October 14, 2012 Share Posted October 14, 2012 (edited) GoogleTranslator (GUI=Ru)screenshot Edited October 14, 2012 by AZJIO My other projects or all Link to comment Share on other sites More sharing options...
guinness Posted October 14, 2012 Share Posted October 14, 2012 AZJIO, The Encoding.au3 is missing from the source files. But overall a good example/application. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Ontosy Posted October 14, 2012 Share Posted October 14, 2012 GoogleTranslator (GUI=Ru)screenshotIt work in russian not in georgian.i have found Encoding.au3 but compiled work source not show right characters. Link to comment Share on other sites More sharing options...
mesale0077 Posted May 1, 2013 Share Posted May 1, 2013 dont work Link to comment Share on other sites More sharing options...
AZJIO Posted May 2, 2013 Share Posted May 2, 2013 I uploaded the file again with the UDF My other projects or all Link to comment Share on other sites More sharing options...
Celtic88 Posted May 2, 2013 Share Posted May 2, 2013 (edited) updat : :support any language "arabic right characters " and read a long string expandcollapse popupOpt("GUIONEVENTMODE", 1) Global $link = "http://translate.google.com/" Global $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") Global $TITEL = "Google Translate" Global $SCRIPTGUI = GUICreate($TITEL, 841, 448, -1, -1, -2133983232) GUISetOnEvent(-3, "__EXIT") Global $EDIT1 = GUICtrlCreateEdit("", 0, 0, 841, 156) GUICtrlSetResizing(-1, 774) Global $Edit2 = GUICtrlCreateEdit("", 0, 160, 841, 260) GUICtrlSetFont(-1, 15, 400, 0, "Arial") GUICtrlSetResizing(-1, 870) Global $Label1 = GUICtrlCreateLabel("Detec lang : ", 23, 425, 180, 17) GUICtrlSetResizing(-1, 834) GUICtrlCreateLabel("translate to ", 155, 425, 59, 17) GUICtrlSetResizing(-1, 834) Global $COMBO1 = GUICtrlCreateCombo("", 215, 423, 127, 25, 2097155) GUICtrlSetOnEvent($COMBO1, "__GOTRAN") GUICtrlSetData($COMBO1, __lGUI()) GUICtrlSetResizing(-1, 834) Global $BUTTON1 = GUICtrlCreateButton("Speak", 352, 421, 75, 25) GUICtrlSetOnEvent($BUTTON1, "__GOSPEAK") GUICtrlSetResizing(-1, 834) GUISetState() While True Sleep(1000) WEnd Func __GOSPEAK() Local $readtxt $readtxt = GUICtrlRead($Edit2) If $readtxt = "" Then Return WinSetTitle($SCRIPTGUI, "", "WAIT DOWNLOAD DATA...") __GOOGLESPEEK($readtxt) WinSetTitle($SCRIPTGUI, "", $TITEL) EndFunc ;==>__GOSPEAK Func __GOTRAN() Local $readtxt = GUICtrlRead($EDIT1) If $readtxt = "" Then Return WinSetTitle($SCRIPTGUI, "", "WAIT DOWNLOAD DATA...") __GOOGLETRANS($readtxt) WinSetTitle($SCRIPTGUI, "", $TITEL) EndFunc ;==>__GOTRAN Func __GOOGLETRANS($TEXTTOTRANS) Local $TXT, $STEXT1, $STEXT, $STEXT2, $STEXT3, $STEXT4, $STEXT5, $Autodetlang $Autodetlang = __DETLANG(StringLeft(StringRegExpReplace($TEXTTOTRANS, "\r\n|\r|\n", Chr(32)), 33)) $Autodetlang = __SLANG($Autodetlang) GUICtrlSetData($Label1, "Detec lang : " & $Autodetlang) $Gettrnlang = __SLANG(GUICtrlRead($COMBO1), 1) If StringInStr("ar fa iw ur yi", $Gettrnlang) > 0 Then GUICtrlSetStyle($Edit2, 3152064 + 2) Else GUICtrlSetStyle($Edit2, 3152064 + 0) EndIf GUICtrlSetData($Edit2, "") $STEXT = StringSplit($TEXTTOTRANS, @CRLF, 1) For $i = 1 To $STEXT[0] $STEXT1 = StringSplit($STEXT[$i], Chr(32), 1) For $O = 1 To $STEXT1[0] $TXT &= $STEXT1[$O] & Chr(32) If StringLen($TXT) > 90 Or $O = $STEXT1[0] Then $STEXT2 = StringSplit($TXT, ".") For $z = 1 To $STEXT2[0] $STEXT3 = StringSplit($STEXT2[$z], '"') For $L = 1 To $STEXT3[0] $STEXT4 = StringSplit($STEXT3[$L], '?') For $M = 1 To $STEXT4[0] $STEXT5 = StringSplit($STEXT4[$M], '!') For $S = 1 To $STEXT5[0] if StringIsSpace($STEXT5[$S]) Then ContinueLoop _Guisetdata(__TRANTXT($STEXT5[$S], $Gettrnlang)) $TXT = "" If $S <> $STEXT5[0] Then _Guisetdata('!') Next If $M <> $STEXT4[0] Then _Guisetdata('?') Next If $L <> $STEXT3[0] Then _Guisetdata('"') Next If $z <> $STEXT2[0] Then _Guisetdata(".") Next EndIf Next If $i <> $STEXT[0] Then _Guisetdata(@CRLF) Next EndFunc ;==>__GOOGLETRANS Func __SLANG($LANGG, $OOPT = 2) Local $OPT = 2 Local $SLIS = StringSplit(__LISLll(), ";") For $i = 1 To $SLIS[0] Local $GETl = StringSplit($SLIS[$i], "|") If StringInStr($GETl[$OOPT], $LANGG, 2) Then If $OOPT = 2 Then $OPT = 1 Return $GETl[$OPT] EndIf Next EndFunc ;==>__SLANG Func __TRANTXT($TXT, $tto) Local $ENCODESSTRING, $READ, $DATA $ENCODESSTRING = __URIENCODE($TXT) $READ = __DOWN($link & "translate_a/t?client=t&sl=auto&text=" & $ENCODESSTRING & "&tl=" & $tto) $DATA = StringSplit($READ, '"') Return $DATA[2] EndFunc ;==>__TRANTXT Func REV($TXT) Local $split, $LOL $split = StringSplit($TXT, " ", 1) For $i = $split[0] To 1 Step -1 $LOL &= $split[$i] & " " Next Return $LOL EndFunc ;==>REV Func _Guisetdata($text) GUICtrlSetData($Edit2, GUICtrlRead($Edit2) & $text & " ") EndFunc ;==>_Guisetdata Func __GOOGLESPEEK($TEXTTOSPEEK) Local $TXT, $OPEN, $STEXT1, $READ = "", $ENCODESSTRING, $RESTRING, $LANG, _ $MPFIL = FileGetShortName(@ScriptDir) & "\" & GUICtrlRead($COMBO1) & "__" & Random(1, 99, 1) & ".MP3" $RESTRING = StringRegExpReplace($TEXTTOSPEEK, "\r\n|\r|\n", " ") $LANG = __DETLANG(StringLeft($RESTRING, 33)) $OPEN = FileOpen($MPFIL, 18) $STEXT1 = StringSplit($RESTRING, " ", 1) For $O = 1 To $STEXT1[0] $TXT &= $STEXT1[$O] & " " If StringLen($TXT) > 90 Or $O = $STEXT1[0] Then $ENCODESSTRING = __URIENCODE($TXT) FileWrite($OPEN, InetRead($link & "translate_tts?ie=UTF-8&tl=" & $LANG & "&q=" & $ENCODESSTRING, 1)) $TXT = "" EndIf Next FileClose($OPEN) SoundPlay($MPFIL) EndFunc ;==>__GOOGLESPEEK Func __DETLANG($STRI) Local $TST, $LANGGG $STRI = __URIENCODE($STRI) $TST = __DOWN($link & "translate_a/t?client=t&sl=auto&text=" & $STRI) $LANGGG = StringLeft(StringTrimLeft($TST, StringInStr($TST, '[["', 0, -1) + 2), 2) Return $LANGGG EndFunc ;==>__DETLANG Func __DOWN($URL) $oHTTP.Open("GET", $URL, False) $oHTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; rv:9.0.1) Gecko/20100101 Firefox/9.0.1") $oHTTP.Send("") $oReceived = $oHTTP.ResponseText Return $oReceived EndFunc ;==>__DOWN Func __URIENCODE($SDATA) Local $ADATA = StringSplit(BinaryToString(StringToBinary($SDATA, 4), 1), "") Local $NCHAR $SDATA = "" For $i = 1 To $ADATA[0] $NCHAR = Asc($ADATA[$i]) Switch $NCHAR Case 45, 46, 48 To 57, 65 To 90, 95, 97 To 122, 126 $SDATA &= $ADATA[$i] Case 32 $SDATA &= "+" Case Else $SDATA &= "%" & Hex($NCHAR, 2) EndSwitch Next Return $SDATA EndFunc ;==>__URIENCODE Func __lGUI() Local $llol, $SLIS $SLIS = StringSplit(__LISLll(), ";") For $i = 1 To $SLIS[0] $llol &= StringLeft($SLIS[$i], StringInStr($SLIS[$i], "|")) Next Return $llol EndFunc ;==>__lGUI Func LISL() Local $langlis = "Arabic|ar;English|en;French|fr" Return $langlis EndFunc ;==>LISL Func __LISLll() Local $langlist = "Afrikaans|af;Albanian|sq;Arabic|ar;Armenian|hy;Azerbaijani|az;Basque|eu;Belarusian|be;Bengali|bn;Bulgarian|bg;Catalan|ca;Chinese|zh-CN;Croatian|hr;Czech|cs;Danish|da;Dutch|nl;English|en;Esperanto|eo;" & _ "Estonian|et;Filipino|tl;Finnish|fi;French|fr;Galician|gl;Georgian|ka;German|de;Greek|el;Gujarati|gu;Haitian Creole|ht;Hebrew|iw;Hindi|hi;Hungarian|hu;Icelandic|is;Indonesian|id;Irish|ga;Italian|it;" & _ "Japanese|ja;Kannada|kn;Khmer|km;Korean|ko;Lao|lo;Latin|la;Latvian|lv;Lithuanian|lt;Macedonian|mk;Malay|ms;Maltese|mt;Norwegian|no;Persian|fa;Polish|pl;Portuguese|pt;Romanian|ro;Russian|ru;" & _ "Serbian|sr;Slovak|sk;Slovenian|sl;Spanish|es;Swahili|sw;Swedish|sv;Tamil|ta;Telugu|te;Thai|th;Turkish|tr;Ukrainian|uk;Urdu|ur;Vietnamese|vi;Welsh|cy;Yiddish|yi" Return $langlist EndFunc ;==>__LISLll Func __EXIT() Exit EndFunc ;==>__EXIT Edited September 10, 2013 by Mrbenkali baoquocphan 1 Link to comment Share on other sites More sharing options...
Celtic88 Posted May 3, 2013 Share Posted May 3, 2013 RE UP Link to comment Share on other sites More sharing options...
bartekd Posted May 23, 2013 Share Posted May 23, 2013 I get this error ==> The requested action with this object has failed.: $oHTTP.Open("GET", $URL, False) $oHTTP.Open("GET", $URL, False)^ ERROR Also, this doesn't seem right Global $link = "<a href='http://translate.google.com/' class='bbc_url' title='External link' rel='nofollow external'>http://translate.google.com/"</a> Link to comment Share on other sites More sharing options...
baoquocphan Posted December 29, 2013 Share Posted December 29, 2013 updat : :support any language "arabic right characters " and read a long string expandcollapse popupOpt("GUIONEVENTMODE", 1) Global $link = "http://translate.google.com/" Global $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") Global $TITEL = "Google Translate" Global $SCRIPTGUI = GUICreate($TITEL, 841, 448, -1, -1, -2133983232) GUISetOnEvent(-3, "__EXIT") Global $EDIT1 = GUICtrlCreateEdit("", 0, 0, 841, 156) GUICtrlSetResizing(-1, 774) Global $Edit2 = GUICtrlCreateEdit("", 0, 160, 841, 260) GUICtrlSetFont(-1, 15, 400, 0, "Arial") GUICtrlSetResizing(-1, 870) Global $Label1 = GUICtrlCreateLabel("Detec lang : ", 23, 425, 180, 17) GUICtrlSetResizing(-1, 834) GUICtrlCreateLabel("translate to ", 155, 425, 59, 17) GUICtrlSetResizing(-1, 834) Global $COMBO1 = GUICtrlCreateCombo("", 215, 423, 127, 25, 2097155) GUICtrlSetOnEvent($COMBO1, "__GOTRAN") GUICtrlSetData($COMBO1, __lGUI()) GUICtrlSetResizing(-1, 834) Global $BUTTON1 = GUICtrlCreateButton("Speak", 352, 421, 75, 25) GUICtrlSetOnEvent($BUTTON1, "__GOSPEAK") GUICtrlSetResizing(-1, 834) GUISetState() While True Sleep(1000) WEnd Func __GOSPEAK() Local $readtxt $readtxt = GUICtrlRead($Edit2) If $readtxt = "" Then Return WinSetTitle($SCRIPTGUI, "", "WAIT DOWNLOAD DATA...") __GOOGLESPEEK($readtxt) WinSetTitle($SCRIPTGUI, "", $TITEL) EndFunc ;==>__GOSPEAK Func __GOTRAN() Local $readtxt = GUICtrlRead($EDIT1) If $readtxt = "" Then Return WinSetTitle($SCRIPTGUI, "", "WAIT DOWNLOAD DATA...") __GOOGLETRANS($readtxt) WinSetTitle($SCRIPTGUI, "", $TITEL) EndFunc ;==>__GOTRAN Func __GOOGLETRANS($TEXTTOTRANS) Local $TXT, $STEXT1, $STEXT, $STEXT2, $STEXT3, $STEXT4, $STEXT5, $Autodetlang $Autodetlang = __DETLANG(StringLeft(StringRegExpReplace($TEXTTOTRANS, "\r\n|\r|\n", Chr(32)), 33)) $Autodetlang = __SLANG($Autodetlang) GUICtrlSetData($Label1, "Detec lang : " & $Autodetlang) $Gettrnlang = __SLANG(GUICtrlRead($COMBO1), 1) If StringInStr("ar fa iw ur yi", $Gettrnlang) > 0 Then GUICtrlSetStyle($Edit2, 3152064 + 2) Else GUICtrlSetStyle($Edit2, 3152064 + 0) EndIf GUICtrlSetData($Edit2, "") $STEXT = StringSplit($TEXTTOTRANS, @CRLF, 1) For $i = 1 To $STEXT[0] $STEXT1 = StringSplit($STEXT[$i], Chr(32), 1) For $O = 1 To $STEXT1[0] $TXT &= $STEXT1[$O] & Chr(32) If StringLen($TXT) > 90 Or $O = $STEXT1[0] Then $STEXT2 = StringSplit($TXT, ".") For $z = 1 To $STEXT2[0] $STEXT3 = StringSplit($STEXT2[$z], '"') For $L = 1 To $STEXT3[0] $STEXT4 = StringSplit($STEXT3[$L], '?') For $M = 1 To $STEXT4[0] $STEXT5 = StringSplit($STEXT4[$M], '!') For $S = 1 To $STEXT5[0] if StringIsSpace($STEXT5[$S]) Then ContinueLoop _Guisetdata(__TRANTXT($STEXT5[$S], $Gettrnlang)) $TXT = "" If $S <> $STEXT5[0] Then _Guisetdata('!') Next If $M <> $STEXT4[0] Then _Guisetdata('?') Next If $L <> $STEXT3[0] Then _Guisetdata('"') Next If $z <> $STEXT2[0] Then _Guisetdata(".") Next EndIf Next If $i <> $STEXT[0] Then _Guisetdata(@CRLF) Next EndFunc ;==>__GOOGLETRANS Func __SLANG($LANGG, $OOPT = 2) Local $OPT = 2 Local $SLIS = StringSplit(__LISLll(), ";") For $i = 1 To $SLIS[0] Local $GETl = StringSplit($SLIS[$i], "|") If StringInStr($GETl[$OOPT], $LANGG, 2) Then If $OOPT = 2 Then $OPT = 1 Return $GETl[$OPT] EndIf Next EndFunc ;==>__SLANG Func __TRANTXT($TXT, $tto) Local $ENCODESSTRING, $READ, $DATA $ENCODESSTRING = __URIENCODE($TXT) $READ = __DOWN($link & "translate_a/t?client=t&sl=auto&text=" & $ENCODESSTRING & "&tl=" & $tto) $DATA = StringSplit($READ, '"') Return $DATA[2] EndFunc ;==>__TRANTXT Func REV($TXT) Local $split, $LOL $split = StringSplit($TXT, " ", 1) For $i = $split[0] To 1 Step -1 $LOL &= $split[$i] & " " Next Return $LOL EndFunc ;==>REV Func _Guisetdata($text) GUICtrlSetData($Edit2, GUICtrlRead($Edit2) & $text & " ") EndFunc ;==>_Guisetdata Func __GOOGLESPEEK($TEXTTOSPEEK) Local $TXT, $OPEN, $STEXT1, $READ = "", $ENCODESSTRING, $RESTRING, $LANG, _ $MPFIL = FileGetShortName(@ScriptDir) & "\" & GUICtrlRead($COMBO1) & "__" & Random(1, 99, 1) & ".MP3" $RESTRING = StringRegExpReplace($TEXTTOSPEEK, "\r\n|\r|\n", " ") $LANG = __DETLANG(StringLeft($RESTRING, 33)) $OPEN = FileOpen($MPFIL, 18) $STEXT1 = StringSplit($RESTRING, " ", 1) For $O = 1 To $STEXT1[0] $TXT &= $STEXT1[$O] & " " If StringLen($TXT) > 90 Or $O = $STEXT1[0] Then $ENCODESSTRING = __URIENCODE($TXT) FileWrite($OPEN, InetRead($link & "translate_tts?ie=UTF-8&tl=" & $LANG & "&q=" & $ENCODESSTRING, 1)) $TXT = "" EndIf Next FileClose($OPEN) SoundPlay($MPFIL) EndFunc ;==>__GOOGLESPEEK Func __DETLANG($STRI) Local $TST, $LANGGG $STRI = __URIENCODE($STRI) $TST = __DOWN($link & "translate_a/t?client=t&sl=auto&text=" & $STRI) $LANGGG = StringLeft(StringTrimLeft($TST, StringInStr($TST, '[["', 0, -1) + 2), 2) Return $LANGGG EndFunc ;==>__DETLANG Func __DOWN($URL) $oHTTP.Open("GET", $URL, False) $oHTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; rv:9.0.1) Gecko/20100101 Firefox/9.0.1") $oHTTP.Send("") $oReceived = $oHTTP.ResponseText Return $oReceived EndFunc ;==>__DOWN Func __URIENCODE($SDATA) Local $ADATA = StringSplit(BinaryToString(StringToBinary($SDATA, 4), 1), "") Local $NCHAR $SDATA = "" For $i = 1 To $ADATA[0] $NCHAR = Asc($ADATA[$i]) Switch $NCHAR Case 45, 46, 48 To 57, 65 To 90, 95, 97 To 122, 126 $SDATA &= $ADATA[$i] Case 32 $SDATA &= "+" Case Else $SDATA &= "%" & Hex($NCHAR, 2) EndSwitch Next Return $SDATA EndFunc ;==>__URIENCODE Func __lGUI() Local $llol, $SLIS $SLIS = StringSplit(__LISLll(), ";") For $i = 1 To $SLIS[0] $llol &= StringLeft($SLIS[$i], StringInStr($SLIS[$i], "|")) Next Return $llol EndFunc ;==>__lGUI Func LISL() Local $langlis = "Arabic|ar;English|en;French|fr" Return $langlis EndFunc ;==>LISL Func __LISLll() Local $langlist = "Afrikaans|af;Albanian|sq;Arabic|ar;Armenian|hy;Azerbaijani|az;Basque|eu;Belarusian|be;Bengali|bn;Bulgarian|bg;Catalan|ca;Chinese|zh-CN;Croatian|hr;Czech|cs;Danish|da;Dutch|nl;English|en;Esperanto|eo;" & _ "Estonian|et;Filipino|tl;Finnish|fi;French|fr;Galician|gl;Georgian|ka;German|de;Greek|el;Gujarati|gu;Haitian Creole|ht;Hebrew|iw;Hindi|hi;Hungarian|hu;Icelandic|is;Indonesian|id;Irish|ga;Italian|it;" & _ "Japanese|ja;Kannada|kn;Khmer|km;Korean|ko;Lao|lo;Latin|la;Latvian|lv;Lithuanian|lt;Macedonian|mk;Malay|ms;Maltese|mt;Norwegian|no;Persian|fa;Polish|pl;Portuguese|pt;Romanian|ro;Russian|ru;" & _ "Serbian|sr;Slovak|sk;Slovenian|sl;Spanish|es;Swahili|sw;Swedish|sv;Tamil|ta;Telugu|te;Thai|th;Turkish|tr;Ukrainian|uk;Urdu|ur;Vietnamese|vi;Welsh|cy;Yiddish|yi" Return $langlist EndFunc ;==>__LISLll Func __EXIT() Exit EndFunc ;==>__EXIT Thank you, DjForfun, your code worked very well and exactly. Can I used your code as an UDF in my script? Thank you very much! Link to comment Share on other sites More sharing options...
rodent1 Posted January 29, 2014 Share Posted January 29, 2014 Hi, This was not working for me, till I updated the function _GoogleTranslateString(): expandcollapse popupFunc _GoogleTranslateString($sText,$sLangPair= -1,$bEncodeURL=False ) Local $url, $sTemp, $aTranslated, $sTranslated If $sLangPair = -1 Then $sLangPair = "en|es" $regex= '(?:<(?i)DIV id="?result_box"? dir="?ltr"?>)(.*?)(?:</(?i)DIV>)' $sTemp = $sText If $bEncodeURL Then $sTemp = _URLEncode($sText) EndIf $url =StringFormat('http://google.com/translate_t?langpair=%s&text=%s',$sLangPair,$sTemp) If(InetGet($url,".temp.html",1)) Then $aTranslated = StringRegExp(StringStripWS(FileRead(".temp.html"),7),$regex,3) If IsArray($aTranslated) Then FileDelete(".temp.html") $sTranslated = StringReplace($aTranslated[0],Chr(160),Chr(32)) $sTranslated = StringRegExpReplace($sTranslated,"((\s|\n)?<(?i)br)(.*?)(>)(\s)",@CRLF) If $bEncodeURL Then Return _URLDecode($sTranslated) EndIf Return $sTranslated ;Change starts here Else ConsoleWrite("Translation is no array" & @CRLF) $aTranslated = StringStripWS(FileRead(".temp.html"),7) if StringInStr($aTranslated, 'onmouseout="this.style.backgroundColor=' & "'#fff'" & '">')>0 Then $aTranslated = StringSplit($aTranslated, 'onmouseout="this.style.backgroundColor=' & "'#fff'" & '">', 1)[2] $aTranslated = StringSplit($aTranslated, "</span>", 1)[1] Local $strg = $aTranslated If $bEncodeURL Then Return _URLDecode($strg) EndIf Return $strg EndIf EndIf EndIf Return SetError(1,0,$sText) EndFunc The change is because StringRegExp did not return an array. Now it works for me. Link to comment Share on other sites More sharing options...
Elias Posted April 8, 2014 Share Posted April 8, 2014 Hi is their a way to do this using "post method" so it can translate a big text in one pass? 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