Add placeholders to a segment via the SDK

Dear Community members,

I would like to add placeholders to a segment via the SDK. This is sometimes necessary to add placeholders, e.g. when one block of formatting in the source segment has to be applied as two blocks in the target language (e.g. for verbs with particles in German).

How can I do this via the SDK? I tried to the following but this does not add the placeholders:

WSTextSegmentTranslation txtSeg = assetSegs[1] as WSTextSegmentTranslation;

WSTextSegment segtx = txtSeg.getTargetSegment;

AssetWSTextSegment dataSeg = segtx.getWSTextSegmentDataTransferObject();

dataSeg.content = "This is {1}the{2} new value of the segment";

AssetWSTextSegmentPlaceholder ph = new AssetWSTextSegmentPlaceholder();

ph.pHId = 1;

ph.pHIdSpecified = true;

ph.idSpecified = true;

ph.text = "<cf bold=\"True\">";

ph.token = "123456789";

AssetWSTextSegmentPlaceholder ph2 = new AssetWSTextSegmentPlaceholder();

ph2.pHId = 2;

ph2.pHIdSpecified = true;

ph2.idSpecified = true;

ph2.text = "</cf>";

ph2.token = "123456789";

List<AssetWSTextSegmentPlaceholder> newphs = new List<AssetWSTextSegmentPlaceholder>();

newphs.Add(ph);

newphs.Add(ph2);

dataSeg.targetPlaceholders = new AssetWSTextSegmentPlaceholder[newphs.Count];

Array.Copy(newphs.ToArray(), dataSeg.targetPlaceholders, newphs.Count);

dataSeg.placeholders = new AssetWSTextSegmentPlaceholder[newphs.Count];

Array.Copy(newphs.ToArray(), dataSeg.placeholders, newphs.Count);

segtx.update();

 

Has someone an idea on how I could do this?

Regards,

Laurent