+ @form.submit.parser.search("div[@id='result']/div[@style]").inner_html
+ end
+end
+
+class WorldlingoTranslator < Translator
+ INFO = 'WorldLingo Free Online Translator <http://www.worldlingo.com/en/products_services/worldlingo_translator.html>'
+
+ LANGUAGES = %w[en fr de it pt es ru nl el sv ar ja ko zh_CN zh_TW]
+ def initialize(cache)
+ require 'uri'
+ super(Translator::Direction.all_to_all(LANGUAGES), cache)
+ end
+
+ def translate(text, from, to)
+ response = Irc::Utils.bot.httputil.get_response(URI.escape(
+ "http://www.worldlingo.com/SEfpX0LV2xIxsIIELJ,2E5nOlz5RArCY,/texttranslate?wl_srcenc=utf-8&wl_trgenc=utf-8&wl_text=#{text}&wl_srclang=#{from.upcase}&wl_trglang=#{to.upcase}"))
+ # WorldLingo seems to respond an XML when error occurs
+ case response['Content-Type']
+ when %r'text/plain'
+ response.body
+ else
+ raise Translator::NoTranslationError
+ end