diff options
author | Raine Virta <rane@kapsi.fi> | 2010-04-16 17:36:28 +0300 |
---|---|---|
committer | Raine Virta <rane@kapsi.fi> | 2010-04-16 22:58:24 +0300 |
commit | 6ca0084780f82de5b4e06a2d242a9f9fd5bad63e (patch) | |
tree | 3c54204ecd300f8498bf8e9b1ea14b188761600b /data/rbot | |
parent | 868c594b7ce5d8e31524109af1ecb493699ee31f (diff) |
translator: additional help for google translate auto-detect failure
When translate command is used without source language, "auto" as source
language is assumed. It means that google translator is used and we let
google figure out what the source language is.
Problem is that the google translator will fail if the system that the
bot is running on does not have the json gem installed. This commit
addresses that problem by showing more informative error message instead
of a weird "none of the translators supports auto to en translation".
Diffstat (limited to 'data/rbot')
-rw-r--r-- | data/rbot/plugins/translator.rb | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/data/rbot/plugins/translator.rb b/data/rbot/plugins/translator.rb index c0b27bc7..6b87476c 100644 --- a/data/rbot/plugins/translator.rb +++ b/data/rbot/plugins/translator.rb @@ -362,7 +362,20 @@ class TranslatorPlugin < Plugin if translator cmd_translate m, params.merge({:translator => translator, :show_provider => true}) else - m.reply _('None of the default translators (translator.default_list) supports translating from %{source} to %{target}') % {:source => params[:from], :target => params[:to]} + # When translate command is used without source language, "auto" as source + # language is assumed. It means that google translator is used and we let google + # figure out what the source language is. + # + # Problem is that the google translator will fail if the system that the bot is + # running on does not have the json gem installed. + if params[:from] == 'auto' + m.reply _("Unable to auto-detect source language due to broken google translator, see %{reverse}%{prefix}help translate failed%{reverse} for details") % { + :reverse => Reverse, + :prefix => @bot.config['core.address_prefix'].first + } + else + m.reply _('None of the default translators (translator.default_list) supports translating from %{source} to %{target}') % {:source => params[:from], :target => params[:to]} + end end end |