Hello,
I am writing a plugin function for Studio 2021 (SR1 CU9), adding an optional TM to the project settings of the active document.
This would be the equivalent manual procedure:
- Open Project Settings / Translation Memory and Automated Translation
- Use... and select the TM to use
- Click on OK to close the Project Settings dialog.
The manual procedure triggers the update of the content in the Translation Memory Result view and matches are available immediately from the new TM.
However, if I do the same automatically from a context menu in the Editor controller, no refresh takes place and the new TM is not active even if I change segments. Opening the Project Settings dialog confirms that the code worked, but I need to manually click OK again to refresh the editor.
See my code below. Is there any way to trigger a refresh for the Editor controller without closing and reopening the active document, simulating the click on OK for the Project Settings?
EditorController ec = SdlTradosStudio.Application.GetController<EditorController>(); Document ad = ec?.ActiveDocument as Document; FileBasedProject proj = ad?.Project; if (proj != null) { TranslationProviderConfiguration tpc = proj.GetTranslationProviderConfiguration(); TranslationProviderReference tref = new TranslationProviderReference(new Uri("sdltm.https://path_to_TM")); TranslationProviderCascadeEntry ce = new TranslationProviderCascadeEntry(tref, false, true, true); tpc.Entries.Add(ce); proj.UpdateTranslationProviderConfiguration(tpc); proj.Save(); // code needed to refresh the editor at this point }
Thank you,
Attila