this.sourceLanguageCode = sourceLanguageCode;
this.targetLanguageCode = targetLanguageCode;
}
public void format(List<Alignment> alignmentList) {
Tmx tmx = new Tmx();
tmx.setVersion(TMX_VERSION);
Header header = new Header();
header.setAdminlang(TMX_ADMINLANG);
header.setSrclang(sourceLanguageCode);
header.setCreationtool(TMX_CREATIONTOOL);
header.setCreationtoolversion(TMX_CREATIONTOOLVERSION);
header.setSegtype(TMX_SEGTYPE);
header.setDatatype(TMX_DATATYPE);
header.setOTmf(TMX_OTMF);
header.setCreationdate(DateParser.getIsoDateNoMillis(new Date()));
tmx.setHeader(header);
Body body = new Body();
for (Alignment alignment : alignmentList) {
Tu tu = new Tu();
createTuv(tu, sourceLanguageCode, alignment.getSourceSegmentList());
createTuv(tu, targetLanguageCode, alignment.getTargetSegmentList());
if (tu.getTuv().size() > 0) {
body.getTu().add(tu);
}
}
tmx.setBody(body);
TmxMarshallerUnmarshaller.getInstance().marshal(tmx, writer);
}