diff options
author | Yaohan Chen <yaohan.chen@gmail.com> | 2009-11-30 14:19:55 -0500 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2009-11-30 23:13:34 +0100 |
commit | 657e1d70928f2878d4c256825632265fe59b2269 (patch) | |
tree | 1a49348add179f386c0c4322b92f9b903ec8f0bc /data/rbot | |
parent | 1ce45e64266ea9efc1cfce4160994de24bbf7a2c (diff) |
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.
Diffstat (limited to 'data/rbot')
-rw-r--r-- | data/rbot/plugins/translator.rb | 11 |
1 files 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}) |