diff --git a/lib/openxliff.jar b/lib/openxliff.jar index a0ee0c8c..89392317 100644 Binary files a/lib/openxliff.jar and b/lib/openxliff.jar differ diff --git a/src/com/maxprograms/converters/Constants.java b/src/com/maxprograms/converters/Constants.java index 452fa0db..2e2395f5 100644 --- a/src/com/maxprograms/converters/Constants.java +++ b/src/com/maxprograms/converters/Constants.java @@ -11,6 +11,8 @@ *******************************************************************************/ package com.maxprograms.converters; +import org.json.JSONObject; + public class Constants { private Constants() { @@ -20,9 +22,22 @@ private Constants() { public static final String TOOLID = "OpenXLIFF"; public static final String TOOLNAME = "OpenXLIFF Filters"; public static final String VERSION = "3.14.0"; - public static final String BUILD = "20230829_1929"; + public static final String BUILD = "20230831_1219"; public static final String SUCCESS = "0"; public static final String ERROR = "1"; public static final String CANCELLED = "Cancelled"; + + public static void main(String[] args) { + JSONObject json = new JSONObject(); + json.put("toolId", TOOLID); + json.put("toolName", TOOLNAME); + json.put("version", VERSION); + json.put("build", BUILD); + json.put("java", System.getProperty("java.version")); + json.put("javaVendor", System.getProperty("java.vendor")); + json.put("xmlVersion", com.maxprograms.xml.Constants.VERSION); + json.put("xmlBuild", com.maxprograms.xml.Constants.BUILD); + System.out.println(json.toString(2)); + } } diff --git a/src/com/maxprograms/converters/sdlxliff/Sdl2Xliff.java b/src/com/maxprograms/converters/sdlxliff/Sdl2Xliff.java index fda7f42a..8352cd37 100644 --- a/src/com/maxprograms/converters/sdlxliff/Sdl2Xliff.java +++ b/src/com/maxprograms/converters/sdlxliff/Sdl2Xliff.java @@ -87,14 +87,15 @@ public static List run(Map params) { writeStr("\n"); writeStr("
\n"); - writeStr("\n"); - writeStr("\n"); - writeStr("\n"); - writeStr(" \n"); + writeStr(" \n"); + writeStr(" \n"); + writeStr(" \n"); writeStr("
\n"); writeStr("\n"); + acceptTrackedChanges(doc.getRootElement()); recurse(doc.getRootElement()); writeStr("\n"); @@ -144,20 +145,20 @@ && containsSrcText(root.getChild("source")))) { Iterator it = mrks.iterator(); while (it.hasNext()) { Element mrk = it.next(); - writeStr("\n"); // write new source - writeStr(" "); + writeStr(" "); recurseSource(mrk); writeStr("\n"); if (targets.containsKey(mrk.getAttributeValue("mid"))) { // write new target Element tmrk = targets.get(mrk.getAttributeValue("mid")); - writeStr(" "); + writeStr(" "); recurseTarget(tmrk); writeStr("\n"); } - writeStr(" \n"); + writeStr(" \n"); } } } @@ -276,4 +277,39 @@ private static boolean containsText(Element source) { private static void writeStr(String string) throws IOException { out.write(string.getBytes(StandardCharsets.UTF_8)); } + + private static void acceptTrackedChanges(Element e) { + List children = e.getChildren("mrk"); + if (!children.isEmpty()) { + List content = e.getContent(); + List newContent = new ArrayList<>(); + Iterator it = content.iterator(); + while (it.hasNext()) { + XMLNode n = it.next(); + if (n.getNodeType() == XMLNode.ELEMENT_NODE) { + Element child = (Element) n; + if (child.getName().equals("mrk")) { + if (child.getAttributeValue("mtype").equals("x-sdl-added")) { + acceptTrackedChanges(child); + newContent.addAll(child.getContent()); + } else if (child.getAttributeValue("mtype").equals("x-sdl-deleted")) { + // do nothing + } else { + newContent.add(child); + } + } else { + newContent.add(child); + } + } else { + newContent.add(n); + } + } + e.setContent(newContent); + } + children = e.getChildren(); + Iterator it = children.iterator(); + while (it.hasNext()) { + acceptTrackedChanges(it.next()); + } + } }