summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhallgren <hallgren@chalmers.se>2012-05-16 14:42:26 +0000
committerhallgren <hallgren@chalmers.se>2012-05-16 14:42:26 +0000
commit5bd17709bfa02eea9c06ddd6a26931cb246b71e6 (patch)
tree588d368efe78b70d4be8280e940f5660804168a2 /src
parent114788a3db475540194bf74d4e45c4f4d1138d5e (diff)
translator: use GF's text lexer/unlexer to obtain more natural looking text
Note though that the unlexer does the wrong thing with initial words that are supposed to be capitalized, e.g. "I am ready.", "Spanish wine is good.", so these sentenses are not translated at the moment.
Diffstat (limited to 'src')
-rw-r--r--src/www/translator/index.html7
-rw-r--r--src/www/translator/translator.js25
2 files changed, 18 insertions, 14 deletions
diff --git a/src/www/translator/index.html b/src/www/translator/index.html
index 7f3d46a22..8d08324fe 100644
--- a/src/www/translator/index.html
+++ b/src/www/translator/index.html
@@ -67,16 +67,15 @@
</noscript>
</div>
<hr>
-<div class=modtime><small>
-<!-- hhmts start --> Last modified: Tue May 15 16:17:32 CEST 2012 <!-- hhmts end -->
+<div class=modtime><small>HMTL
+<!-- hhmts start --> Last modified: Wed May 16 16:15:20 CEST 2012 <!-- hhmts end -->
</small></div>
<a href="about.html">About</a>
<script type="text/javascript" src="../minibar/support.js"></script>
<script type="text/javascript" src="../minibar/pgf_online.js"></script>
-<!--
<script type="text/javascript" src="../gfse/cloud2.js"></script>
--->
+<script type="text/javascript" src="../gfse/localstorage.js"></script>
<script type="text/javascript" src="translator.js"></script>
<script type="text/javascript" >
var translator = new Translator()
diff --git a/src/www/translator/translator.js b/src/www/translator/translator.js
index acff13d72..a92cffc5b 100644
--- a/src/www/translator/translator.js
+++ b/src/www/translator/translator.js
@@ -67,26 +67,31 @@ Translator.prototype.update_translations=function() {
ds[i]=sd
replaceNode(sd,old)
}
+ function upd3(txt) {
+ segment.target=txt;
+ segment.options=JSON.parse(JSON.stringify(o)) // no sharing!
+ replace(t.draw_segment(segment,i))
+ }
function upd2(ts) {
switch(ts.length) {
- case 1: segment.target=ts[0]; break;
- case 0: segment.target="[no translation]";break;
- default: segment.target="[ambiguous translation]"
+ case 1: gfshell('ps -unlextext "'+ts[0]+'"',upd3); break;
+ case 0: upd3("[no translation]");break;
+ default: upd3("[ambiguous translation]")
}
- segment.options=JSON.parse(JSON.stringify(o)) // no sharing!
- replace(t.draw_segment(segment,i))
}
- function upd(translate_output) {
+ function upd1(translate_output) {
//console.log(translate_output)
- var ts=collect_texts(translate_output[0].translations)
- upd2(ts)
+ upd2(collect_texts(translate_output[0].translations))
+ }
+ function upd0(source) {
+ t.server.translate({from:gfrom,to:gto,input:source},upd1)
}
var fs=supported(gfrom)
var ts=supported(gto)
if(fs && ts) {
if(segment.options.method!="Manual"
&& JSON.stringify(segment.options)!=JSON.stringify(o))
- t.server.translate({from:gfrom,to:gto,input:segment.source},upd)
+ gfshell('ps -lextext "'+segment.source+'"',upd0)
}
else {
var fn=concname(o.from)
@@ -95,7 +100,7 @@ Translator.prototype.update_translations=function() {
var sup=" is supported by the grammar"
var msg= fs ? tn+unsup : ts ? fn+unsup :
"Neither "+fn+" nor "+tn+sup
- upd2(["["+msg+"]"])
+ upd3("["+msg+"]")
}
}