Skip to content

Commit e87688d

Browse files
committed
Extracted context info from XLIFF 1.2 files
1 parent e0b50a7 commit e87688d

4 files changed

Lines changed: 14 additions & 8 deletions

File tree

src/com/maxprograms/converters/Constants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ private Constants() {
2222
public static final String TOOLID = "OpenXLIFF";
2323
public static final String TOOLNAME = "OpenXLIFF Filters";
2424
public static final String VERSION = "5.1.0";
25-
public static final String BUILD = "20260317_1453";
25+
public static final String BUILD = "20260321_0855";
2626

2727
public static final String SUCCESS = "0";
2828
public static final String ERROR = "1";

src/com/maxprograms/converters/po/Po2Xliff.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -384,18 +384,18 @@ private static void writeSegment() throws IOException {
384384
writeString(" <target>" + XMLUtils.cleanText(target) + "</target>\n");
385385
}
386386
}
387-
if (!comment.isEmpty()) {
387+
if (!comment.isBlank()) {
388388
writeString(" <note from=\"po-file\">" + XMLUtils.cleanText(comment) + "</note>\n");
389389
}
390-
if (!context.isEmpty()) {
390+
if (!context.isBlank()) {
391391
writeString(" <context-group name=\"x-po-entry-header#" + contextId++
392392
+ "\" purpose=\"information\">\n" + " <context context-type=\"x-po-autocomment\">"
393393
+ XMLUtils.cleanText(context) + "</context>\n" + " </context-group>\n");
394394
}
395-
if (!reference.isEmpty()) {
395+
if (!reference.isBlank()) {
396396
parseReference(reference);
397397
}
398-
if (!newContext.isEmpty()) {
398+
if (!newContext.isBlank()) {
399399
writeString(" <context-group name=\"x-po-msgctxt#" + contextId++ + "\" purpose=\"information\">\n"
400400
+ " <context context-type=\"x-msgctxt\">" + XMLUtils.cleanText(newContext)
401401
+ "</context>\n" + " </context-group>\n");

src/com/maxprograms/converters/xliff/Xliff1xProcessor.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,12 @@ private static void recurse1x(Element root, List<Element> units) {
149149
}
150150
unit.addContent(n);
151151
}
152+
List<Element> contextGroups = root.getChildren("context-group");
153+
for (Element contextGroup : contextGroups) {
154+
Element group = new Element("context-group");
155+
group.clone(contextGroup);
156+
unit.addContent(group);
157+
}
152158
units.add(unit);
153159
root.addContent(new PI(Constants.TOOLID, currentFile + "_" + unit.getAttributeValue("id")));
154160
}

src/com/maxprograms/xliff2/ToXliff2.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,8 @@ private static void recurse(Element source, Element target)
425425
metaGroup.addContent(meta);
426426
}
427427
}
428-
Element contextGroup = source.getChild("context-group");
429-
if (contextGroup != null) {
428+
List<Element> contextGroups = source.getChildren("context-group");
429+
for (Element contextGroup : contextGroups) {
430430
List<Element> contexts = contextGroup.getChildren("context");
431431
if (!contexts.isEmpty()) {
432432
Element metadata = unit.getChild("mda:metadata");
@@ -442,7 +442,7 @@ private static void recurse(Element source, Element target)
442442
if (type.startsWith("x-sdl-")) {
443443
type = type.replaceAll("_sdl:spc_", " ");
444444
type = type.substring(6);
445-
}
445+
}
446446
Element meta = new Element("mda:meta");
447447
meta.setAttribute("type", type);
448448
meta.addContent(context.getText());

0 commit comments

Comments
 (0)