Store metadata per segment (SetMetaData)

Hi,

I would like to store some metadata in a project per segment (e.g. an additional identifier). For example, for segment 10, this would look like: ActiveDocument.SegmentPairs.ElementAt(10).Target.Properties.TranslationOrigin.SetMetaData("MyKey", "Meta data information");


This used to work in the past. However, after doing this on a Japanese translation segment, it does not seem to work anymore. After executing this code, "MyKey" is not added.

However, in the debugger, when I invoke this method, the item is added to MetaData.

Does anyone has a clue?

Are there other (better) ways to store information at a segment?

Best regards,
Henk
Parents Reply
  • The UpdateSegmentPair also does not work. I am using a class that inherits from AbstractAutoSuggestProvider. It provides access to the active document and also events when I change segments. 

    Update. The same happens with the EditorController. In the following code, "ActiveDocument_ActiveSegmentChanged" is invoked. The metadata is only set for the first file, not for the second. 

    EditorController _editorController;

    class MyProjectViewPart : AbstractViewPartController

    {
    protected override Control GetContentControl()
    {
    return _control.Value;
    }

    protected override void Initialize()
    {

    _editorController = SdlTradosStudio.Application.GetController<EditorController>();

    _editorController.ActiveDocument.ActiveSegmentChanged += ActiveDocument_ActiveSegmentChanged;

    }


    void ActiveDocument_ActiveSegmentChanged(object sender, EventArgs e)
    {
    var segmentPair = _editorController.ActiveDocument.ActiveSegmentPair;
    segmentPair.Properties.TranslationOrigin.SetMetaData("henk", "henk");
    _editorController.ActiveDocument.UpdateSegmentPair(segmentPair);
    }

Children