egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

GTranslate is not working because of TCL issues
Goto page Previous  1, 2
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
rayvtirx
Voice


Joined: 31 May 2010
Posts: 16
Location: bristol,england

PostPosted: Sat Oct 08, 2011 10:44 am    Post subject: Reply with quote

just happened to find a different version of the same script while googling and this one works http://heartbroken.bshellz.net/gtranslate.tcl
Back to top
View user's profile Send private message Visit poster's website
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Sat Oct 08, 2011 11:34 am    Post subject: Reply with quote

Oh ! I didn't notice the version on egghelp wasn't the last one I did.

The official download is http://www.eggdrop.fr/board/downloads.php?action=view&did=209

I'll send the good version to slennox in a few hours.
_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
rayvtirx
Voice


Joined: 31 May 2010
Posts: 16
Location: bristol,england

PostPosted: Sat Oct 08, 2011 11:52 am    Post subject: Reply with quote

ah cool - thanks
ill wait until its on egghelp as.. i need a translator to go on that site Razz
Back to top
View user's profile Send private message Visit poster's website
ujjain
Voice


Joined: 11 Oct 2010
Posts: 12

PostPosted: Sat Oct 08, 2011 6:17 pm    Post subject: Reply with quote

I have new code, it works perfectly and is extremely light-weight and simple.

Code:

administrator@artemis:~$ cat /home/administrator/eggdrop/scripts/gtranslate.tcl
namespace eval gTranslator {

# Factor this out into a helper
proc getJson url {
  set tok [http::geturl $url]
  set res [json::json2dict [http::data $tok]]
  http::cleanup $tok
  return $res
}
# How to decode _decimal_ entities; WARNING: high magic factor within!
proc decodeEntities str {
  set str [string map {\[ {\[} \] {\]} \$ {\$} \\ \\\\} $str]
  subst [regsub -all {&#(\d+);} $str {[format %c \1]}]
}

bind pub - !tr gTranslator::translate
proc translate { nick uhost handle chan text } {
  package require http
  package require json
  set lngto [string tolower [lindex [split $text] 0]]
  set text [http::formatQuery q [join [lrange [split $text] 1 end]]]
  set dturl "http://ajax.googleapis.com/ajax/services/language/detect?v=1.0&q=$text"

  set lng [dict get [getJson $dturl] responseData language]

  if { $lng == $lngto } {
    putserv "PRIVMSG $chan :\002Error\002 translating $lng to $lngto."
    return 0
  }
  set trurl "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&langpair=$lng%7c$lngto&$text"
  putlog $trurl

  set res [getJson $trurl]

  putlog $res
  #putserv "PRIVMSG $chan :Language detected: $lng"

  set translated [decodeEntities [dict get $res responseData translatedText]]

  putserv "PRIVMSG $chan :$translated"
#  putserv "PRIVMSG $chan :[encoding convertto utf-8 $translated]"
}
}
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Wed Apr 04, 2012 3:12 pm    Post subject: Reply with quote

A small message to say that gTranslator doesn't work anymore and will not be released again.
Google choosed to block the API v1 and the v2 is a commercial one, I refuse to make a script which use commercial services.

@slennox: could you please remove Google Translator from the tcl archive ?

Regards,
CrazyCat
_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber