Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Language translation

$
0
0

hi

I'm a small language translation program

but there are some problems

%S, %d  ,\n 
to
% s or % S  \\n  or \\N  converted and unicode problem   exam u200 ?

and save  as    ansi ,utf-8 ,unicode select  save file converted file

some time

MAINMENU_FILE_SAVE_DIFFERENTS = "Save Differents To File...

to

MAINMENU_FILE_SAVE_DIFFERENTS =\

 

why ı dont now

and translation is very slow

how to provide a solution

next time then I need to do to other languages

AutoIt         
#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <Array.au3> Local $laFileLines[5000],$laFileLines_1[5000],$aDays[5000] #Region ### START Koda GUI section ### Form= $Form1_1 = GUICreate("[#] Form1 [#]", 624, 130, 192, 124) $Input1 = GUICtrlCreateInput("", 40, 40, 345, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY)) $Button1 = GUICtrlCreateButton("SELECT EN", 392, 40, 65, 25) $Input2 = GUICtrlCreateInput("", 40, 72, 345, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY)) $Button2 = GUICtrlCreateButton("SAVE TR", 392, 72, 65, 25) $Button3 = GUICtrlCreateButton("Translate to", 536, 40, 73, 57) $Input3 = GUICtrlCreateInput("<<>>", 472, 72, 49, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER)) $Label1 = GUICtrlCreateLabel("Reagent", 480, 48, 33, 17) $Label2 = GUICtrlCreateLabel("", 56, 96, 305, 28) GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1     $nMsg = GUIGetMsg()     Switch $nMsg         Case $GUI_EVENT_CLOSE             Exit Case $Button1 Local $message = "Choose the language file." Local $var_123 = FileOpenDialog($message, @desktopDir & "\", "Lang file(*.*)", 1 + 4) If @error Then    MsgBox(4096, "", "No File(s) chosen") Else     $var_123 = StringReplace($var_123, "|", @CRLF) $var_12345 =  StringSplit($var_123, '.') GUICtrlSetData($Input1, $var_123) EndIf Case $Button2 Local $var = FileSaveDialog("Choose the language file.", @desktopDir & "\", "Lang file (*."&$var_12345[2]&")", 2) If @error Then  MsgBox(4096, "", "Save cancelled.") else   $mmm_1= $var&"."&$var_12345[2]   GUICtrlSetData($Input2,  $mmm_1) EndIf Case $Button3  GUICtrlSetData($Label2, "Please wait translation is done") $ayir = GUICtrlRead($Input3) ttt( GUICtrlRead($Input1))  _k88k(GUICtrlRead($Input1),"turkish.dat");turkishconverted.dat GUICtrlSetData($Label2, "")     EndSwitch WEnd func ttt($var ) _FileReadToArray($var ,$laFileLines) For $i = 1 To $laFileLines[0]  GUICtrlSetData($Label2, "Please wait translation is done") $laFileLines[$i] = StringReplace($laFileLines[$i], $ayir, "=") $laFileLines[$i] = StringReplace($laFileLines[$i], "&", "") $aDays = StringSplit($laFileLines[$i], '=') if $aDays[0]=2 then filewrite("deneme.dat",$aDays[2]& @CRLF);Convert to go file $kkk= _GoogleTranslate($aDays[2], "en", "tr") filewrite("turkish.dat",StringUpper(stringleft($kkk, 1))&StringTrimleft($kkk, 1)& @CRLF) sleep(100) else filewrite("deneme.dat",$aDays[1]& @CRLF) filewrite("turkish.dat",$aDays[1]& @CRLF) endif next endfunc func _k88k($var,$var_1) _FileReadToArray($var ,$laFileLines) _FileReadToArray($var_1 ,$laFileLines_1) For $i = 1 To $laFileLines[0] $laFileLines[$i] = StringReplace($laFileLines[$i], "<<>>", "=") $aDays = StringSplit($laFileLines[$i], '=') if $aDays[0]=2 then $laFileLines[$i] = StringReplace($laFileLines[$i], "="&$aDays[2], $ayir&$laFileLines_1[$i]) filewrite(GUICtrlRead($Input2),$laFileLines[$i]& @CRLF) else filewrite(GUICtrlRead($Input2),$laFileLines[$i]& @CRLF) endif next endfunc Func _GoogleTranslate($sText, $sFrom = "en", $sTo = "tr") $Translation = InetRead('http://translate.google.com/translate_a/t?client=t&text=' & $sText & '&hl=en&sl=' & $sFrom & '&tl=' & $sTo) If @error Then Return SetError(1, 0, 0) $Translation = StringRegExp(BinaryToString($Translation), '"(?i)(.*?)"', 3) If @error Then Return SetError(2, 0, 0) If StringStripWS($Translation[0], 3) = "" Then Return $Translation[2] Return $Translation[0] EndFunc   ;==>_GoogleTranslate  

Thank you now

look this  files

 

 

Attached Files


Viewing all articles
Browse latest Browse all 12506

Trending Articles