diff --git a/lib/openxliff.jar b/lib/openxliff.jar index e00537a6..708d166d 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 d837382b..a8149a79 100644 --- a/src/com/maxprograms/converters/Constants.java +++ b/src/com/maxprograms/converters/Constants.java @@ -21,8 +21,8 @@ private Constants() { public static final String TOOLID = "OpenXLIFF"; public static final String TOOLNAME = "OpenXLIFF Filters"; - public static final String VERSION = "3.24.0"; - public static final String BUILD = "20241122_0822"; + public static final String VERSION = "3.25.0"; + public static final String BUILD = "20241124_0807"; public static final String SUCCESS = "0"; public static final String ERROR = "1"; diff --git a/src/com/maxprograms/converters/ditamap/DitaParser.java b/src/com/maxprograms/converters/ditamap/DitaParser.java index 27652816..d6a4d242 100644 --- a/src/com/maxprograms/converters/ditamap/DitaParser.java +++ b/src/com/maxprograms/converters/ditamap/DitaParser.java @@ -652,9 +652,7 @@ private void addToImages(String imagePath, String href, String parentFile) { JSONObject json = new JSONObject(); json.put("imagePath", imagePath); json.put("href", href); - if (!images.containsKey(parentFile)) { - images.put(parentFile, new ArrayList<>()); - } + images.computeIfAbsent(parentFile, s -> new ArrayList()); List list = images.get(parentFile); String string = json.toString(); if (!list.contains(string)) { diff --git a/src/com/maxprograms/converters/sdlxliff/Sdl2Xliff.java b/src/com/maxprograms/converters/sdlxliff/Sdl2Xliff.java index 0e6a1d07..eb6d3cfa 100644 --- a/src/com/maxprograms/converters/sdlxliff/Sdl2Xliff.java +++ b/src/com/maxprograms/converters/sdlxliff/Sdl2Xliff.java @@ -129,6 +129,34 @@ && containsSrcText(root.getChild("source")))) { } Element segSource = root.getChild("seg-source"); Element target = root.getChild("target"); + + Map lockedMap = new HashMap<>(); + Map statusMap = new HashMap<>(); + + Element segDefs = root.getChild("sdl:seg-defs"); + if (segDefs != null) { + List children = segDefs.getChildren("sdl:seg"); + Iterator it = children.iterator(); + while (it.hasNext()) { + Element sdlSeg = it.next(); + String id = sdlSeg.getAttributeValue("id"); + if ("true".equals(sdlSeg.getAttributeValue("locked", "false"))) { + lockedMap.put(id, true); + } + if ("Draft".equals(sdlSeg.getAttributeValue("conf"))) { + statusMap.put(id, "new"); + } + if ("Translated".equals(sdlSeg.getAttributeValue("conf"))) { + statusMap.put(id, "translated"); + } + if ("RejectedTranslation".equals(sdlSeg.getAttributeValue("conf"))) { + statusMap.put(id, "needs-review-translation"); + } + if ("ApprovedSignOff".equals(sdlSeg.getAttributeValue("conf"))) { + statusMap.put(id, "signed-off"); + } + } + } if (segSource != null) { if (containsText(segSource)) { Map targets = new HashMap<>(); @@ -145,16 +173,25 @@ && containsSrcText(root.getChild("source")))) { Iterator it = mrks.iterator(); while (it.hasNext()) { Element mrk = it.next(); + String id = mrk.getAttributeValue("mid"); + String lockedString = ""; + if (lockedMap.containsKey(id)) { + lockedString = "\" ts=\"locked"; + } writeStr(" \n"); + + mrk.getAttributeValue("mid") + lockedString + "\" xml:space=\"preserve\">\n"); // write new source writeStr(" "); recurseSource(mrk); writeStr("\n"); if (targets.containsKey(mrk.getAttributeValue("mid"))) { // write new target + String stateString = ""; + if (statusMap.containsKey(id)) { + stateString = " state=\"" + statusMap.get(id) + "\""; + } Element tmrk = targets.get(mrk.getAttributeValue("mid")); - writeStr(" "); + writeStr(" "); recurseTarget(tmrk); writeStr("\n"); } diff --git a/src/com/maxprograms/converters/xml/Xliff2Xml.java b/src/com/maxprograms/converters/xml/Xliff2Xml.java index af7c333c..c9c568e5 100644 --- a/src/com/maxprograms/converters/xml/Xliff2Xml.java +++ b/src/com/maxprograms/converters/xml/Xliff2Xml.java @@ -308,7 +308,7 @@ private static String extractText(Element element) throws SAXException { } else { String text = ((TextNode) n).getText(); if (isIdml && text.indexOf('\n') != -1) { - text = text.replaceAll("\\n", ""); + text = text.replace("\n", ""); } result = result + addEntities(text); } diff --git a/src/com/maxprograms/xliff2/ToXliff2.java b/src/com/maxprograms/xliff2/ToXliff2.java index d4d9cb7b..bd7159d4 100644 --- a/src/com/maxprograms/xliff2/ToXliff2.java +++ b/src/com/maxprograms/xliff2/ToXliff2.java @@ -316,7 +316,7 @@ private static void recurse(Element source, Element target) throws SAXException, Attribute a = at.next(); if (a.getName().indexOf(':') != -1 && !a.getName().startsWith("xml:")) { unit.setAttribute(a); - } else if (preserveAttributes.contains(a.getName())) { + } else if (preserveAttributes.contains(a.getName()) && !("ts".equals(a.getName()) && "locked".equals(a.getValue()))) { otherAttributes.add(a); } } @@ -429,7 +429,9 @@ private static void recurse(Element source, Element target) throws SAXException, if (hasTarget) { segment.addContent(tgt2); } - + if ("locked".equals(source.getAttributeValue("ts"))) { + segment.setAttribute("subState", "openxliff:locked"); + } List matches = source.getChildren("alt-trans"); if (!matches.isEmpty()) { root2.setAttribute("xmlns:mtc", "urn:oasis:names:tc:xliff:matches:2.0");