使用rtranslate
Thursday, November 15th, 2007 Usage:
sishen@lifegoo:~$ irb -rubygems
irb(main):001:0> require ‘rtranslate’
=> true
irb(main):002:0> $KCODE = ‘u’
=> “u”
irb(main):003:0> result = Translate.t(”china”, Language::ENGLISH, Language::CHINESE_SIMPLIFIED)
=> “中国”
irb(main):004:0> result = Translate.t(”china”, Language::ENGLISH, Language::JAPANESE)
=> “中華人民共和国”
irb(main):005:0> result = Translate.t(”china”, Language::ENGLISH, “zh-TW”)
=> “中國”
http://code.google.com/p/rtranslate/
用ruby程序向gtalk发送消息
Monday, October 29th, 2007require ‘xmpp4r’
to = ’someone@gmail.com’
body = ‘This message is from xmpp4r.’
subject = ‘test’
message = Jabber::Message.new to, body
message.subject = subject
id = ‘myname@gmail.com’
password = ‘mypassword’
client = Jabber::Client.new Jabber::JID.new(id), false
client.connect
client.auth password
client.send message
client.close