In this tutorial will be explained how to open a Translation Memory using Translation Memory API and how to implement Segment Element Visitor Pattern. Complete sample code can be found on Github.
In order to manipulate TMs we need to add references to following libraries: Sdl.LanguagePlatform.TranslationMemory.dll and Sdl.LanguagePlatform.TranslationMemoryApi.dll.
After we open the tm we get all the Translation Units associated to that tm.
In tus variable we have all the translation units from the tm.
How to implement Segment Element Visitor Pattern
- Create a class which implements ISegmentElementVisitor interface
- In VisitText() method will be fired when the segment contains plain text. You can read the segment text like this text.Value();
- In VisitTag() method can be read information about tags.
How to use Segment Element Visitor
We need to iterate in translation units and accept visitor.