So I created a batch task that loops through all the segments in an sdlxliff file.
Here is some example code:
The Task:
public class TranslateTask : AbstractFileContentProcessingAutomaticTask { protected override void ConfigureConverter(ProjectFile projectFile, IMultiFileConverter multiFileConverter) { multiFileConverter.AddBilingualProcessor(new SegmentProcessor()); } }
The Processor:
public class SegmentProcessor : AbstractBilingualContentProcessor { public override void ProcessParagraphUnit(IParagraphUnit paragraphUnit) { if (paragraphUnit.IsStructure) { return; } foreach (var segmentPair in paragraphUnit.SegmentPairs) { if (IgnoreSegment(segmentPair)) { continue; }
// The following code DOES NOT WORK. Casting to Itext return null. foreach (var target in segmentPair.Target) { var text = target as IText; if (text != null) { text.Properties.Text = "Updated"; } } } } }
Question:
Is there a simple way to update the Target text in each segment pair?
If there isn't. What do I need to do to accomplish this?