if (event.getEventType() == EventType.START_SUBDOCUMENT) {
StartSubDocument startSubDoc =
(StartSubDocument) event.getResource();
subDocName = stripPath(startSubDoc.getName());
} else if (event.getEventType() == EventType.TEXT_UNIT) {
TextUnit tu = (TextUnit) event.getResource();
if (!tu.getSource().isEmpty() && tu.isTranslatable()) {
String translatable = getTranslatableText(tu);
if (!translatable.isEmpty()) {
TextFlowTarget tft =
translations.get(getIdFor(tu,
translatable, subDocName));
if (tft != null) {
String translated = tft.getContents().get(0);
translated =
getFullTranslationText(tu, translated);
tu.setTargetContent(localeId, GenericContent
.fromLetterCodedToFragment(
translated, tu.getSource()
.getFirstContent()
.clone(), true, true));
}
}
}