SDL Trados Studio
SDL Trados GroupShare
SDL Trados Business Manager
SDL Trados Live
SDL MultiTerm
SDL Passolo
SDL Speech to Text
SDL Managed Translation - Enterprise
SDL MultiTrans
SDL TMS
SDL WorldServer
Translation Management Connectors
SDL LiveContent S1000D
SDL Contenta S1000D
SDL XPP
SDL Tridion Docs
SDL Tridion Sites
SDL Content Assistant
SDL Machine Translation Cloud
SDL Machine Translation Connectors
SDL Machine Translation Edge
Language Developers
Tridion Developers
Tridion Docs Developers
Xopus Developers
Community Help
SDL User Experience
Language Products - GCS Internal Community
SDL Community Internal Group
SDL Access Customer Portal
SDL Professional Services
SDL Training & Certification
Style Guides
Language Technology Partner Group
SDL Academic Partners
SDL Enterprise Technology Partners
XyUser Group
ETUG (European Trados User Group) Public Information
Machine Translation User Group
Nordic SDL Tridion Docs User Group
SDL Tridion UK Meetup
SDL Tridion User Group New England
SDL Tridion West Coast User Group
SDL WorldServer User Group
Tridion Docs Europe & APAC User Group
Tridion User Group Benelux
Tridion User Group Ohio Valley
SDL MultiTerm Ideas
SDL Passolo Ideas
SDL Trados GroupShare Ideas
SDL Trados Studio Ideas
SDL Machine Translation Cloud Ideas
SDL Machine Translation Edge Ideas
SDL Language Cloud TMS Ideas
SDL Language Cloud Terminology Ideas
SDL Language Cloud Online Editor Ideas
SDL Managed Translation - Enterprise Ideas
SDL TMS Ideas
SDL WorldServer Ideas
SDL Tridion Docs Ideas
SDL Tridion Sites Ideas
SDL LiveContent S1000D Ideas
SDL XPP Ideas
Events & Webinars
To SDL Documentation
To SDL Support
What's New in SDL
Detecting language please wait for.......
Hi there,
I'm currently struggling with something which should be quite simple..
By clicking on a custom ribbon button I'd like to
1. loop over the segment pairs displayed in the editor2. based on a predicate set their property to IsLocked = true3. change the display filter to "view only locked"4. refresh the editor grid.
My neurons are probably affected by the flu, because I couldn't make it work..
My main difficulties are:
1. I can't change and persist the IsLocked property as it switches automatically back to false2. I can't call a refresh on the EditorController because of it's protection level applied to the AbstractViewController3. I never found in the documentation how to change the display filter.
Any help would be much appreciated,
have a great day ...
Greg
Code :
public class ApplyAction : AbstractViewControllerAction<EditorController> { protected override void Execute() { foreach (var s in Controller.ActiveDocument.SegmentPairs) if (/*specific condition*/) s.Properties.IsLocked = true; // can be persited , it switches back to false immediately // Here I'd like to do 2 things // 1. change the editor display filter to "only locked segment" // I've been looking in vain in the documentation, any hint ? // 2. trigger a refresh of the editor // Controller.Refresh is inaccessible due to its protection level. } }
Hi Remi,
Do you implement OnFileComplete method in the class which inherits from AbstractFileContentProcessingAutomaticTask?
If not please add this method because it will save the changes on the document…
MAGIC!!!
That seems to work. Thanks a lot!
We'll post our code on GitHub and the Plugin in the Appstore as usual.
Here we go:
https://github.com/Supertext/Supertext.Sdl.Trados.BatchTasks
A few answers:
Hi,
I don't know if this is still an issue, but this worked for me. First I set up a generic filter:
class GenericSegmentFilter : IDisplayFilter { private Func<ISegmentPair, bool> Evaluator; public GenericSegmentFilter() { } public GenericSegmentFilter(Func<ISegmentPair, bool> evaluator) { Evaluator += evaluator; } public bool EvaluateRow(DisplayFilterRowInfo rowInfo) { return (rowInfo.IsSegment && Evaluator(rowInfo.SegmentPair)); } }
and in your main code:
EditorController ec = SdlTradosStudio.Application.GetController<EditorController>(); Document activedoc = ec.ActiveDocument; // to lock your segments foreach (ISegmentPair isp in activedoc.SegmentPairs.Where(sp => MySpecificCondition(sp))) { ISegmentPairProperties spp = isp.Properties.Clone() as ISegmentPairProperties; spp.IsLocked = true; activedoc.UpdateSegmentPairProperties(isp, spp); } // to filter for locked segments - this will trigger a refresh as well activedoc.ApplyFilterOnSegments(new GenericSegmentFilter(s => s.Target.Properties.IsLocked));
Hope this helps.
Attila
Has anyone figured out how to do this in the batch task API? We're struggling with the same issue there, but obviously ActiveDocument is not available there.
Hi Remy,
Can you please take a look at this source code from Anonymizer plugin? https://github.com/sdl/Sdl-Community/blob/master/Anonymizer/Anonymizer/Process%20Xliff/AnonymizerPreProcessor.cs
https://github.com/sdl/Sdl-Community/blob/master/Anonymizer/Anonymizer/Batch%20Task/AnonymizerTask.cs
Here you have an example on how you can parse an xliff file using a batch task.
Kind regards,
Andrea Ghisa
Hey Andrea
We've based our tool on your Anonymizer. But the locking function does not work:
public override void ProcessParagraphUnit(IParagraphUnit paragraphUnit) { base.ProcessParagraphUnit(paragraphUnit); if (paragraphUnit.IsStructure) { return; } foreach (var segmentPair in paragraphUnit.SegmentPairs.ToList()) { var segmentVisitor = new SegmentVisitor(_patterns, _includeTagContent); segmentVisitor.ReplaceText(segmentPair.Source, ItemFactory, PropertiesFactory); if (segmentVisitor.ShouldLockSegment) { segmentPair.Properties.IsLocked = true; } } }
Any idea here?
If not please add this method because it will save the changes on the document.