From f21572a12c521bf244ca230991e830872754341c Mon Sep 17 00:00:00 2001 From: Dmitry Kim Date: Thu, 29 Mar 2007 22:19:06 +0000 Subject: + support for non-iso-8859-1 languages (ru, zt, ja, ko, el) --- data/rbot/plugins/fish.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/data/rbot/plugins/fish.rb b/data/rbot/plugins/fish.rb index 68240659..8c115f90 100644 --- a/data/rbot/plugins/fish.rb +++ b/data/rbot/plugins/fish.rb @@ -3,11 +3,12 @@ require 'uri/common' Net::HTTP.version_1_2 class BabelPlugin < Plugin + LANGS = %w{en fr de it pt es nl ru zh zt el ja ko} def help(plugin, topic="") - "translate to => translate from english to , translate from => translate to english from , translate => translate from to . Languages: en, fr, de, it, pt, es, nl" + "translate to => translate from english to , translate from => translate to english from , translate => translate from to . Languages: #{LANGS.join(', ')}" end def translate(m, params) - langs = ["en", "fr", "de", "it", "pt", "es", "nl"] + langs = LANGS trans_from = params[:fromlang] ? params[:fromlang] : 'en' trans_to = params[:tolang] ? params[:tolang] : 'en' trans_text = params[:phrase].to_s @@ -31,9 +32,13 @@ class BabelPlugin < Plugin http = @bot.httputil.get_proxy(URI.parse("http://babelfish.altavista.com")) + headers = { + "content-type" => "application/x-www-form-urlencoded; charset=utf-8", + 'accept-charset' => 'utf-8' + } + http.start {|http| - resp = http.post(query, data, {"content-type", - "application/x-www-form-urlencoded"}) + resp = http.post(query, data, headers) if (resp.code == "200") lines = Array.new -- cgit v1.2.3