Wide Coverage Translation Demo: improved performance

For improved performance, request only one translation from the server
initially. When the user clicks on a translated sentense, request 9 more
translations.
This commit is contained in:
hallgren
2015-03-11 17:53:25 +00:00
parent 748ebae433
commit cd50599267

View File

@@ -98,6 +98,7 @@ wc.translate=function() {
p.appendChild(span_class("pick "+q,pick))
}
}
if(!so.got_more) p.appendChild(text("..."))
/*
p.appendChild(wrap_class("small","pick",
node("a",{href:wc.google_translate_url(),
@@ -112,6 +113,10 @@ wc.translate=function() {
if(e) e.innerHTML=prob+"<br>"+(r.tree||"")
if(wc.p /*&& so.rs.length>1*/) show_picks()
//if(f.speak.checked) wc.speak(t.text,f.to.value)
if(!so.got_more) {
so.got_more=true
trans(so.input,1,9)
}
}
so.target.onclick=show_more
@@ -175,7 +180,7 @@ wc.translate=function() {
}
gftranslate.translate(text,f.from.value,wc.languages || f.to.value,i,count,step3)
}
function step2(text) { trans(text,0,10) }
function step2(text) { trans(text,0,1) }
function step2cnl(text) {
function step3cnl(results) {
var trans=results[0].translations