From 657e1d70928f2878d4c256825632265fe59b2269 Mon Sep 17 00:00:00 2001 From: Yaohan Chen Date: Mon, 30 Nov 2009 14:19:55 -0500 Subject: Simplify support for using "auto" to detect source language When "auto" is used as source language, Google Translate detects the source language. However there is no need to hardcode Google Translate as the only translator supporting "auto". If another translator supports language detection, we can add "auto" to its supported source languages. If no translator in default_list supports translating from "auto", the existing code already responds with a message saying so. --- data/rbot/plugins/translator.rb | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/data/rbot/plugins/translator.rb b/data/rbot/plugins/translator.rb index 3a371127..d4f55444 100644 --- a/data/rbot/plugins/translator.rb +++ b/data/rbot/plugins/translator.rb @@ -322,15 +322,8 @@ class TranslatorPlugin < Plugin def cmd_translator(m, params) params[:to] = @bot.config['translator.destination'] if params[:to].nil? - - # Use google translate as translator if source language has not been given - # and auto-detect it - if params[:from].nil? - params[:from] = "auto" - translator = "google_translate" - else - translator = @default_translators.find {|t| @translators[t].support?(params[:from], params[:to])} - end + params[:from] ||= 'auto' + translator = @default_translators.find {|t| @translators[t].support?(params[:from], params[:to])} if translator cmd_translate m, params.merge({:translator => translator, :show_provider => true}) -- cgit v1.2.3