mIRC Home    About    Download    Register    News    Help

Print Thread
Translating #171755 28/02/07 03:48 PM
Joined: Jan 2007
Posts: 280
DuXxXieJ Offline OP
Fjord artisan
OP Offline
Fjord artisan
Joined: Jan 2007
Posts: 280
Code:
on *:input:*: {
  if ($1 = !translate ) && ($2) {
    if ($chan = $null) {
      run http://tools.search.yahoo.com/language/translation/translate.php?doit=done&tt=text&intl=1&text= $+ $htmlfrm($2-) $+ &lp=nl_en
      halt
    }
    run http://tools.search.yahoo.com/language/translation/translate.php?doit=done&tt=text&intl=1&text= $+ $htmlfrm($2-) $+ &lp=nl_en
    halt
  }
}

on *:text:*!translate-NL-ENG*:#oceanworld,#spelops,#testt: {
  if ($chan = $null) {
    msg $chan http://tools.search.yahoo.com/language/translation/translate.php?doit=done&tt=text&intl=1&text= $+ $htmlfrm($2-) $+ &lp=nl_en
    halt
  }
  msg $chan http://tools.search.yahoo.com/language/translation/translate.php?doit=done&tt=text&intl=1&text= $+ $htmlfrm($2-) $+ &lp=nl_en
}
alias htmlfrm {
  var %i = 1,%r
  while (%i <= $len($1-)) {
    if ($mid($1-,%i,1) isalnum) { %r = %r $+ $ifmatch }
    else { %r = %r $+ % $+ $base($asc($mid($1-,%i,1)),10,16,2) }
    inc %i
  }
  return %r
}


Ok, this code is translating a text, when somebody say's !translate-NL-ENG.
It works, but it says the WEBSITE, and i wanna know the WORD, the translated word.

Somebody know's how to do that?
I've heard then i can do that.. but i don't know HOW...(Witch script)

Last edited by DuXxXieJ; 28/02/07 03:48 PM.

Squee whenever a squee squee's. Squee whenever a squee does not squee.
Re: Translating [Re: DuXxXieJ] #171763 28/02/07 06:27 PM
Joined: Jul 2006
Posts: 107
L
LonDart Offline
Vogon poet
Offline
Vogon poet
L
Joined: Jul 2006
Posts: 107
All I can tell you is that that would require using Sockets, which are way beyond me.

/help sockets

Good Luck!!


LonDart
Re: Translating [Re: LonDart] #171770 28/02/07 10:04 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
Yeah, you'd need to use sockets. And I've never tried pulling data out of a form, so I'm not sure how that works. Maybe it's the same or maybe it isn't.


Invision Support
#Invision on irc.irchighway.net
Re: Translating [Re: DuXxXieJ] #171787 01/03/07 03:35 AM
Joined: Oct 2005
Posts: 1,741
G
genius_at_work Offline
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
You can try this script:

Code:
on *:TEXT:!babel *:#:{
  babel $2-
}

alias babel {
  if (!$1) {
    echo -a Syntax: /babel [type] <words to translate here, max 700 chars>
    if (%babelchan) msg %babelchan Syntax: !babel [type] <words to translate here, max 700 chars>
    return
  }

  set %babeltype en_nl
  if ($regex($1,/^[a-z]{2}_[a-z]{2}$/i)) {
    %babeltype = $1
    tokenize 32 $2-
  }

  set %babel $left($1-,700)
  if ($target) set %babelchan $target
  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 contact Babelfish
  if (%babelchan) msg %babelchan Error: Unable to contact 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  
    if (%babelchan) msg %babelchan Error: No text to translate
    return
  }

  var %babelu = %babel
  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
  }

  if (!%babeltype) set %babeltype en_fr
  var %data = doit=done&intl=1&tt=urltext&trtext= $+ $replace(%babelu,$chr(32),+) $+ &lp= $+ %babeltype $+ &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
  if (%babelchan) msg %babelchan 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) {
    if (%babelchan) {
      msg %babelchan %babelt
    }
    else {
      echo 3 -a " $+ %babel $+ " 
      echo -a ...translates to...
      echo 2 -a " $+ %babelt $+ "
    }
    .timerbabel off
    unset %babel*
    sockclose $sockname
  }
}


Syntax:
/babel [type] <message>
!babel [type] <message>

[type] = a valid babelfish language type (en_nl, en_fr, etc) [optional]
<message> = message to translate, max 700 chars

-genius_at_work

Last edited by genius_at_work; 01/03/07 03:37 AM.
Re: Translating [Re: genius_at_work] #171823 01/03/07 04:49 PM
Joined: Jan 2007
Posts: 280
DuXxXieJ Offline OP
Fjord artisan
OP Offline
Fjord artisan
Joined: Jan 2007
Posts: 280
No sorry,
that doesn't work.
And now ALL my scripts doens't work anymore, since i've loaded and tested it. Andah : [Type] <-- ??


Squee whenever a squee squee's. Squee whenever a squee does not squee.
Re: Translating [Re: genius_at_work] #171829 01/03/07 07:40 PM
Joined: Jan 2007
Posts: 1,156
D
DJ_Sol Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
Woohooo!!! Man you kick butt!! I tried to get a socket open to babelfish and couldn't figure out how to get past the whole java interface. Woohoo!!!!

/babel en_nl love is wonderful
"love is wonderful"
...translates to...
"de liefde is prachtig"

/babel en_fr love is wonderful
"love is wonderful"
...translates to...
"l'amour est merveilleux"

[11:38] sAge: omg!!!!!
[11:38] sAge: wooohooooo

Thank You SoOOOOOOO Much!!!

(I ended up making a multilingual dictionary through Wikidictionary but it needs to be cleaned up a bit. Maybe Ill post it when I do.)

Re: Translating [Re: DuXxXieJ] #171878 02/03/07 02:02 AM
Joined: Oct 2005
Posts: 1,741
G
genius_at_work Offline
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
Nothing about the script would stop your scripts from working (unless you already had an alias called /babel). Make sure you have the script in its own new remotes file. The person below you seems to have no problems using the script.

-genius_at_work

What I did with the translator! [Re: DJ_Sol] #171926 02/03/07 08:27 PM
Joined: Jan 2007
Posts: 1,156
D
DJ_Sol Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
I have been wanting this translator for a while so yesterday, as soon as I got it I set to work! The goal is to put all functions in one toolbar underneath the edit box, but I've never made a dockable toolbar before so it may take some time.

Pick ONE name from the nicklist and it will translate what they say. Set up your 2nd edit box to always show the command to translate and talk to people in the room in a different language! Or simply open the translator dialog to translate what you like!


Re: What I did with the translator! [Re: DJ_Sol] #171928 02/03/07 09:20 PM
Joined: Jan 2007
Posts: 280
DuXxXieJ Offline OP
Fjord artisan
OP Offline
Fjord artisan
Joined: Jan 2007
Posts: 280
Okkies, *btw : Cool mIRC wink *Screenshot* ^^)


Squee whenever a squee squee's. Squee whenever a squee does not squee.
Re: What I did with the translator! [Re: DuXxXieJ] #171931 02/03/07 09:49 PM
Joined: Jan 2007
Posts: 1,156
D
DJ_Sol Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
Thanks DuXxXieJ

Re: Translating [Re: genius_at_work] #171938 03/03/07 02:05 AM
Joined: Oct 2006
Posts: 342
L
learn3r Offline
Fjord artisan
Offline
Fjord artisan
L
Joined: Oct 2006
Posts: 342
this is cool may i ask what are the other types like english to spanish


learn learn learn
Re: Translating [Re: learn3r] #171939 03/03/07 02:36 AM
Joined: Oct 2005
Posts: 1,741
G
genius_at_work Offline
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
zh_en Chinese-simp to English
zt_en Chinese-trad to English
en_zh English to Chinese-simp
en_zt English to Chinese-trad
en_nl English to Dutch
en_fr English to French
en_de English to German
en_el English to Greek
en_it English to Italian
en_ja English to Japanese
en_ko English to Korean
en_pt English to Portuguese
en_ru English to Russian
en_es English to Spanish
nl_en Dutch to English
nl_fr Dutch to French
fr_en French to English
fr_de French to German
fr_el French to Greek
fr_it French to Italian
fr_pt French to Portuguese
fr_nl French to Dutch
fr_es French to Spanish
de_en German to English
de_fr German to French
el_en Greek to English
el_fr Greek to French
it_en Italian to English
it_fr Italian to French
ja_en Japanese to English
ko_en Korean to English
pt_en Portuguese to English
pt_fr Portuguese to French
ru_en Russian to English
es_en Spanish to English
es_fr Spanish to French

-genius_at_work

Re: Translating [Re: genius_at_work] #171940 03/03/07 03:18 AM
Joined: Oct 2006
Posts: 342
L
learn3r Offline
Fjord artisan
Offline
Fjord artisan
L
Joined: Oct 2006
Posts: 342
cool thanks


oh i got this

i typed
!babel aaaaaa

bot responded:
aaaaaa


doesn't it should reply with wrong syntax or something?

Last edited by learn3r; 03/03/07 03:30 AM.

learn learn learn
Re: Translating [Re: genius_at_work] #171941 03/03/07 03:19 AM
Joined: Jan 2007
Posts: 1,156
D
DJ_Sol Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
I got errors translating to greek. I didnt bother exploring them at all since I don't need it. I think they might have been "line too long" errors.

Re: Translating [Re: learn3r] #171943 03/03/07 04:02 AM
Joined: Oct 2005
Posts: 1,741
G
genius_at_work Offline
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
There is nothing wrong with that command and response. The script displays exactly what Babelfish translates. If Babelfish can't translate a word, it simply leaves it untranslated. You can enter anything you like, but if Babelfish can't translate it, nothing will change.


@DJ_Sol

Some languages are very long by nature. Short of limiting the input to fewer characters, there is nothing that can be done. Actually, you could add a :error handler that simply says "line too long" or something of that sort.

-genius_at_work