Translator for San Andreas Multiplayer
#1

Very simple translator for SA-MP made with Autohotkey it's much faster than manually translating. I've successfully used it to have conversations in Portuguese, Spanish, Polish, Hungarian, Indonesian, Russian, Dutch, German, and a few other languages. Works best in small servers. Please post any improvements you might think of below and I'll definitely consider them. This is still in the early stages of development with more features and greater compatibility to come. It works alright for me now and I hope it will help you as well. So without further ado, here it is.

UPDATED 01/06/2013

Changes v1.2:
Major bug fix (wouldn't have worked, unless placed with chatlog.txt)

Changes v1.1:
Added Tray icon functions
Now simply uses two letter abbreviations for language selection. "ex. en for English, es for Spanish"
Language selection simplified to "Your Language" and "Their Language" input boxes.

Changes v1.0:

Added INI functions, no longer needs to be in folder with Chatlog.txt(run from anywhere)
Language selection (uses the end of ****** Translate URLS "ex. /#en/es/")
Can now read the last 5 lines and displays in a msg box instead of sending.
ctrl+f12 to reload

INSTALL INSTRUCTIONS
Download it from here. When prompted, navigate to, and select your Chatlog.txt, set appropriate languages, press OK and you're ready to start translating

USE INSTRUCTIONS
Run SAMPtranslate.exe, and set the languages, then press OK. Open Firefox and go to http://translate.******.com/ (make sure instant translation is on) then leave it open. Open SA-MP and join the server you want (you'll probably need to be windowed, or you can set your game resolution to the same as your desktop's or vice versa). Press F10 to translate the last 5 lines of chat. Type a message in GTA's chat box and instead of pressing enter, press F9 to send the message translated into their language. Pressing Ctrl+F12 will open the SAMPtranslate GUI or you can click the tray icon.

If you're not sure what the 2 letter abbreviation for a language is, manually translate something in ****** translate to that language and the URL in your browser's address bar should contain the 2 letter abbreviation you need.

KNOWN BUGS
Sometimes it goes too fast and misses translation, just retry until it works. If it's still missing make sure you're windowed and close unnecessary programs.

If Firefox isn't open it will pause until you open it. You need Firefox for this to work(More browsers will be supported soon hopefully) but if you absolutely can't use Firefox then you'll need to edit the parts that say "Mozilla Firefox" in the source below, and replace with your browser's name.

SOURCE INSTRUCTIONS
To use/edit the source below, install Autohotkey, copy the source, open notepad, paste and save as anything but make sure you put .AHK as the file extension, then simply double click the saved file.

If you don't trust my compiled version you can decompile it yourself and see that it's exactly the same as the source, with this http://www.autohotkey.com/board/topi...ile-script-10/ (Added this because admins didn't think that what I posted was the full source... it is.)

SOURCE
Код:
;;SA-MP Translator
;;by J from Jaycob.co.nf
;;01/06/2013
;;v1.2
#SingleInstance Force
Menu, Tray, Add, Open Menu, Menu 
Menu, Tray, Default, Open Menu 

Menu:
GUI, DESTROY
INIRead, logfile, %A_ScriptDir%\trans.ini, general, logfile
If (logfile == "ERROR"){
	msgbox Hit Ok and find the SAMP chatlog (default location on WindowsXP is "My Documents\GTA San Andreas User Files\SAMP\chatlog.txt").
   FileSelectFile, logfile,,,Selet GTA chat log, Documents (*.txt)
   If (logfile == ""){
      MsgBox, No file selected, translations wont work.
   } Else {
      INIWrite, %logfile%, trans.ini, general, logfile
   }
}
INIRead, save, %A_ScriptDir%\trans.ini, general, save
if save = ERROR
{
save = default
}
SetTitleMatchMode, 2 
SetKeyDelay, 20, 5
;; instructions
IniRead, Language, %A_ScriptDir%\trans.ini, %save%, Language
if Language = ERROR
{
Language = en
}
IniRead, Language2, %A_ScriptDir%\trans.ini, %save%, Language2
if Language2 = ERROR
{
Language2 = es
}
Gui, Add, Text,, Open firefox 
Gui, Add, Text,, press f10 to translate last 5 chat lines
Gui, Add, Text,, type in chatbox then press f9 to send 
Gui, Add, Text,, press ctrl+f10 if you dont know what language it is
Gui, Add, Text,, Two letter abreviations for languages(ex. en is English)
Gui, Add, Text,, Your Language:
Gui, Add, Edit, vLanguage, %Language%
Gui, Add, Text,, Their Language:
Gui, Add, Edit, vLanguage2, %Language2%
Gui, Add, Text,, ctrl+F12 to open this again
Gui, Add, Button, Default, OK
gui, show,
return
ButtonOK: 
gui, submit
IniWrite, %Language%, %A_ScriptDir%\trans.ini, %save%, Language
IniWrite, %Language2%, %A_ScriptDir%\trans.ini, %save%, Language2
sleep 2000
f10::
;;read chatlog and translate
File = %logfile%         
Lines = 6
FileRead Text, %File%
StringGetPos Pos5, Text, `n, R%Lines%
StringTrimLeft Llines, Text, Pos5+1
clipboard = %Llines%
WinWait, Mozilla Firefox, 
IfWinNotActive, Mozilla Firefox, , WinActivate, Mozilla Firefox, 
WinWaitActive, Mozilla Firefox,  
sleep 300
Sendinput, ^l
sleep 700
Sendraw translate.******.com/#%Language2%/%Language%/
Sendinput, {enter}
Sendinput, ^a{delete}
sendinput, ^v
sleep 1500
Send ^c
MsgBox, %clipboard%
Clipboard =
WinWait, GTA:SA:MP, 
IfWinNotActive, GTA:SA:MP, , WinActivate, GTA:SA:MP, 
WinWaitActive, GTA:SA:MP, 
return
^f10::
;;read chatlog detect language and translate
File = %logfile%          
Lines = 6
FileRead Text, %File%
StringGetPos Pos5, Text, `n, R%Lines%
StringTrimLeft Llines, Text, Pos5+1
clipboard = %Llines%
WinWait, Mozilla Firefox, 
IfWinNotActive, Mozilla Firefox, , WinActivate, Mozilla Firefox, 
WinWaitActive, Mozilla Firefox,  
sleep 300
Sendinput, ^l
sleep 700
Sendraw translate.******.com/#auto/%Language%/
Sendinput, {enter}
Sendinput, ^a{delete}
sendinput, ^v
sleep 1500
Send ^c
MsgBox, %clipboard%
Clipboard =
WinWait, GTA:SA:MP, 
IfWinNotActive, GTA:SA:MP, , WinActivate, GTA:SA:MP, 
WinWaitActive, GTA:SA:MP, 
return
f9::
;;send
send ^a^c
WinWait, Mozilla Firefox, 
IfWinNotActive, Mozilla Firefox, , WinActivate, Mozilla Firefox, 
WinWaitActive, Mozilla Firefox,  
Sleep 300
Sendinput, ^l
Sleep 700
Sendinput, ^a{delete}
sendraw, translate.******.com/#%Language%/%Language2%/
sendinput, ^v{enter}
sleep 1500
Sendinput, ^c
WinWait, GTA:SA:MP, 
IfWinNotActive, GTA:SA:MP, , WinActivate, GTA:SA:MP, 
WinWaitActive, GTA:SA:MP, 
Sendinput t{CtrlDown}a{CtrlUp}{delete}%clipboard%{enter}
clipboard = 
return
^F12::reload
[ame="http://www.youtube.com/watch?v=gJdhK0KtbUM"]Video demonstration[/ame]

SAMPTranslate1.2.exe
Reply
#2

http://forum.sa-mp.com/forumdisplay.php?f=82..
Reply
#3

First post and that's on the wrong section. Although, someone can find this application useful.
Reply
#4

Can someone check if the compiled version is safe? I don't have computer
Reply
#5

You have to post the entire source code.
Reply
#6

I did lol you can check for yourself although this isn't the right post anyways. To decompile the exe you can use this http://www.autohotkey.com/board/topi...ile-script-10/
Reply
#7

Fix the download Instruction please?
Reply
#8

I've made a more practical script (but for Autoit)

Check it:

https://sampforum.blast.hk/showthread.php?tid=479769
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)