[Tool/Web/Other] 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
Code:
;;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
Mirror SAMPTranslate1.2.exe
Reply
#2

you gotta love ****** translate how its makes things wrong at some points. :P
Anyways, well done
Reply
#3

Lol Thanks. In my video demonstration it translates "Hello I'm not Spanish" correctly, then when I translate it back to English it says "Hello I'm Spanish". Blame ****** for mistranslations XD.
Reply
#4

Why 2 threads https://sampforum.blast.hk/showthread.php?tid=442725 ?
Reply
#5

Quote:
Originally Posted by doreto
View Post
It's moved because it was in the wrong section.
Reply
#6

Looks nice
Reply
#7

nice! it works with only english and spanish language?
if "yes" you can add others language
Reply
#8

Quote:
Originally Posted by AlexPro99
View Post
nice! it works with only english and spanish language?
if "yes" you can add others language
No, most languages that ****** Translate can translate should work.
Although the GUI is only in English.
Reply
#9

Very good.

Off: That is my server xD
Reply
#10

Quote:
Originally Posted by xSDx
View Post
Very good.

Off: That is my server xD
Thanks
Gracias, su servidor es muy bueno tambiйn.
Reply
#11

i can't download please re upload
Reply
#12

Quote:
Originally Posted by Witnec
Посмотреть сообщение
i can't download please re upload
I've added a mirror link.
Reply
#13

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: 1 Guest(s)