diff options
| author | hallgren <hallgren@chalmers.se> | 2014-05-07 23:42:05 +0000 |
|---|---|---|
| committer | hallgren <hallgren@chalmers.se> | 2014-05-07 23:42:05 +0000 |
| commit | fc6d8f63623c166ed79d2d2e3c4a73cc1de0a9a7 (patch) | |
| tree | 765d804007e84a9c5b7823cedbf3b1486f5ac4dd /src/www/js/gftranslate.js | |
| parent | 70b192594e7d3057b6d7422e60e9e08011e4dc00 (diff) | |
Wide Coverage Demo App: show all Phrasebook translations
Also improve behaviour for languages that are missing in Phrasebook (Chinese).
Also update the initial set of languages in the menus to match Translate11.pgf.
Diffstat (limited to 'src/www/js/gftranslate.js')
| -rw-r--r-- | src/www/js/gftranslate.js | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/www/js/gftranslate.js b/src/www/js/gftranslate.js index a232bde50..86cdc477a 100644 --- a/src/www/js/gftranslate.js +++ b/src/www/js/gftranslate.js @@ -85,20 +85,23 @@ function trans_text_quality(text) { } // find_to :: Lang -> [{to:Lang,...}] -> Int -find_to=function(to,lins) { +function find_to(to,lins) { for(var i=0;i<lins.length;i++) if(lins[i].to==to) return i - return 0 // Hmm.... + return -1 // Hmm.... } -trans_quality=function(r,to) { +function trans_quality(r,to) { var ix=to ? find_to(to,r.linearizations) : 0 - var text=r.linearizations[ix].text - if(r.prob==0) return {quality:"high_quality",text:text} + if(ix<0) return null else { - var t=trans_text_quality(text) - if(t.quality=="default_quality" && r.tree && r.tree[0]=="?") - t.quality="low_quality" - return t + var text=r.linearizations[ix].text + if(r.prob==0) return {quality:"high_quality",text:text} + else { + var t=trans_text_quality(text) + if(t.quality=="default_quality" && r.tree && r.tree[0]=="?") + t.quality="low_quality" + return t + } } } |
