mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-25 10:48:54 -06:00
transaltor: reduce code duplication
This commit is contained in:
@@ -124,15 +124,17 @@ Translator.prototype.update_translations=function() {
|
|||||||
ts[i].appendChild(text(segment.target+" "))
|
ts[i].appendChild(text(segment.target+" "))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function update_apertium_translation(i,afrom,ato) {
|
function update_segment(i,txts) {
|
||||||
var segment=ss[i]
|
var segment=ss[i]
|
||||||
function upd3(txts) {
|
|
||||||
segment.target=txts[0];
|
segment.target=txts[0];
|
||||||
segment.options={method:o.method,from:o.from,to:o.to} // no sharing!
|
segment.options={method:o.method,from:o.from,to:o.to} // no sharing!
|
||||||
if(txts.length>1) segment.choices=txts
|
if(txts.length>1) segment.choices=txts
|
||||||
else delete segment.choices
|
else delete segment.choices
|
||||||
replace(i)
|
replace(i)
|
||||||
}
|
}
|
||||||
|
function update_apertium_translation(i,afrom,ato) {
|
||||||
|
var segment=ss[i]
|
||||||
|
function upd3(txts) { update_segment(i,txts) }
|
||||||
function upd1(res) {
|
function upd1(res) {
|
||||||
//console.log(translate_output)
|
//console.log(translate_output)
|
||||||
if(res.translation) upd3([res.translation])
|
if(res.translation) upd3([res.translation])
|
||||||
@@ -150,13 +152,7 @@ Translator.prototype.update_translations=function() {
|
|||||||
|
|
||||||
function update_gf_translation(i,gfrom,gto) {
|
function update_gf_translation(i,gfrom,gto) {
|
||||||
var segment=ss[i]
|
var segment=ss[i]
|
||||||
function upd3(txts) {
|
function upd3(txts) { update_segment(i,txts) }
|
||||||
segment.target=txts[0];
|
|
||||||
segment.options={method:o.method,from:o.from,to:o.to} // no sharing!
|
|
||||||
if(txts.length>1) segment.choices=txts
|
|
||||||
else delete segment.choices
|
|
||||||
replace(i)
|
|
||||||
}
|
|
||||||
function upd2(ts) {
|
function upd2(ts) {
|
||||||
function unlex(txt,cont) { gfshell('ps -unlextext "'+txt+'"',cont) }
|
function unlex(txt,cont) { gfshell('ps -unlextext "'+txt+'"',cont) }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user