Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

add button (Translator servlet) to switch one already translated line in edit mode

regera3ac6ca7df33
diff --git a/htroot/Translator_p.html b/htroot/Translator_p.html
index 846f8adbd..131af2999 100644
--- a/htroot/Translator_p.html
+++ b/htroot/Translator_p.html
@@ -36,7 +36,7 @@
<label for="targettxt#[tokenid]#" >#[sourcetxt]#</label>
</td>
<td style="border-bottom: solid gray; border-bottom-width: 1px;" valign="top" nowrap>
- <input type="text" name="targettxt#[tokenid]#" id="targettxt#[tokenid]#" size="80" value="#[targettxt]#" #(filteruntranslated)#disabled::#(/filteruntranslated)#/>#(filteruntranslated)#::<button name="approve" type="submit" value="#[tokenid]#" class="btn btn-sm"><span class="glyphicon glyphicon-ok-sign" style="color: green"/></button>#(/filteruntranslated)#
+ <input type="text" name="targettxt#[tokenid]#" id="targettxt#[tokenid]#" size="80" value="#[targettxt]#" #(filteruntranslated)#disabled::#(/filteruntranslated)#/>#(filteruntranslated)#<button name="editapproved" type="submit" value="#[tokenid]#" class="btn btn-sm"><span class="glyphicon glyphicon-pencil"/></button>::<button name="approve" type="submit" value="#[tokenid]#" class="btn btn-sm"><span class="glyphicon glyphicon-ok-sign" style="color: green"/></button>#(/filteruntranslated)#
</td>
</tr>
#{/textlist}#
diff --git a/htroot/Translator_p.java b/htroot/Translator_p.java
index d46133e0e..87db72a6d 100644
--- a/htroot/Translator_p.java
+++ b/htroot/Translator_p.java
@@ -77,36 +77,46 @@ public class Translator_p {
i = 0;
boolean filteruntranslated = false;
+ boolean editapproved = false; // to switch already approved translation in edit mode
int textlistid = -1;
if (post != null) {
filteruntranslated = post.getBoolean("filteruntranslated");
- if (filteruntranslated) {
- prop.put("filter.checked", 1);
- } else {
- prop.put("filter.checked", 0);
- }
+ prop.put("filter.checked", filteruntranslated); // remember filter setting
textlistid = post.getInt("approve", -1);
+ if (post.containsKey("editapproved")) {
+ textlistid = post.getInt("editapproved", -1);
+ editapproved = true;
+ }
}
boolean changed = false;
for (String sourcetext : origTextList.keySet()) {
String targettxt = origTextList.get(sourcetext);
boolean existinlocalTrans = localTrans.containsKey(filename) && localTrans.get(filename).containsKey(sourcetext);
+
+ if (editapproved) existinlocalTrans |= (i == textlistid); // if edit of approved requested handle as/like existing in local to allow edit
+
if (targettxt == null || targettxt.isEmpty() || existinlocalTrans) {
prop.put("textlist_" + i + "_filteruntranslated", true);
} else if (filteruntranslated) {
continue;
}
+ // handle (modified) input text
if (i == textlistid && post != null) {
- String t = post.get("targettxt" + Integer.toString(textlistid));
- // correct common partial html markup (part of text identification for words also used as html parameter)
- if (!t.isEmpty()) {
- if (sourcetext.startsWith(">") && !t.startsWith(">")) t=">"+t;
- if (sourcetext.endsWith("<") && !t.endsWith("<")) t=t+"<";
+ if (editapproved) { // switch already translated in edit mode by copying to local translation
+ // not saved here as not yet modified/approved
+ ctm.addTranslation(localTrans, filename, sourcetext, targettxt);
+ } else {
+ String t = post.get("targettxt" + Integer.toString(textlistid));
+ // correct common partial html markup (part of text identification for words also used as html parameter)
+ if (!t.isEmpty()) {
+ if (sourcetext.startsWith(">") && !t.startsWith(">")) t=">"+t;
+ if (sourcetext.endsWith("<") && !t.endsWith("<")) t=t+"<";
+ }
+ targettxt = t;
+ // add changes to original (for display) and local (for save)
+ origTextList.put(sourcetext, targettxt);
+ changed = ctm.addTranslation(localTrans, filename, sourcetext, targettxt);
}
- targettxt = t;
- // add changes to original (for display) and local (for save)
- origTextList.put(sourcetext, targettxt);
- changed = ctm.addTranslation (localTrans, filename, sourcetext, targettxt);
}
prop.putHTML("textlist_" + i + "_sourcetxt", sourcetext);
prop.putHTML("textlist_" + i + "_targettxt", targettxt);