Translator

By mountaindew on Mar 04, 2008

This is a translator script that I made, it uses Google Translator. It translates English, Spanish, French, Italian, Portuguese, Dutch, and German. But most languages only translate into English.

Syntax: [!translate|/translate] [from-to] [words]

Examples:

/translate fr-en au revoir !translate es-en Tengo un script muy interesante!

Also, there's a dialog. Right click on any window and click "Translator". You click the original language from the left, and then click the language you want to translate to on the right. Type what you want to translate in the edit box, and click "Translate". The translation will show up in the read-only edit box below it.

Screens

Image

Image

Image

Enjoy Image

;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
;                Translator                      *
;            Made by MountainDew                 ~ 
; IRC.DeltaAnime.Net » #Lindrian #mIRC-Scripting *
;  US.UnderNet.Org » #Hawkee.com #mircscripting  ~
;*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*

menu * {
  Translator: trans_dialog
}
alias trans_dialog dialog $iif($dialog(trans),-v,-m) trans trans
dialog trans {
  title "Translator"
  size -1 -1 99 137
  option dbu
  list 1, 8 22 35 49, size
  list 2, 56 22 35 49, size
  box "To", 3, 53 13 41 61
  box "From", 4, 5 13 41 61
  text "Translator", 5, 37 3 29 8
  edit "", 6, 9 79 83 10, multi autohs autovs
  button "OK", 7, 40 126 20 9, ok cancel
  button "Translate", 8, 36 91 28 9, disable
  box "Translation", 9, 5 103 89 20
  edit "", 10, 8 111 83 10, read multi autovs
}
on *:dialog:trans:*:*:{
  if ($devent == init) {
    didtok trans 1,2 32 English Spanish French Portuguese German Dutch Italian
  }
  if ($devent == sclick) {
    if ($did isnum 1-2) {
      if ($did(trans,2).seltext) && ($did(trans,1).seltext) && ($did(trans,6).text) did -e trans 8
      did -r trans 10
    }
    if ($did == 8) {
      if ($did(trans,1).seltext == $did(trans,2).seltext) {
        noop $input(You can't translate to the same language!,ho,Error!)
        did -b trans 8
        halt
      }
      did -b trans 8
      did -r trans 10
      set %t.d 1
      sockopen trans translate.google.com 80
      sockmark trans $+($lang($did(trans,1).seltext),~,$lang($did(trans,2).seltext),~,$did(trans,6))
    }
  }
  if ($devent == edit) {
    did $iif($did(trans,6).text && $did(Trans,2).seltext,-e,-b) trans 8
    did -r trans 10
  }
}
alias translate {
  if ($sock(trans)) {
    %t.msg There's already a translation in progress.
    halt
  }
  set %t.msg $iif(%t.chan,msg $v1,echo -a)
  if (!$regex($$1,/^(?:it|pt|es|nl|de|fr|en)-(?:it|pt|es|nl|de|fr|en)\b/i)) {
    %t.msg Syntax: $iif(%t.chan,!,/) $+ translate from-to [words]
    %t.msg Languages: English (en) French (fr) Spanish (es) Italian (it) Portuguese (pt) German (de) Dutch (nl)
    halt
  }
  elseif (!$2) {
    %t.msg Syntax: $iif(%t.chan,!,/) $+ translate from-to [words]
    halt
  }
  if ($left($1,2) == $right($1,2)) {
    %t.msg You can't translate into the same language!
    halt
  }
  sockopen trans translate.google.com 80
  sockmark trans $+($left($1,2),~,$right($1,2),~,$2-)
  $iif(%t.chan,describe $v1 translates,echo -a Translating) $qt($2-) from $replace($1,-,$chr(32) to $chr(32),es,Spanish,en,English,fr,French,it,Italian,pt,Portuguese,nl,Dutch,de,German) $+ ...
}
on *:sockopen:trans:{
  sockwrite -nt $sockname GET $+(/translate_t?langpair=,$gm($sockname,1,126),$chr(124),$gm($sockname,2,126),&text=,$replace($gm($sockname,3,126),$chr(32),+)) HTTP/1.1
  sockwrite -nt $sockname Host: translate.google.com
  sockwrite -nt $sockname $crlf
}
on *:sockread:trans:{
  sockread &x
  if ($bfind(&x,1,<div id=result_box)) { 
    sockmark $sockname $+($sock($sockname).mark,~,$replace($bvar(&x,$calc($v1 + 29),$calc($bfind(&x,$v1,</div>)- $v1 -29)).text,&#39;,'))
    if (%t.d) {
      did -a trans 10 $gm($sockname,4,126)
      did -e trans 8
    }
    else %t.msg 4Translation: $gm($sockname,4,126)
    sockclose $sockname
    unset %t.*
  }
}
alias lang return $replace($1,Spanish,es,English,en,French,fr,Portuguese,pt,Italian,it,Dutch,nl,German,de)
alias gm return $gettok($sock($1).mark,$2,$3)
alias trans translate $1-
on $*:text:/^[!@.]trans(lat(e|ion))?\b/Si:#:{
  set %t.chan $chan
  translate $2-
}

Comments

Sign in to comment.
Warriorii   -  Jun 03, 2012

i got a socket open error on line 45 when i tried to get it to translate (come in) from english to french

More
 Respond  
Pangaea   -  Mar 31, 2012

lo scott if ur still looking for a 100% worker, fords one is good.. been using it alot and still am since my last post there. U can find fords here on hawkee,If u cant get fords working i guess i could post the one i have currently running, cant rem if i tweeked it... btw when i say its a worker, it is on my 6.2 bot

More
 Respond  
ScottK   -  Mar 31, 2012

The same thing happens with the Google Translator Windows Gadget - Google decided to be anal concerning API access to the Translator code.

Yay, Google - thanks for remaining to "not be evil"

More
 Respond  
Pangaea   -  Feb 01, 2011

lol.. argg, is there any translator script that is working? i guess all the sockets have expired or somthing

More
 Respond  
Kingc44   -  Jun 16, 2010

It keeps saying that there's already a translation in progress :/

More
 Respond  
CvdEeden   -  Dec 21, 2009

It is translating for houuuuuursssssssss. I said, !translate nl-en hoe is het

And it took 2 hours for it FINALLY responded.

More
 Respond  
AdrianF   -  Mar 20, 2009

koooool snipppppett

More
 Respond  
Monkee   -  Jan 31, 2009

Wonderful script. Works perfectly for me. I just have one question, on the dialog, if I wanted to add a button "Send" whereby it sent the translated text to the channel/user, how would I go about that? (command line wise)

When I figure out how to rate I'll be giving this top marks. Good job.

More
 Respond  
pwnisher3   -  Dec 07, 2008

omg yay. it works perfect. and correct translations :D great job MD

More
 Respond  
CoOlEsT_n_CuTeSt   -  Dec 05, 2008

hey, i want indonesian to english each line with notice

More
 Respond  
Free`Spirit   -  Oct 28, 2008

It works without any problem. Thank you! :) One more thing: Did you ever try http://reverso.net ?

More
 Respond  
Jamiie   -  Oct 02, 2008

Done, I took out the line that says "translation" and switched a few switches around to short alias' to make people think I'm speaking a different language. :P

More
 Respond  
mountaindew   -  Oct 02, 2008

Thanks Jamiie.

In this line:

set %t.msg $iif(%t.chan,msg $v1,echo -a)

change "echo -a" to "msg $active".

More
 Respond  
Jamiie   -  Oct 01, 2008

Nicely done mountaindew. 10/10+like.. how would you go about making it message chan or active using the alias? instead of the ! event.

More
 Respond  
SuPeRFlY   -  Sep 29, 2008

Great script. Excelent work. 10/10

More
 Respond  
mountaindew   -  Sep 29, 2008

Yea I did add more languages once but I like lost the script when I updated mIRC or something. I'll try to add them again when I get a chance.

More
 Respond  
Bullet_Dodger   -  Sep 28, 2008

The only reason Japanese , Chinese isnt on there is because on mIRC it comes out ? or � instead of the letters

More
 Respond  
^Neptune   -  Sep 28, 2008

Yeah would be quite nice to add all available languages on the site. Nice job though.

More
 Respond  
Bullet_Dodger   -  Sep 28, 2008

Very Good Script [10/10] +Like

More
 Respond  
new2k4   -  Sep 23, 2008

why not put more languages there? i modified it for myself by adding some more. Though i left out the one that need language pack installed, like Chinese, Japanese...

and it's very nice :) ty

More
 Respond  
TropicalMeltdown   -  Aug 23, 2008

awww sorry mi bad

More
 Respond  
mountaindew   -  Aug 23, 2008

TropicalMeltdown, I didn't make the translations themselves, it sockets to Google Translator. There's no such thing as a perfect translator anyways.

More
 Respond  
TropicalMeltdown   -  Aug 23, 2008

dude its not the rite spanish 5/10

More
 Respond  
mountaindew   -  Jun 25, 2008

Updated, there was a problem with the &binvars

More
 Respond  
ShAmPi   -  Jun 25, 2008

Well. It works now :D Might have been googles problem ;)

More
 Respond  
mountaindew   -  Jun 23, 2008

Really? It seems to work fine for me. Are there any errors in you guys\' status windows?

More
 Respond  
ShAmPi   -  Jun 23, 2008

Yeah same for me. Again an empty output :(

More
 Respond  
knoeki   -  Jun 21, 2008

it stopped working for me...

More
 Respond  
SweeTCooL   -  Jun 09, 2008

oh ok thx dude :D

More
 Respond  
mountaindew   -  Jun 06, 2008

That\'s a great idea, I never thought of using /didtok :P

Edit: Updated it using didtok

More
 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.