From fc4c8b0058e425baf4e2b516256f96ed900de29c Mon Sep 17 00:00:00 2001 From: hallgren Date: Fri, 20 Jun 2014 18:39:28 +0000 Subject: Cloud service & apps: better error handling in wide coverage translation The wide coverage demo apps now shows a "please wait" message while the grammar is loading, and a red error message if the grammar is not found on the server. The Simple Translation Tool also show red error messages if the grammar is not found. --- src/www/js/wc.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/www/js/wc.js') diff --git a/src/www/js/wc.js b/src/www/js/wc.js index e35b8f9c9..04686fee7 100644 --- a/src/www/js/wc.js +++ b/src/www/js/wc.js @@ -3,10 +3,12 @@ wc.cnl="Phrasebook" // try this controlled natural language first wc.f=document.forms[0] wc.o=element("output") wc.e=element("extra") +wc.i=element("grammarinfo") wc.p=element("pick") wc.os=[] // output segment list wc.cache={} // output segment cache, indexed by source text wc.local=appLocalStorage("gf.wc.") +wc.translating="" wc.delayed_translate=function() { function restart(){ if(wc.f.input.value!=wc.translating) wc.translate() } @@ -298,6 +300,7 @@ wc.try_google=function() { // Update language selection menus with the languages supported by the grammar function init_languages() { function init2(langs) { + replaceInnerHTML(wc.i,"Enter text to translate above") wc.languages=langs var langset=toSet(langs) function update_menu(m) { @@ -310,7 +313,13 @@ function init_languages() { update_menu(wc.f.from) update_menu(wc.f.to) } - gftranslate.get_languages(init2) + function initerror(errortext,status,ct) { + var msg = status==404 ? "The wide cover translation grammar was not found on the server" : "Server problem "+status + replaceChildren(wc.i,text(msg)) + if(wc.i) wc.i.className="error" + } + replaceInnerHTML(wc.i,"Loading the wide coverage translation grammar, please wait...") + gftranslate.get_languages(init2,initerror) } function init_speech() { -- cgit v1.2.3