diff --git a/lib/openxliff.jar b/lib/openxliff.jar index 7946f428..c95dd4fc 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 b55cba97..27609bdc 100644 --- a/src/com/maxprograms/converters/Constants.java +++ b/src/com/maxprograms/converters/Constants.java @@ -20,7 +20,7 @@ private Constants() { public static final String TOOLID = "OpenXLIFF"; public static final String TOOLNAME = "OpenXLIFF Filters"; public static final String VERSION = "1.11.1"; - public static final String BUILD = "20201014_1434"; + public static final String BUILD = "20201018_1009"; public static final String SUCCESS = "0"; public static final String ERROR = "1"; diff --git a/src/com/maxprograms/converters/xliff/ToOpenXliff.java b/src/com/maxprograms/converters/xliff/ToOpenXliff.java index e2a99da1..84b93b46 100644 --- a/src/com/maxprograms/converters/xliff/ToOpenXliff.java +++ b/src/com/maxprograms/converters/xliff/ToOpenXliff.java @@ -170,20 +170,15 @@ private static void recurse2x(Element root, List units) { while (it.hasNext()) { Element match = it.next(); String ref = match.getAttributeValue("ref"); - if (ref.equals(segment.getAttributeValue("id"))) { + if (ref.equals("#" + segment.getAttributeValue("id"))) { Element altTrans = new Element("alt-trans"); String origin = match.getAttributeValue("origin"); if (!origin.isEmpty()) { altTrans.setAttribute("origin", origin); } - String quality = altTrans.getAttributeValue("matchQuality"); + String quality = match.getAttributeValue("matchQuality"); if (!quality.isBlank()) { - try { - double percentage = Double.parseDouble(quality); - altTrans.setAttribute("match-quality", "" + percentage); - } catch (NumberFormatException e) { - // ignore - } + altTrans.setAttribute("match-quality", quality); } Element altSource = new Element("source"); altSource.setContent(getContent2x(match.getChild("source"))); @@ -379,14 +374,9 @@ private static void recurse1x(Element root, List units) { if (!origin.isEmpty()) { altTrans.setAttribute("origin", origin); } - String quality = altTrans.getAttributeValue("match-quality"); + String quality = match.getAttributeValue("match-quality"); if (!quality.isBlank()) { - try { - double percentage = Double.parseDouble(quality); - altTrans.setAttribute("match-quality", "" + percentage); - } catch (NumberFormatException e) { - // ignore - } + altTrans.setAttribute("match-quality", quality); } Element altSource = new Element("source"); altSource.setContent(getContent1x(match.getChild("source"))); diff --git a/src/com/maxprograms/xliff2/ToXliff2.java b/src/com/maxprograms/xliff2/ToXliff2.java index aae42a24..66770545 100644 --- a/src/com/maxprograms/xliff2/ToXliff2.java +++ b/src/com/maxprograms/xliff2/ToXliff2.java @@ -448,23 +448,24 @@ private static void recurse(Element source, Element target) { Element mtc = new Element("mtc:matches"); unit.getContent().add(0, mtc); for (int i = 0; i < matches.size(); i++) { - Element smatch = matches.get(i); - Element tmatch = new Element("mtc:match"); - tmatch.setAttribute("ref", "#" + source.getAttributeValue("id")); - String matchQuality = smatch.getAttributeValue("match-quality"); + Element altTrans = matches.get(i); + Element match = new Element("mtc:match"); + match.setAttribute("ref", "#" + source.getAttributeValue("id")); + String matchQuality = altTrans.getAttributeValue("match-quality"); if (!matchQuality.isEmpty()) { try { - tmatch.setAttribute("matchQuality", "" + Float.parseFloat(matchQuality)); + Float quality = Float.parseFloat(matchQuality); + match.setAttribute("matchQuality", "" + quality); } catch (NumberFormatException nf) { // ignore } } - String origin = smatch.getAttributeValue("origin"); + String origin = altTrans.getAttributeValue("origin"); if (!origin.isEmpty()) { - tmatch.setAttribute("origin", origin); + match.setAttribute("origin", origin); } Element tsrc = new Element("source"); - List content = smatch.getChild("source").getContent(); + List content = altTrans.getChild("source").getContent(); Iterator snodes = content.iterator(); while (snodes.hasNext()) { XMLNode node = snodes.next(); @@ -498,9 +499,9 @@ private static void recurse(Element source, Element target) { } } } - tmatch.addContent(tsrc); + match.addContent(tsrc); Element ttgt = new Element("target"); - content = smatch.getChild("target").getContent(); + content = altTrans.getChild("target").getContent(); snodes = content.iterator(); while (snodes.hasNext()) { XMLNode node = snodes.next(); @@ -534,8 +535,8 @@ private static void recurse(Element source, Element target) { } } } - tmatch.addContent(ttgt); - mtc.addContent(tmatch); + match.addContent(ttgt); + mtc.addContent(match); } } if (originalData.getChildren("data").isEmpty()) {