Is it possible to get a reference to the calling project from the Plugin?

 Hello, I was wondering if it was possible to get a reference to the calling project when using your own translation provider. What would be the starting point?

Parents
  • Hi  

    Yes is possible to take a reference to the calling project like this:

    • Please make sure you add your project Sdl.TranslationStudioAutomation.IntegrationApi.dll
    • We'll use the Intergration APi to gat a reference to Projects Controller:

    var projectsController = SdlTradosStudio.Application.GetController<ProjectsController>();

    var currentProject = projectsController.CurrentProject;

    If you have any questions do not hesitate to ask.

     

    Kind regards,

    Andrea Ghisa

  • Hello, thank you for your reply. As a matter of fact, I do have a few follow up questions... Your post put me on the trail of what to look for, and found a post that seems to indicate that more DLLs are needed, otherwise, it wont works "as is posted". In the end, these were the references I had to add:
    Sdl.TranslationStudioAutomation.IntegrationApi;
    Sdl.ProjectAutomation.FileBased;

    With these two references, I was able to get the project file path with this:
    ProjectsController pcProjectController = SdlTradosStudio.Application.GetController<ProjectsController>();
    string strCurrentProject = pcProjectController.CurrentProject.FilePath;

    The code you posted, for which version of SDL should it be used for? V 2017 or 2019? Is there a difference?

    Finally: Im using project automation to prep files automatically, and am including a reference to our MT plugin. Is it possible to:
    1. Get the file (that is currently getting translated) that the plugin is working on as well as the project? By diving into the CurrentProject object properties, this shows that there is a GetFile function, but Im not sure how I would generate the GUID necessary to get a reference to the file that the plugin is working with...
    2. Get some information as to what is the "context" of the operation. What I mean by this: the plugin can/should be used by either humans (to do discrete lookups, on a segment by segment basis), or by my automated workflow (no humans involved). I was wondering how/if a distinction could be made...
Reply
  • Hello, thank you for your reply. As a matter of fact, I do have a few follow up questions... Your post put me on the trail of what to look for, and found a post that seems to indicate that more DLLs are needed, otherwise, it wont works "as is posted". In the end, these were the references I had to add:
    Sdl.TranslationStudioAutomation.IntegrationApi;
    Sdl.ProjectAutomation.FileBased;

    With these two references, I was able to get the project file path with this:
    ProjectsController pcProjectController = SdlTradosStudio.Application.GetController<ProjectsController>();
    string strCurrentProject = pcProjectController.CurrentProject.FilePath;

    The code you posted, for which version of SDL should it be used for? V 2017 or 2019? Is there a difference?

    Finally: Im using project automation to prep files automatically, and am including a reference to our MT plugin. Is it possible to:
    1. Get the file (that is currently getting translated) that the plugin is working on as well as the project? By diving into the CurrentProject object properties, this shows that there is a GetFile function, but Im not sure how I would generate the GUID necessary to get a reference to the file that the plugin is working with...
    2. Get some information as to what is the "context" of the operation. What I mean by this: the plugin can/should be used by either humans (to do discrete lookups, on a segment by segment basis), or by my automated workflow (no humans involved). I was wondering how/if a distinction could be made...
Children
No Data