@SuppressWarnings("unchecked") private void addStartElemToSkelAddProps(StartElement startElement, IResource resource) { skel.append("<" + startElement.getName().getLocalPart()); Iterator<Attribute> attributes = startElement.getAttributes(); while (attributes.hasNext()) { Attribute attribute = attributes.next(); skel.append(String.format(" %s=\"%s\"", attribute.getName() .getLocalPart(), attribute.getValue())); Property prop = new Property(attribute.getName().getLocalPart(), attribute.getValue()); if (resource instanceof DocumentPart) { ((DocumentPart) resource).setProperty(prop); } else if (resource instanceof StartGroup) { ((StartGroup) resource).setProperty(prop); } else if (resource instanceof ITextUnit) { ((ITextUnit) resource).setProperty(prop); } } skel.append(">"); }
private void addTuProperties(ITextUnit tu, Unit unit) { if (unit.getName() != null) tu.setProperty(new Property(XMLSkeletonWriter.NAME, unit.getName())); tu.setProperty(new Property(XMLSkeletonWriter.CANRESEGMENT, unit.getCanResegment() ? "yes" : "no")); tu.setProperty(new Property(XMLSkeletonWriter.TRANSLATE, unit.getTranslate() ? "yes" : "no")); if (unit.getSourceDir() != Directionality.AUTO) tu.setProperty(new Property(XMLSkeletonWriter.SRCDIR, unit.getSourceDir().toString())); if (unit.getTargetDir() != Directionality.AUTO) tu.setProperty(new Property(XMLSkeletonWriter.TRGDIR, unit.getTargetDir().toString())); if (unit.getType() != null) tu.setProperty(new Property(XMLSkeletonWriter.TYPE, unit.getType())); }
String note = result.group(rule.noteGroup); if ( note.length() > 0 ) { tuRes.setProperty(new Property(Property.NOTE, note, true));
tuRes.setPreserveWhitespaces(true); if (note.length() > 0) { tuRes.setProperty(new Property(Property.NOTE, note, true));
private void procCharacters(Characters chars, ITextUnit tu) { // --setting translator comment-- if (ts.procTransComment) { tu.setProperty(new Property(Property.TRANSNOTE, chars.getData())); } if (ts.currentMessageLocation == MessageLocation.RESOURCE) { procCharacters(chars); } else if (ts.currentMessageLocation == MessageLocation.SOURCE) { TextContainer tc = tu.getSource(); if (!tc.hasText()) { skel.addContentPlaceholder(tu); } // We can use getFirstPartContent() because nothing is segmented tc.getFirstContent().append(chars.getData()); } else if (ts.currentMessageLocation == MessageLocation.TARGET) { TextContainer tc = tu.getTarget(trgLang); if (!tc.hasText()) { skel.addContentPlaceholder(tu, trgLang); } // We can use getFirstPartContent() because nothing is segmented tc.getFirstContent().append(chars.getData()); } }
tu.setProperty(new Property(Property.NOTE, locNote)); tu.setProperty(new Property(Property.TRANSNOTE, transNote)); tu.setProperty(new Property(PROPERTY_REFERENCES, references)); tu.setProperty(new Property(PROPERTY_CONTEXT, msgContext));
tu.setProperty(new Property(Property.NOTE, tmp.toString(), true));
if (params.removeQualifiers) { if (TextUnitUtil.removeQualifiers(textUnit, params.textQualifier)) { textUnit.setProperty(new Property(PROP_QUALIFIED, "yes"));
for (Event event : subFilterEvents) { if (event.isTextUnit()) { event.getTextUnit().setProperty(scalarType); event.getTextUnit().setProperty(flow); event.getTextUnit().setProperty(indent); if (scalar.type == YamlScalarTypes.LITERAL) { event.getTextUnit().setPreserveWhitespaces(true);
String note = result.group(rule.noteGroup); if ( note.length() > 0 ) { tuRes.setProperty(new Property(Property.NOTE, note, true));
tf_target.setPreserveWhitespaces(true); if ( ts.isNumerus() ) tf_target.setProperty(new Property("numerus", "yes")); tf_target.setSourceContent(source); tf_target.createTarget(trgLang, false,
tu.setProperty(scalarType); tu.setProperty(flow); tu.setProperty(indent); eventBuilder.endTextUnit(); eventBuilder.addDocumentPart(scalar.type.getQuoteChar());
tc.setContent(tf); tu.setProperty(new Property(CommaSeparatedValuesFilter.PROP_QUALIFIED, "yes"));
if (Util.isEmpty(trimmedCell)) continue; tu.setProperty(new Property(Property.NOTE, trimmedCell));
textUnit.setProperty(new Property(Property.NOTE, comment));
if ( !Util.isEmpty(data) ) tu.setType(data); data = item.getMetadata().get(MetadataType.GROUP_NAME); if ( !Util.isEmpty(data) ) tu.setProperty(new Property("Txt::GroupName", data, false)); data = item.getMetadata().get(MetadataType.FILE_NAME); if ( !Util.isEmpty(data) ) tu.setProperty(new Property("Txt::FileName", data, false)); return new Event(EventType.TEXT_UNIT, tu);
/** * Converts a TranslationUnit to a TextUnit * @param tu The TranslationUnit to convert. * @return The converted TextUnit */ public static ITextUnit convertToTextUnit (TranslationUnit tu) { ITextUnit textUnit; String tuid = tu.getMetadata().get(MetadataType.ID); textUnit = new TextUnit(tuid); if (tuid != null) { textUnit.setName(tuid); } textUnit.setSourceContent(tu.getSource().getContent()); textUnit.setTargetContent(tu.getTarget().getLanguage(), tu.getTarget().getContent()); for (MetadataType type : tu.getMetadata().keySet()) { if (type != MetadataType.ID) { textUnit.setProperty(new Property(type.fieldName(), tu.getMetadata().get(type))); } } return textUnit; }
tu.setProperty(new Property(Property.NOTE, ci.locNote)); String type = trav.getLocNoteType(attribute); GenericAnnotation.addAnnotation(tu, new GenericAnnotation(GenericAnnotationType.LOCNOTE,