tglogo.png

Downloading File

Filename: Google Translator - Auto Text-Translator v3
;BOF
 
 
;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~~*~*~*~*~*~*~*~*~*;
;     Google Translator - Traditional Translator + Auto Text-Translator     ;
;                          Made by Kirby (Quakenet)                         ;
;*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*;
 
;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*;
;Google Translator Aliases/Identifiers/Input/Menu;
;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*;
 
;// Open up the Google Translator Dialog - Syntax: /trans //
alias trans { dialog $iif($dialog(translator),-v,-m) translator translator }
 
;// Other aliases/identifiers //
alias -l ab2word { var %x Translator\languages.txt, %y Translator\abbreviations.txt | noop $read(%y,w,$1) | return $iif($read(%x,$readn),$v1) }
alias -l char { return $replace($regsubex($1,/&#(x?([a-f\d]*));/gi,$chr($iif($left(\1,1) == x,$base(\2,16,10),\2))),&amp;,&,&lt;,<,&gt;,>,&quot;,") }
alias -l between { noop $regex($1,/\Q $+ $2 $+ \E(.*?)\Q $+ $3 $+ \E/gi) | return $regml($4) }
alias -l gdid { did -r translator 24 | didtok translator 24 44 $hget(Translator,Channels) | did -b translator 26-27 }
alias -l gfix { hfree Translator | trans | echo -a * Problem has been fixed. }
alias -l gwrite { var %x $1 | tokenize 32 $2- | write $+(Translator\,%x) $* }
alias -l hex { return $regsubex($1-,/([^\d\w])/gi,$+(%,$base($asc(\1),10,16))) }
alias -l smsg { msg $iif(c isincs $chan($1).mode,$1 $strip($2-),$1-) }
alias -l word2ab { var %x Translator\languages.txt, %y Translator\abbreviations.txt | noop $read(%x,w,$1) | return $iif($read(%y,$readn),$v1) }
 
;// On Input - Edit settings in the dialog to automatically translate your text to another language! //
on *:input:*: {
  if ($hget(Translator,Status)) && (!$regex($1-,^[\/(.*)])) && (!$sock(translator)) && (!$istok($hget(Translator,Channels),#,44)) {
    sockopen translator translate.google.com 80 | sockmark translator input $+($word2ab($hget(Translator,Lang)),|,$word2ab($hget(Translator,Lang2))) $hex($1-) | haltdef
  }
}
 
;// Google Translator Menu //
menu * {
  Google Translator
  .Traditional Google Translator : trans
  .-
  .$iif($hget(Translator,Status),$style(1)) Auto Text-Translator $+($chr(40),$iif($hget(Translator,Lang),$v1,*None*),$chr(32),$chr(187),$chr(32),$iif($hget(Translator,Lang2),$v1,*None*),$chr(41))
  ..$iif($hget(Translator,Status),$style(2)) Turn Auto Text-Translator On: hadd -m Translator Status $true | echo -a * Google Auto Text-Translator is now 09ON.
  ..$iif(!$hget(Translator,Status),$style(2)) Turn Auto Text-Translator Off: hadd -m Translator Status $false | echo -a * Google Auto Text-Translator is now 04OFF.
  .-
  .$iif($group(#Translator) == On,$style(1)) Google Translator (Bot Command)
  ..$iif($group(#Translator) == On,$style(2)) Turn Bot Command On: .enable #Translator | echo -a * Google Bot Translator is now 09ON.
  ..$iif($group(#Translator) == Off,$style(2)) Turn Bot Command Off: .disable #Translator | echo -a * Google Bot Translator is now 04OFF.
  .-
  .Encountered a problem? Click here to fix it. : gfix
}
 
 
;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~;
;Translate text to any 41 languages available - Syntax: /translate <language|language2> <text>;
;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~;
 
alias translate {
  var %x $gettok($1,1,124), %y $gettok($1,2,124)
  if ($isfile(Translator\languages.txt)) && ($isfile(Translator\abbreviations.txt)) {
    if ($numtok($1-,32) <= 1) { echo -a * Syntax example: /translate en|es Hello, my name is $+($me,!) }
    elseif (!$ab2word(%x)) || (!$ab2word(%y)) { echo -a * Strings do not match. $iif($ab2word(%x) == $ab2word(%y),%x and %y are not valid.,$iif(!$ab2word(%x),%x is invalid.,$iif(!$ab2word(%y),%y is invalid.))) }
    else { sockopen translator translate.google.com 80 | sockmark translator alias $1 $hex($2-) }
  }
  elseif (!$isfile(Translator\languages.txt)) || (!$isfile(Translator\abbreviations.txt)) {
    $iif($isdir(Translator),noop $findfile(Translator,*,0,0,.remove $1-),mkdir Translator)
    sockclose translator | sockopen translator translate.google.com 80 | sockmark translator load alias
    echo -a * Downloading Abbreviations and Languages from translate.google.com...
  }
}
 
 
;~*~*~*~*~*~*~*~*~*~*~*~*~;
;Google Translator Sockets;
;~*~*~*~*~*~*~*~*~*~*~*~*~;
on *:sockopen:translator: {
  tokenize 32 $sock(translator).mark
  sockwrite -n $sockname GET $+(/translate_t?langpair=,$2,&text=,$3) HTTP/1.0
  sockwrite -n $sockname Host: translate.google.com
  sockwrite -n $sockname $crlf
}
on *:sockread:translator: {
  sockread %translator
  tokenize 32 $sock(translator).mark
  if ($regex(%translator,<div id=result_box dir="ltr">(.*)</div><div id=clir>)) && ($1 != load) {
    if ($1 == dialog) { did -ra translator 9 $regsubex($char($regml(1)),/([\s])?<br>([\s])?/g,$crlf) }
    elseif ($1 == alias) { echo -a * Translation $+($chr(40),,$ab2word($gettok($2,1,124)), $chr(187) ,$ab2word($gettok($2,2,124)),,$chr(41),:)) $char($regml(1)) }
    elseif ($1 == input) { msg $active $char($regml(1)) }
    elseif ($1 ischan) { smsg $1 Translation $+($chr(40),,$ab2word($gettok($2,1,124)), $chr(187) ,$ab2word($gettok($2,2,124)),,$chr(41),:)) $char($regml(1)) }
  }
  elseif ($regex(%translator,value="(.+)">) && ($1 == load)) {
    var %x $regsubex($between(%translator,</option>,</select>,1),/(<option (value|SELECTED value)="(.*?)">|<\/option>)/g,$chr(32)), %y $remove($regsubex($between(%translator,;</option>,</select>,1),/(<option (value|SELECTED value)=|>(.*?)<\/option>)/g,$chr(32)),$chr(34))
    gwrite languages.txt $+(Detect,$chr(160),language) %x | gwrite abbreviations.txt auto %y
    echo -a * Abbreviations and Languages have been successfully written to $+($mircdirTranslator,\,.) :-)
    if ($dialog(translator)) { dialog -x translator translator | dialog -m translator translator | halt }
    $iif($2 == cmd,.notice $3,echo -a *) Sorry for the inconvenience - required Abbreviations and Languages' files could not be located, but the problem has been fixed. Retry? :D
  }
}
on *:sockclose:translator: { if ($dialog(translator)) { did -e translator 8,12 | did -ra translator 13 Done! } | unset %translator }
 
 
;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~;
;Google Translator Dialog Information/Events;
;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~;
 
;// Dialog format //
dialog translator {
  title "Google Translator"
  size -1 -1 411 95
  option dbu
  tab "Google Translator (Traditional :D)", 10, 2 -1 407 94
  text "Enter text to translate.", 6, 8 16 57 8, tab 10
  edit "", 1, 7 26 187 40, tab 10 multi autovs
  combo 2, 7 74 60 75, tab 10 size drop
  combo 3, 81 74 60 75, tab 10 size drop
  text ">", 7, 72 74 4 8, tab 10
  link "swap", 4, 149 75 13 8, tab 10
  button "Translate", 8, 175 73 40 12, tab 10
  edit "", 9, 216 26 187 40, tab 10 read multi autovs
  text "Translation:", 5, 217 16 120 8, tab 10
  button "Copy translation to Clipboard", 12, 229 73 83 12, tab 10
  edit "", 13, 321 74 82 10, tab 10 read autohs center
  tab "Google Auto Text-Translator (talk in any language! :D)", 11
  text "Your language:", 15, 13 28 67 8, tab 11
  text "New language:", 16, 102 28 66 8, tab 11
  combo 17, 16 40 60 75, tab 11 size drop
  combo 18, 105 40 60 75, tab 11 size drop
  text "Auto-Translation Status:", 19, 202 35 60 8, tab 11
  radio "Turn script on", 20, 186 47 43 10, tab 11
  radio "Turn script off", 21, 233 47 44 10, tab 11
  text "QUACK from QUAKENET!", 22, 208 61 48 20, tab 11 center
  list 24, 295 25 54 60, tab 11 sort size hsbar vsbar
  button "Add channel", 25, 353 31 44 12, tab 11
  button "Delete channel", 26, 353 49 44 12, tab 11
  button "Modify channel", 27, 353 67 44 12, tab 11
  box "Translation Options:", 28, 181 24 101 58, tab 11
  box "Exception Channels:", 23, 290 16 112 73, tab 11
  box "Chat in any language!", 14, 9 16 164 73, tab 11
  text ">", 29, 89 41 4 8, tab 11
  link "swap", 30, 85 54 13 8, tab 11
  box "Credits", 31, 20 65 142 19, tab 11
  text "Made by: Kirby", 32, 40 72 37 8, tab 11
  text "Network: Quakenet", 33, 95 72 48 8, tab 11
}
 
;// Dialog Events //
on *:dialog:translator:*:*: {
  var %t Translator\languages.txt, %s Translator\abbreviations.txt
  if ($devent == init) {
    if (!$isdir(Translator)) || (!$isfile(%t)) || (!$isfile(%s)) {
      did -b translator 2-3,8
      $iif($isdir(Translator),noop $findfile(Translator,*,0,0,.remove $1-),mkdir Translator)
      sockclose translator | sockopen translator translate.google.com 80 | sockmark translator load
      echo -a * Downloading Abbreviations and Languages from translate.google.com...
      haltdef
    }
    if ($hget(Translator,Channels)) { didtok translator 24 44 $v1 }
    $iif($hget(Translator,Status),did -c translator $iif($v1,20,21),hadd -m Translator Status $false)
    if (!$hget(Translator,Lang)) || (!$hget(Translator,Lang2)) { hadd -m Translator Lang English | hadd -m Translator Lang2 Spanish }
    var %x 1
    while (%x <= $lines(%t)) {
      if ($hget(Translator,Lang) isin $read(%t,%x)) { var %l $readn }
      elseif ($hget(Translator,Lang2) isin $read(%t,%x)) { var %m $readn }
      did -a translator 2-3,17-18 $read(%t,%x) | inc %x
    }
    did -c translator 2 11 | did -c translator 3 37 | did -b translator 8,12,26-27 | did -ra translator 13 Ready. | did -c translator 17 %l | did -c translator 18 %m | did -c translator $iif($hget(Translator,Status),20,21)
  }
  if ($devent == sclick) {
    if ($did == 4) { var %x $did(2), %y $did(3) | noop $read(%t,w,%x) | did -c translator 3 $readn | noop $read(%t,w,%y) | did -c translator 2 $readn }
    if ($did == 8) {
      if ($did(2) == $did(3)) { did -ra translator 9 $did(1) | haltdef }
      var %x 1, %y $did(1).lines
      while (%x <= %y) { var %z $+(%z,$did(1,%x),$chr(37),$chr(48),$chr(65)) | inc %x }
      if (!$sock(translator)) { sockopen translator translate.google.com 80 | sockmark translator dialog $+($word2ab($did(2)),|,$word2ab($did(3))) $replace($hex(%z),$+($chr(37),$chr(50),$chr(53),$chr(48),$chr(65)),$+($chr(37),$chr(48),$chr(65))) }
      did -b translator 8 | did -o translator 5 1 Translation: $did(2) $chr(187) $did(3) | did -ra translator 13 Translating...
    }
    if ($did == 12) {
      var %x 1, %y $did(9).lines
      while (%x <= %y) { var %z $iif(%y == 1,$did(9,%x),$+(%z,$crlf,$did(9,%x))) | inc %x }
      clipboard %z | did -ra translator 13 Copied to clipboard!
    }
    if ($did isnum 17-18) { hadd -m Translator $iif($did isnum 17,Lang,Lang2) $did($did) }
    if ($did isnum 20-21) { hadd -m Translator Status $iif($did isnum 20,$true,$false) }
    if ($did == 24) && ($did(24).sel) { did -e translator 26-27 }
    if ($did == 25) { var %x $hget(Translator,Channels), %y $input(Enter a channel name that you want to add to the exception's list. (Channel names may be separated with a comma.),eiow,Attention!) | hadd -m Translator Channels $addtok(%x,$iif($regex(%y,^#),%y,$+($chr(35),%y)),44) | gdid }
    if ($did == 26) { var %x $hget(Translator,Channels) | hadd -m Translator Channels $deltok(%x,$findtok(%x,$did(24).seltext,44),44) | gdid }
    if ($did == 27) { var %x $hget(Translator,Channels), %y $input(Enter a channel name that you want to replace with $+($qt($did(24).seltext),.),eiow,Attention!) | hadd -m Translator Channels $reptok(%x,$did(24).seltext,%y,44) | gdid }
    if ($did == 30) { hadd -m Translator Lang $did(18) | hadd -m Translator Lang2 $did(17) | var %x $did(17), %y $did(18) | noop $read(%t,w,%x) | did -c translator 18 $readn | noop $read(%t,w,%y) | did -c translator 17 $readn }
  }
  if ($devent == edit) { did $iif($did(1),-e,-b) translator 8 | did -b translator 12 | did -r translator 9 | did -ra translator 13 Ready. }
}
 
 
;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*;
;Bot Translator - Syntax: !translate <language|language2> <text> ;
;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*;
#Translator Off
on $*:text:/^[.!@]translate*/Si:#: {
  if ($isfile(Translator\languages.txt)) && ($isfile(Translator\abbreviations.txt)) {
    if (!$2) {
      .notice $nick Syntax: !translate <language|language2> <text> (example: !translate en|es Hello, my name is $+($nick,!,$chr(41))
      var %w 1, %x 1, %y Translator\languages.txt, %z Translator\abbreviations.txt
      while (%w <= $lines(%y)) { var %a $addtok(%a,$read(%y,%w),32) | inc %w }
      .notice $nick Possible languages: $regsubex(%a,/[\s]/g,$+(\1,$chr(44),$chr(32)))
      while (%x <= $lines(%z)) { var %b $addtok(%b,$read(%z,%x),32) | inc %x }
      .notice $nick Possible combinations: $regsubex(%b,/[\s]/g,$+(\1,$chr(44),$chr(32)))
    }
    elseif (!$3-) {
      var %x $gettok($2,1,124), %y $gettok($2,2,124)
      if (!$ab2word(%x)) || (!$ab2word(%y)) { .notice $nick Strings do not match. $iif($ab2word(%x) == $ab2word(%y),%x and %y are not valid.,$iif(!$ab2word(%x),%x is invalid.,$iif(!$ab2word(%y),%y is invalid.))) | halt }
      .notice $nick You need to supply a string to translate!
    }
    elseif ($3-) {
      var %x $gettok($2,1,124), %y $gettok($2,2,124)
      if ($ab2word(%x)) && ($ab2word(%y)) && (!$sock(translator)) { sockopen translator translate.google.com 80 | sockmark translator # $2 $hex($3-) | halt }
      .notice $nick Strings do not match. $iif($ab2word(%x) == $ab2word(%y),%x and %y are not valid.,$iif(!$ab2word(%x),%x is invalid.,$iif(!$ab2word(%y),%y is invalid.)))
    }
  }
  elseif (!$isfile(Translator\languages.txt)) || (!$isfile(Translator\abbreviations.txt)) {
    $iif($isdir(Translator),noop $findfile(Translator,*,0,0,.remove $1-),mkdir Translator)
    sockclose translator | sockopen translator translate.google.com 80 | sockmark translator load cmd $nick
    echo -a * Downloading Abbreviations and Languages from translate.google.com...
  }
}
#Translator End
 
 
;EOF


Related Files

by FordLawnmower
by FordLawnmower

Please note that on our website we use cookies necessary for the functioning of our website, cookies that optimize the performance. To learn more about our cookies, how we use them and their benefits, please read our Cookie Policy.
I Understand