Copy source segment to target segment in Trados Editor

I have been trying to copy a segment text from source to target, but I couldn't be able to do that.

Is there a way to do this?

I tried the following code, but it didn't work. If there is a text or blank character in the target field, then I can do that.

doc.ProcessSegmentPairs("Copy",
                   (segPair, eventArg) =>
                   {
                       foreach (IAbstractMarkupData markupData in segPair.Source)
                       {                             
                               var text = markupData as IText;

                               if (text != null)
                               {
                                   (((IAbstractMarkupData )segPair.Target) as IText).Text = text.Properties.Text;
                               }                       
                       }
                   });

Parents
  • I have been looking into this and find a way to update a target segment when the target segment is empty.
    The following is a solution I came up with.


    var activeDocument = editorController.ActiveDocument;
    if (activeDocument != null)
    {
    var segmentPair = activeDocument.GetActiveSegmentPair();

    activeDocument.ProcessSegmentPairs("Add Text",
    (segPair, eventArg) =>
    {
    if (segmentPair.Properties.Id == segPair.Properties.Id)
    {
    IDocumentItemFactory documentItemFactory = DefaultDocumentItemFactory.CreateInstance();
    ITextProperties textProperties = documentItemFactory.PropertiesFactory.CreateTextProperties(quoteTranslation);
    IText text = documentItemFactory.CreateText(textProperties);
    segPair.Target.Add(text);
    }
    });
    }
Reply
  • I have been looking into this and find a way to update a target segment when the target segment is empty.
    The following is a solution I came up with.


    var activeDocument = editorController.ActiveDocument;
    if (activeDocument != null)
    {
    var segmentPair = activeDocument.GetActiveSegmentPair();

    activeDocument.ProcessSegmentPairs("Add Text",
    (segPair, eventArg) =>
    {
    if (segmentPair.Properties.Id == segPair.Properties.Id)
    {
    IDocumentItemFactory documentItemFactory = DefaultDocumentItemFactory.CreateInstance();
    ITextProperties textProperties = documentItemFactory.PropertiesFactory.CreateTextProperties(quoteTranslation);
    IText text = documentItemFactory.CreateText(textProperties);
    segPair.Target.Add(text);
    }
    });
    }
Children
No Data