Jump to content

Recommended Posts

Posted

Hello,

I'm trying to translate with google translator but not able to translate my text file from Russian to English and my output saved in text file is 0 instead of any translated text.

I'm using a text file which contains 5 lines of Russian language and I want to translate it into English language and want to save it in other text file translated.txt but I'm not able to let it happen.

Please help me how can I make this possible same code was working several months ago but not now especially don't know what's going wrong with my code of google translator.

 

Here are my codes

#RequireAdmin
#include <IE.au3>
#include <String.au3>
#include <Array.au3>
ProcessClose ( 'iexplore.exe')
$File1 = @ScriptDir & "\kat01.txt"
$txt = FileRead($File1)
;-------------------------------Translation Started-------------------------
Local $tag="* # * # *"
Local $oIE=_IECreate("https://translate.google.com/#ru/en", 1, 1)
Local $oForm=_IEFormGetCollection($oIE,0)
Local $oQuery=_IEGetObjByName($oForm,"text")
_IEFormElementSetValue($oQuery, $tag & @CR & $txt & @CR & $tag)
_IEFormSubmit($oForm)
_IELoadWait($oIE)
Local $oText=_IEGetObjById($oIE,"gt-res-data")
$lines=StringSplit(_IEPropertyGet($oText,"innerText"),@CRLF,1)
;_IEQuit($oIE)
_ArrayDelete($lines,_ArraySearch($lines,$tag,1,0,0,1,0) & "-" & $lines[0])
_ArrayDelete($lines,"1-" & _ArraySearch($lines,$tag,1,0,0,1,1))
$lines[0]=UBound($lines)-1
_ArrayDisplay($lines)
Local $sFilePath = @ScriptDir & "\Translated.txt"
_FileWriteFromArray($sFilePath, $lines, 1)

 

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
×
×
  • Create New...