In this page we'll explain how to edit an sdlxliff from selected project in Batch Task plugin context. Like in previous documentation we'll also use Project Anonymizer plugin for code example. Full source code of the project can be found here .
When we want to edit an sdlxliff file we need a BilingualProcessor.
How to create a Bilingual Processor
1. Create a new class which inherits AbstractBilingualContentProcessor class.
2. Override ProcessParagraphUnit() method.
public override void ProcessParagraphUnit(IParagraphUnit paragraphUnit)
{
base.ProcessParagraphUnit(paragraphUnit);
if (paragraphUnit.IsStructure) { return; }
foreach (var segmentPair in paragraphUnit.SegmentPairs.ToList())
{
var segmentVisitor = new SegmentVisitor();
segmentVisitor.VisitText(segmentPair.Source);
}
}
Once we created the processor we need to add it to IMultiFileConverter object from ConfigureConverter method.
protected override void ConfigureConverter(ProjectFile projectFile, IMultiFileConverter multiFileConverter)
{
multiFileConverter.AddBilingualProcessor(new BilingualContentHandlerAdapter(new YourCustomProcessor()));
}
Please make sure you override OnFileComplete() method in your application. If you don't override this method your changes on the file will not be saved.
public override bool OnFileComplete(ProjectFile projectFile, IMultiFileConverter multiFileConverter)
{
return true;
}