|
Joined: Dec 2005
Posts: 4
Self-satisified door
|
OP
Self-satisified door
Joined: Dec 2005
Posts: 4 |
hi. i'd like to know where i can find a good language translator addon. i tried the one on mirc.net but it doesn't work correctly. it only translates the first line of text
|
|
|
|
Joined: Feb 2004
Posts: 2,019
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 2,019 |
Edit the code so that it takes multiple lines of text, or call the script for every line.
I don't think you are going to find any free decent translator anyway, usually it's just words, maybe a sentence, but rarely multiple sentences.
Gone.
|
|
|
|
Joined: Dec 2005
Posts: 4
Self-satisified door
|
OP
Self-satisified door
Joined: Dec 2005
Posts: 4 |
;Language Translator
;Version 1.00
;by LemonButt (lemonbutt@graffiti.net)
Menu Menubar {
-
Language Translator: { LT }
-
}
On *:Sockopen:LT: {
Sockwrite -tn $Sockname GET $+(http://www.babelfish.altavista.com/tr?lp=,%~~lt.language,&trtext=,%~~lt.text,) HTTP/1.1
Sockwrite -tn $Sockname Host: babelfish.altavista.com $+ $Str($Crlf,2)
Sockwrite -tn $Sockname User-Agent: mIRC
Sockwrite -tn $Sockname $Crlf
Unset %~~lt.language
Unset %~~lt.text
}
On *:Sockread:LT: {
If ($Sockerr) { Sockclose $Sockname | Echo -a An error has occured: $Sockerr | Halt }
Elseif (%~~tbsitu.updated == $Null) {
Sockread %~~lt.sockread
If (*<td bgcolor=white class=s><div style=padding:10px;>* Iswm %~~lt.sockread) && ($Dialog(LT) != $Null) {
Set %~~lt.settings $Gettok(%~~lt.settings,1-2,32) $Calc($Gettok(%~~lt.settings,3,32) + 1)
Did -ra LT 105 $Gettok($Gettok(%~~lt.sockread,3,60),2,62)
Did -ra LT 110 Total Messages Translated: $Gettok(%~~lt.settings,3,32)
}
}
Unset %~~lt.sockread
}
On *:Load: { Set %~~lt.settings 3 4 0 }
On *:Unload: { Unset %~~lt.* }
Dialog LT {
Title "Language Translator [/lt]"
Size -1 -1 205 110
Option DBU
Box "Source", 100, 5 5 195 40
Combo 101, 10 14 50 10, Drop
Edit "", 102, 65 14 130 25, Multi, AutoVS
Box "Translation", 103, 5 50 195 40
Combo 104, 10 59 50 10, Drop
Edit "", 105, 65 59 130 25, Multi, AutoVS
Button "Translate", 106, 10 29 50 10, OK
Button "Swap Languages", 107, 10 74 50 10
Button "About", 108, 115 95 40 10
Button "Close", 109, 160 95 40 10
Text "", 110, 5 96 110 10
}
On *:Dialog:LT:*:*: {
If ($Devent == Init) {
Set -u0 %~~lt.init 1
While ($LT.Language(%~~lt.init) != $Null) { Did -a $Dname 101,104 $LT.Language(%~~lt.init) | Inc %~~lt.init }
Did -c $Dname 101 $Gettok(%~~lt.settings,1,32)
Did -c $Dname 104 $Gettok(%~~lt.settings,2,32)
Did -ra $Dname 110 Total Messages Translated: $Gettok(%~~lt.settings,3,32)
Did -f $Dname 106
}
If ($Devent == Sclick) {
If ($Did == 106) {
If ($Did($Dname,101).sel != $Did($Dname,104).sel) && ($Did($Dname,102) != $Null) { LT.Translate $+($LT.Language($Did($Dname,101).seltext),_,$LT.Language($Did($Dname,104).seltext)) $Did($Dname,102) }
ElseIf ($Did($Dname,102) == $Null) { LT $Input(Please enter text to translate.,wdo,Enter Text) }
Else { LT $Input(Please select two different languages.,wdo,Same Language) }
Haltdef
}
If ($Did == 107) { Set -u0 %~~lt.source $Did($Dname,101).sel | Did -c $Dname 101 $Did($Dname,104).sel | Did -c $Dname 104 %~~lt.source }
If ($Did == 108) { LT $Input($+(Language Translator,$Crlf,Version 1.00,$Crlf,by LemonButt (lemonbutt@graffiti.net)),ido,About) }
If ($Did == 109) { Dialog -x $Dname }
}
}
Alias LT {
If ($1 == $Null) {
If ($Dialog(LT) == $Null) { Dialog -m LT LT }
Else { Dialog -v LT }
}
}
Alias -l LT.Translate {
Sockclose LT
Set %~~lt.language $$1
Set %~~lt.text $Replace($$2-,$Chr(32),$+($Chr(37),20))
Set %~~lt.settings $Did(LT,101).sel $Did(LT,104).sel $Gettok(%~~lt.settings,3,32)
Sockopen LT babelfish.altavista.com 80
}
Alias -l LT.Language {
If ($$1 == English) { Return en }
ElseIf ($$1 == Chinese) { Return zh }
ElseIf ($$1 == Dutch) { Return nl }
ElseIf ($$1 == French) { Return fr }
ElseIf ($$1 == German) { Return de }
ElseIf ($$1 == Greek) { Return el }
ElseIf ($$1 == Italian) { Return it }
ElseIf ($$1 == Japanese) { Return ja }
ElseIf ($$1 == Korean) { Return ko }
ElseIf ($$1 == Portuguese) { Return pt }
ElseIf ($$1 == Russian) { Return ru }
ElseIf ($$1 == Spanish) { Return es }
ElseIf ($$1 == 1) || ($$1 == zh) { Return Chinese }
ElseIf ($$1 == 2) || ($$1 == nl) { Return Dutch }
ElseIf ($$1 == 3) || ($$1 == en) { Return English }
ElseIf ($$1 == 4) || ($$1 == fr) { Return French }
ElseIf ($$1 == 5) || ($$1 == de) { Return German }
ElseIf ($$1 == 6) || ($$1 == el) { Return Greek }
ElseIf ($$1 == 7) || ($$1 == it) { Return Italian }
ElseIf ($$1 == 8) || ($$1 == ja) { Return Japanese }
ElseIf ($$1 == 9) || ($$1 == ko) { Return Korean }
ElseIf ($$1 == 10) || ($$1 == pt) { Return Portuguese }
ElseIf ($$1 == 11) || ($$1 == ru) { Return Russian }
ElseIf ($$1 == 12) || ($$1 == es) { Return Spanish }
}
This is the code of the script. it's a really good translator and easy to use but the problem is it only translate the first line of text. If someone could pls test this and tell me how can i fix this to translate all text
|
|
|
|
Joined: Oct 2005
Posts: 1,741
Hoopy frood
|
Hoopy frood
Joined: Oct 2005
Posts: 1,741 |
Try this translator that I made (with a bit of assistance from FiberOPtics):
alias babel {
if (!$1) {
echo -a Syntax: /babel <words to translate here, max 700 chars>
return
}
set %babel $left($1-,700)
if ($sock(babel)) sockclose babel
sockopen babel world.altavista.com 80
if ($sockerr) babelfail
.timerbabel 1 30 babelfail
}
alias babelfail {
echo -a Error: Unable to connect to babelfish
.timerbabel off
unset %babel
sockclose babel
}
on *:SOCKOPEN:babel:{
if ($sockerr) {
babelfail
return
}
if (!%babel) {
sockclose babel
echo -a Error: No text to translate
return
}
var %babelu = %babel
%babelu = $replace(%babelu,%,% $+ 25)
while ($regex(babel,%babelu,/([^% \w])/Sg)) {
var %babelu = $replace(%babelu,$regml(babel,1),% $+ $base($asc($regml(babel,1)),10,16))
if ($calc($len(%babelu) $+ 2) > 800) break
}
var %type = en_fr
var %data = doit=done&intl=1&tt=urltext&trtext= $+ $replace(%babelu,$chr(32),+) $+ &lp= $+ %type $+ &btnTrTxt=Translate
var %write = sockwrite -tn $sockname
%write POST /tr HTTP/1.1
%write Referer: http://world.altavista.com/tr
%write Content-Type: application/x-www-form-urlencoded
%write Host: world.altavista.com
%write Content-Length: $len(%data)
%write Connection: close
%write
%write %data
}
on *:SOCKCLOSE:babel:{
echo -s Error: Babelfish closed the connection
.timerbabel off
unset %babel
}
on *:SOCKREAD:babel:{
var %sread
sockread %sread
if (%babelcontinue) %babelt = %babelt %sread
var %regex = /<td bgcolor=white class=s><div style=padding:10px;>(.+)$/Si
if ($regex(babel,%sread,%regex)) {
set %babelt $regml(babel,1)
set %babelcontinue 1
}
var %regex = /(.+)<\/div><\/td>/Si
if ($regex(babelb,%babelt,%regex)) {
set %babelt $regml(babelb,1)
set %babelcontinue 0
var %babeldone 1
}
if (%babeldone) {
echo 4 -a " $+ %babel $+ "
echo -a ...translates to...
echo 4 -a " $+ %babelt $+ "
.timerbabel off
unset %babel*
sockclose $sockname
}
}
This should translate everything you enter, up to 700 characters. If there are a lot of non-alnum characters in the message (each of which is replaced by 3 characters), the message will be truncated at 800 characters to prevent variable overflow. The usage is: /babel Your message goes here. -genius_at_work
Last edited by genius_at_work; 26/12/05 02:26 AM.
|
|
|
|
Joined: Feb 2004
Posts: 2,019
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 2,019 |
Don't forget the $replace(%babelu,%,% $+ 25) before doing the while with $regex, since % is also a character that needs to be converted to %25. This conversion must be done before other conversions, for obvious reasons.
Gone.
|
|
|
|
|