In reply to a post on the forum regarding language translation
" And yes, DeepL is amazing, how did we ever do without it? "
i give you .......
I wrote this in the year or two preceding May 2000, for mirc 5.51, for testing the idea with Bablefish website. I wrote several interfaces after this one which performed more functions. This one include file has a minimal interface branch for irc (not Tiggr's complete irc interface), the complete (but not threaded) http client written in mirc. Chances are, it no longer works on any new mirc, and won't interface to many http services, if only because it does not do https or any security handshaking. I tried to do some idiot-proofing, you can see the warning about idioms failing literal translations in this particular include, and attempts to cause Tiggr to flood Bablefish were simply dropped. There is a rudimentary control popup menu. I do not remember if i used my php remote that filtered webpages, i was on win95B and a flakey dialup at the time. Sorry, Jimcbrown , no database. The first line having the "halt" in it stopped this from running the last time Tiggr had loaded it, and there's many lines of code in it for debugging, it wasn't the last block of translating code i had written. I am very surprised i still have this file.
Ok, due to "the march of time", "upgrades", etc, some of the actual real file i wrote 25 years ago uses a code page no longer in vogue. Specifically characters properly representing the language names were not english. Duh. Since this is highly unlikely to run as was anyhow, i have corrupted those six lines to use "modern" english code pages. You'd delete these six lines (plus many more) to use an existing (2024 vs 1999) resource anyhow.
---------------------
on 1:TEXThalt:*:#:{
; echo -s errr... $address($nick,5) %ok.reply. [ $+ [ $newmask($address($nick,5),4) ] ]
; if ( %ok.reply. [ $+ [ $newmask($address($nick,5),4) ] ] != $null ) { halt }
if ( %Bablecom.accept != yes ) { goto eoontextxlate }
if ( %Bablecom.accept. [ $+ [ # ] ] == no ) { goto eoontextxlate }
set %xlate.ontext $strippunct( $1- )
if ( $istok(" Tiggr Tiggrbot Gertie Gertiebot bot ", $gettok(%xlate.ontext ,1,32),32) == $true ) {
if ( $gettok(%xlate.ontext ,2,32) == translate ) || ( $gettok(%xlate.ontext , $2 ,32) == t ) {
; tiggr translate e-s habla espanol?
xlate # $nick !t $gettok($1- , 3- ,32)
} }
if ( $1 == !t ) || ( $1 == !translate ) {
xlate # $nick $1-
}
:eoontextxlate
}
alias xlate {
; echo -s in xlate: $1-
; recieves:
; # $nick $1-
; StatusWindow Kat %intext
set -u0 %chan $1
set -u0 %nick $2
if ( %net != $null ) {
if ( $address(%nick,4) != $null ) && ( $address(%nick,4) != $address($me,4) ) {
if ( %flood.xlate. [ $+ [ $address(%nick,5) ] ] != $null ) || ( %flood.xlate.rep. [ $+ [ $address(%nick,5) ] ] != $null ) {
msg %chan please don't flood!
if ( %net != $null ) {
set -u10 %flood.xlate. [ $+ [ $address(%nick,5) ] ] off
set -u10 %flood.xlate.rep. [ $+ [ $address(%nick,5) ] ] off
goto eoxlate
} } }
}
if ( $4 != help ) && ( %flood.xlate. [ $+ [ $address(%nick,5) ] ] == $null ) {
if ( %net != $null ) { set -u10 %flood.xlate. [ $+ [ $address(%nick,5) ] ] off }
Babletranslate %chan $4-
}
if ( $3 == !translate ) || ( $3 == !t ) {
if ( $4 == help ) && ( %flood.xlatehelp. [ $+ [ $address(%nick,5) ] ] == $null ) {
; if ( %net != $null ) { set -u60 %flood.xlatehelp. [ $+ [ %chan ] ] off }
msg %chan I can translate between these languages: French(f) German(g) Italian(i) Portuguese(p) Spanish(s) English(e). As an example, to translate from english to german, type: !t e-g welcome to the room!
.timer 1 1 msg %chan btw,, I don't do idioms or slang, that would be me guessing you didn't say what you meant, for instance, "hi" is an idiom of english ,, "hi" = "high altitude" in all other languages. To greet someone in other languages, you must use a real greeting,, like "hello" or "welcome".
} }
:eoxlate
}
alias ReBabletranslate {
; echo -s in RE Babletranslate : $1-
Babletranslate $1-
}
alias Babletranslate {
; msg #bottest $1-
; echo -s in Babletranslate $1-
set %2 $2
if ( - isin %2 ) { set %2 $replace( %2 , - , _ ) }
if ( %rslant isin %2 ) { set %2 $replace( %2 , %rslant , _ ) }
if ( %comma isin %2 ) { set %2 $replace( %2 , %comma , _ ) }
set -u0 %2a $gettok(%2,1,$asc(_))
set -u0 %2b $gettok(%2,2,$asc(_))
set -u0 %toknum $findtok(" e sp s po p ge gr g f i d english spanish portugese german french italian ", %2a ,1,32)
if ( %toknum != $null ) {
set %2a $gettok(" en es es pt pt de de de fr it de en es pt de fr it ",%toknum,32)
}
set -u0 %toknum $findtok(" e sp s po p ge gr g f i d english spanish portugese german french italian ", %2b ,1,32)
if ( %toknum != $null ) {
set %2b $gettok(" en es es pt pt de de de fr it de en es pt de fr it ",%toknum,32)
}
set -u0 %2 %2a $+ _ $+ %2b
if ( $istok(" en_fr en_de en_it en_pt en_es fr_en de_en it_en es_en pt_en ", %2 ,32) == $true ) {
; echo -s valid language mix: %2
set %bable.language &lp= $+ %2 $+ &Submit=Translate
set %Bable.ip babelfish.altavista.digital.com
set -u0 %Bable.file.despaced $3-
echo -s Bable.file.despaced1= %Bable.file.despaced
:loopspacechars
if ( %space isin %Bable.file.despaced ) {
set -u0 %Bable.file.despaced $gettok(%Bable.file.despaced,1,32) $+ $chr(37) $+ 2 $+ 0 $+ $gettok(%Bable.file.despaced,2-,32)
goto loopspacechars
}
echo -s Bable.file.despaced2= %Bable.file.despaced
set %Bable.file / $+ cgi-bin/translate?doit=done&urltext= $+ %Bable.file.despaced $+ %bable.language
if ( %Bablecom.accept == yes ) {
inc %Bable.num
set %Bable.room [ $+ [ %Bable.num ] ] $1
if ( %Bable.room [ $+ [ %Bable.num ] ] != StatusWindow ) {
echo %Bable.room [ $+ [ %Bable.num ] ] 12,12..12,0 Accessing Babelfish now...
}
/sockopen Bable [ $+ [ %Bable.num ] ] %Bable.ip 80
}
set %2
goto eoBabletranslate
}
if ( $istok(" fr de it es pt ", %2a ,32) == $true ) && ( $istok(" fr de it es pt ", %2b ,32) == $true ) {
echo -s Bable doesn't do that..... %2
set %Bable.retry [ $+ [ Bable $+ [ $calc(%Bable.num + 1 ) ] ] ] $1 en_ $+ %2b
; echo -s %Bable.num
.timer 1 0 ReBabletranslate $1 %2a $+ _en $3-
}
:eoBabletranslate
}
on 1:START:{
; alias startbable {
; /debug on
unset %Bable.*
set %Bablenum 1
set %Bable.tag.1 *En Francais:*
set %Bable.tag.2 *Auf Deutsch:*
set %Bable.tag.3 *In Italiano:*
set %Bable.tag.4 *Em Portuguces:*
set %Bable.tag.5 *En Espanol:*
set %Bable.tag.6 *In English:*
set %Bable.tag.xlatedwm *
set %Bable.tag.xlated
unset %flood.xlate*
unset %Bable.retry*
set %20 % $+ 2 $+ 0
}
on 1:SOCKOPEN:Bable*: {
if ( %Bablecom.accept == yes ) {
set -u0 %sockname $sockname
if ( %Bablecom.win.show == yes ) { window -ak @ [ $+ [ %sockname ] ] }
if ( %Bablecom.status.show == yes ) {
echo -s *** $sockname was just opened, Retrieving file %Bable.file from %Bable.ip
}
sockwrite %sockname GET %Bable.file HTTP/1.1 $crlf
sockwrite %sockname Accept: text/html $crlf
sockwrite %sockname Accept-Language: en-us $crlf
sockwrite %sockname User-Agent: Mozilla/4.0 (compatible; mIRC5.51; Windows 25; DigExt) $crlf
sockwrite %sockname Connection: Keep-Alive $crlf
sockwrite %sockname Host: $ip $crlf
sockwrite %sockname $crlf
}
else {
sockclose Bable [ $+ [ $sockname ] ]
if ( %Bable.room [ $+ [ $remove($sockname , Bable ) ] ] != StatusWindow ) {
echo %Bable.room [ $+ [ $remove($sockname , Bable ) ] ] 12,12..12,0 Babelfish access closed.
}
}
}
on 1:SOCKCLOSE:Bable*: {
if ( %Bable.room [ $+ [ $remove($sockname , Bable ) ] ] != StatusWindow ) {
echo %Bable.room [ $+ [ $remove($sockname , Bable ) ] ] 12,12..12,0 Babelfish access closed.
}
if ( %Bablecom.status.show == yes ) {
echo -s *** $sockname just closed
}
sockclose Bable [ $+ [ $sockname ] ]
if ( %Bablecom.win.close == yes ) { /window -c @Bable [ $+ [ %sockname ] ] }
}
on 1:SOCKREAD:Bable*: {
set -u0 %bable.startparse
if ( %Bablecom.accept == yes ) {
if ($sockerr > 0) { goto eosockread }
set -u0 %sockname $sockname
:nextread
sockread %tempsockreaddata
;read the data coming from the socket
if ($sockbr == 0) { goto eosockread }
if ( %Bable.dumpdata [ $+ [ $sockname ] ] == yes ) {
; sockclose Bable [ $+ [ $sockname ] ]
goto eosockread2
}
; if i've read all the data, stop
if ( %tempsockreaddata != $null ) && ( %tempsockreaddata != %space ) {
; ok, filter the crap for the real reply here
; echo -s tempsockreaddata= %tempsockreaddata
if ( %bable.startparse == yes ) {
; start looking for the translation
if ( %Bable.tag.xlatedwm iswm %tempsockreaddata ) {
set %Bable.IsHere [ $+ [ $remove($sockname , Bable ) ] ] yes
echo -s Bable translation here..
}
if ( %Bable.IsHere [ $+ [ $remove($sockname , Bable ) ] ] == yes ) {
if ( ** !iswm %tempsockreaddata ) {
if ( %Bable.xlated [ $+ [ $sockname ] ] == $null ) { set %Bable.xlated [ $+ [ $sockname ] ] $remove(%tempsockreaddata , %Bable.tag.xlated ) }
else {
if ( $len(%Bable.xlated [ $+ [ $sockname ] ] ) > 500 ) && ( %Bable.retry [ $+ [ $sockname ] ] == $null ) {
; echo -s %Bable.room [ $+ [ $remove($sockname , Bable ) ] ] %Bable.xlated [ $+ [ $sockname ] ]
msg %Bable.room [ $+ [ $remove($sockname , Bable ) ] ] %Bable.xlated [ $+ [ $sockname ] ]
set %Bable.xlated [ $+ [ $sockname ] ] $remove(%tempsockreaddata , %Bable.tag.xlated )
set -u60 %Bable.dumpdata [ $+ [ $sockname ] ] yes
}
else { set %Bable.xlated [ $+ [ $sockname ] ] %Bable.xlated [ $+ [ $sockname ] ] %tempsockreaddata }
}
}
else {
if ( %Bable.retry [ $+ [ $sockname ] ] != $null ) {
set %tempnewdata %Bable.retry [ $+ [ $sockname ] ] %Bable.xlated [ $+ [ $sockname ] ]
.timer 1 0 Babletranslate %tempnewdata
set -u60 %Bable.dumpdata [ $+ [ $sockname ] ] yes
}
else {
; echo -a $sockname @ %Bable.retry [ $+ [ $sockname ] ]
; echo -s %Bable.room [ $+ [ $remove($sockname , Bable ) ] ] %Bable.xlated [ $+ [ $sockname ] ]
msg %Bable.room [ $+ [ $remove($sockname , Bable ) ] ] %Bable.xlated [ $+ [ $sockname ] ]
set -u60 %Bable.dumpdata [ $+ [ $sockname ] ] yes
}
set %Bable.retry [ $+ [ $sockname ] ]
set %bable.startparse
set %Bable.IsHere [ $+ [ $remove($sockname , Bable ) ] ]
.timer 1 2 set %Bable.xlated [ $+ [ $sockname ] ]
set %bable.startparse
set %bable.language
set %Bable.ip
set %Bable.file
set %tempnewdata
}
}
}
set %babletagnum 1
:loopbabletags
if ( %Bable.tag. [ $+ [ %babletagnum ] ] iswm %tempsockreaddata ) { set -u0 %bable.startparse yes }
else { if ( %babletagnum < 6 ) { inc -u0 %babletagnum | goto loopbabletags } }
if ( $window( @ [ $+ [ %sockname ] ] ).name != $null ) { aline -p @ [ $+ [ %sockname ] ] %tempsockreaddata }
}
; if there was stuff received from the socket, then echo it
goto nextread
:eosockread
}
else {
if ( %Bable.room [ $+ [ $remove($sockname , Bable ) ] ] != StatusWindow ) {
echo %Bable.room [ $+ [ $remove($sockname , Bable ) ] ] 12,12..12,0 Babelfish access closed.
}
set %Bable.room [ $+ [ $remove($sockname , Bable ) ] ]
sockclose Bable [ $+ [ $sockname ] ]
}
:eosockread2
}
alias clsallBablewin {
set -u0 %winno 1
:loopBablewins
if ( %winno < 500 ) {
if ( @Bable* iswm $window(%winno) ) { .timer 1 %winno /window -c $window(%winno) }
inc -u0 %winno
goto loopBablewins
}
}
alias echoBablesettings {
echo -s --------
echo -s 12,12..2,0 Bable Settings are:
if ( %Bablecom.accept == yes ) { echo -s 12,12..2,0 Bable will accept retrieve commands }
else { echo -s 12,12..2,0 Bable will NOT accept retrieve commands }
if ( %Bablecom.win.close == yes ) { echo -s 12,12..2,0 Bable windows will auto-close }
else { echo -s 12,12..2,0 Bable windows will NOT auto-close }
if ( %Bablecom.win.show == yes ) { echo -s 12,12..2,0 Bable windows will show }
else { echo -s 12,12..2,0 Bable windows will NOT show }
if ( %Bablecom.status.show == yes ) { echo -s 12,12..2,0 Bable will show connects in the mirc status window }
else { echo -s 12,12..2,0 Bable will show connects in the mirc status window }
echo -s --------
}
menu status {
-
My Translator:
.Server On/Off
..On:{ set %Bablecom.accept yes }
..Off:{ sockclose Bable* }
.-
.Show @Windows:
..Yes:{ set %Bablecom.win.show yes }
..No:{ set %Bablecom.win.show }
.-
.Auto-Close @Windows:
..Yes:{ set %Bablecom.win.close yes }
..No:{ set %Bablecom.win.close }
.-
.Close all @Bable Windows:{ clsallBablewin }
.-
.Echo all Bable settings:{ echoBablesettings }
.-
.Show Status Connects:
..Yes:{ set %Bablecom.status.show yes }
..No:{ set %Bablecom.status.show }
}
alias bablecomments {
##
##
##
##
##
##
##
##
##
##
## Language markers:
#
# English to French: "En Francais:"
# English to German: "Auf Deutsch:"
# English to Italian: "In Italiano:"
# English to Portuguese: "Em Portugues:"
# English to Spanish: "En Espanol:"
# ?? to English: "In English:"
**********************
//readwebpage http://babelfish.altavista.digital.com/cgi-bin/translate?doit=done&urltext=hello%20to%20you&lp=en_fr&Submit=Translate
# the web reply form looks like this:
## ** the language **
##
##