Connecting to Trados Studio from an external script

Hi everyone. I am new to using Trados Studio and also new to developing with Trados Studio, so please forgive me for asking a basic question.

Does anyone know if it is possible to connect to Trados Studio 2019 from, for example, a Python script?

It looks like this was possible with Trados Workbench according to the SDL Trados 2007 Desktop SDK, but as far as I can tell this method doesn't seem to be possible with later versions of Trados Studio.

The current Trados Studio API documentation seems to focus on building internal plug-ins for Trados Studio rather than connecting to a running instance of Trados studio from separate code.

Specifically, I am interested in getting Trados Studio to calculate a matching rate between two Word documents, or between a single Word document and a collection of translation memories.

Any help regarding this would be hugely appreciated.

Best regards, 

Jon

emoji
Parents
  • Hi  , let me see if I understood correctly what you are trying to achieve.  Create a script to perform the following type of automation

    Method 1:

    • Extract the segments from two documents.
    • Perform a comparison against the segments of both documents to identify the differences & calculate a matching rate, edit distance?
    • Calculate a document level score (matching rate), based on the edit distance calculated from each of the segment?

    Method 2:

    • Extract the segment from a document
    • Extract the Translation Units from a Translation Memory
    • Perform the same comparison results as with Method 1

    It should be feasible to execute a command line script from Python.  However, you would still need to work with the Trados Studio APIs in developing the code to achieve this. I would recommend that you create a command line script that can be executed from Python with parameters.  Make reference to the Trados Studio Sample Projects to understand how to work with the various APIs, as well as the relevant documentation that you already made reference to Trados Studio 2019 APIs

    You can also find some good examples from the public repository here: RWS Community. One project in particular Post-Edit Compare will help you understand  how to read & compare the segments, generating a matching rate (segment level)

    emoji
Reply
  • Hi  , let me see if I understood correctly what you are trying to achieve.  Create a script to perform the following type of automation

    Method 1:

    • Extract the segments from two documents.
    • Perform a comparison against the segments of both documents to identify the differences & calculate a matching rate, edit distance?
    • Calculate a document level score (matching rate), based on the edit distance calculated from each of the segment?

    Method 2:

    • Extract the segment from a document
    • Extract the Translation Units from a Translation Memory
    • Perform the same comparison results as with Method 1

    It should be feasible to execute a command line script from Python.  However, you would still need to work with the Trados Studio APIs in developing the code to achieve this. I would recommend that you create a command line script that can be executed from Python with parameters.  Make reference to the Trados Studio Sample Projects to understand how to work with the various APIs, as well as the relevant documentation that you already made reference to Trados Studio 2019 APIs

    You can also find some good examples from the public repository here: RWS Community. One project in particular Post-Edit Compare will help you understand  how to read & compare the segments, generating a matching rate (segment level)

    emoji
Children
  • Hi  .

    Many thanks for the reply. That was very helpful. Much appreciated.

    I have since come across the below sample command line application and I'm using this as a basis to work from.

    https://developers.rws.com/studio-api-docs/apiconcepts/projectautomation/introduction_to_the_sample_app.html

    I have also found an updated version of the code for this sample application on GitHub.

    https://github.com/RWS/trados-studio-api-samples/blob/master/ProjectAutomation/Sdl.SDK.ProjectAutomation.Samples.BatchAnalyze/Program.cs

    I have a question regarding the following in the sample code.

    LicenseManager.ReleaseLicense();  (line 91)

    In Visual Studio 2022, the above line raises the following error.

    'LicenseManager' does not contain a definition for 'ReleaseLicense'. (Code CS0117)

    The sample code includes the below on line 5.

    using Sdl.TranslationStudioAutomation.Licensing;

    Also, "Sdl.TranslationStudioAutomation.Licensing" has been added as a reference to the project in Visual Studio.

    Is there something that I am missing here which would resolve this error? (Sorry, I'm new to Visual Studio and C#.)

    Many thanks,

    Jon

    emoji
  • Check if this way of interacting with Studio via command line would suit your needs. I have developed it some time ago after facing exactly the same problem as you - that SDL totally abandoned the external scripting options and focused purely on the internal GUI-centric plugins Disappointed
    https://github.com/EvzenP/STraSAK

    DISCLAIMER: As I'm out of localization industry for quite some time, I have not followed the latest Studio SDK developments and changes, so it might be that some features stopped working properly.

    emoji
  •  

    Nice to see you back... your ears must have been burning as I'm part way through an article where I mention STraSAK as it's still the best Trados related Powershell repository I've seen anyone sharing.  It is out of date as you suspected as we've had considerable changes since 2021, and we haven't done any work specifically on the Powershell Tookit as you were pretty much the only person pushing for it.  The APIs are well used these days and seem to suffice the needs of users automating tasks.

    However, I do think it would be good to look at this again and update it.  I'm sure many people could take advantage of it as it is much easier than full blown "GUI-centric" development, and faster.

    I also wanted to respond to you because I think you must have had this page saved somewhere as this is actually an archived group so nobody will see it unless they have saved it too... which clearly some do.

    I'll move this over to the appropriate location as it is a useful thread, and will add you to that group just in case you feel like a little light relief from localization retirement.

    Paul Filkin | RWS Group

    ________________________
    Design your own training!

    You've done the courses and still need to go a little further, or still not clear? 
    Tell us what you need in our Community Solutions Hub

    emoji
  • It was a pure coincidence ;-), I just fired up my old Seamonkey suite where I have these forums' RSS feeds subscribed... and spotted this thread (with pretty fresh content actually).

    From time to time I try to download new Studio version to check what's new... just to realize that the ancient bug with getting the real default project template via API is still not fixed... The workarounds I implemented using some internal non-public API stopped working as well... and I wasn't lucky finding out to which different DLL have that APIs moved, so I simply give up...

    The speech recognition industry, where I'm for the last 5+ years, is not plagued by the terribly inefficient GUI-clicking attitude ;-). In fact it's the exact opposite, our customers usually need to process thousands or even millions of audio recordings, so scripting rulez ;-)

    Actually, our company does cooperate with RWS since the SDL times and even right now we are in touch with the Rich Media Delivery department regarding possible use of our speech technologies ;-)

  •  

    with pretty fresh content actually

    Yes... this location was archived a couple of months ago as we restructured the forums and groups to try and have some consistency with the products.  We kept the archived just in case.  I'll pay more attention to it now just in case anyone else gets in there before we remove altogether.

    The workarounds I implemented using some internal non-public API stopped working as well... and I wasn't lucky finding out to which different DLL have that APIs moved, so I simply give up...

    Yes, unfortunate, but powershell and command line working really hasn't been a priority for us.  You were really the cheerleader for that one.  Perhaps we will take a look at your (S)TraSrak project and bring it up to date.  I definitely cannot put a timeline on that but I think it might be useful and could help get things fixed if it turns out to be useful for others.

    Actually, our company does cooperate with RWS since the SDL times and even right now we are in touch with the Rich Media Delivery department regarding possible use of our speech technologies ;-)

    That's interesting!  I'm working on an accessibility project with one of the teams there at the moment.  Seems you just can't get away from us ;-)

    Paul Filkin | RWS Group

    ________________________
    Design your own training!

    You've done the courses and still need to go a little further, or still not clear? 
    Tell us what you need in our Community Solutions Hub