SDL PowerShell Toolkit

SDL is pleased to announce the availability of a beta version of the SDL PowerShell Toolkit.

The SDL PowerShell Toolkit is a set of modules using Windows PowerShell scripting technology and the Project Automation and Translation Provider APIs from the SDL Trados Studio Professional SDK. In a nutshell, the modules provide functions and sample code that you can re-use in your PowerShell scripts to automate SDL Trados Studio. They feature an initial set of code for use in typical Studio automation tasks such as creating a project, a translation memory or a package derived from a project. You can use these as a starting point for your own PowerShell-based efforts. It is assumed that the reader is familiar with Windows PowerShell as well as an initial understanding of the SDL Trados Studio SDK, in particular the project automation API.

Over time, we would like to see the development community develop further modules and helpful functions that we can share with each other.

Best regards, Ian

Ian Davies | Senior Product Manager | SDL | Language Technologies Division | +44 7826843819

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

PowerShellToolkit.zip
  • Hi Romulus,

    my offline documentation says pretty clearly this:

    FileBasedProject Constructor (ProjectInfo)
    Creates a new project based on the default project template set up in SDL Trados Studio.
    ...
    Remarks
    The default project template has to be set up before you can use this constructor. This is done automatically when SDL Trados Studio starts for the first time after installation.

    And that's actually the ONLY thing which makes sense - that if I select the "Trados" profile during the first run after installation, this (and only this) template will be used as default... just as Studio does "at the UI level".
    Any other behavior does not make any sense since it would be inconsistent with the "UI level behavior" and different than documented.

  • Hello,

    I just wanted to try this toolkit on my pc but I could not do it right. I get below error.

    Can you tell me what is wrong?

  • Hi Sinan,

    The powershell toolkit has not been updated for over 6 years....
    I mean, the original code points to Trados 2011...
    github.com/.../TMHelper.psm1

    The error your are getting "cannot find an overload" is trying to call a method which no longer exists in newer versions of Trados Studio. (IIRC that overload existed until Trados Studio 2014).

    Long story short, it badly needs updating, but no one takes the time to do it :).
  • As Jesse says, the toolkit was created for older Studio version which uses only 4 parameters for creation of filebased TM.

    I changed my toolkit modules to accept $StudioVersion as parameter (which is simply the variable part of Studio program files path)

    param([String]$StudioVersion = "Studio4")

    if ("${Env:ProgramFiles(x86)}")
    {
        $ProgramFilesDir = "${Env:ProgramFiles(x86)}"
    }
    else
    {
        $ProgramFilesDir = "${Env:ProgramFiles}"
    }

    Add-Type -Path "$ProgramFilesDir\SDL\SDL Trados Studio\$StudioVersion\Sdl.LanguagePlatform.TranslationMemoryApi.dll"
    Add-Type -Path "$ProgramFilesDir\SDL\SDL Trados Studio\$StudioVersion\Sdl.LanguagePlatform.TranslationMemory.dll"

    and then use it to differentiate the TM creation calls

        if ($StudioVersion -le "Studio3")
        {
            $TM = New-Object Sdl.LanguagePlatform.TranslationMemoryApi.FileBasedTranslationMemory ($TMPath, $Description, $TMSourceLanguage, $TMTargetLanguage, $FuzzyIndexes, $Recognizers)
        }
        else
        {
            $TM = New-Object Sdl.LanguagePlatform.TranslationMemoryApi.FileBasedTranslationMemory ($TMPath, $Description, $TMSourceLanguage, $TMTargetLanguage, $FuzzyIndexes, $Recognizers, $TokenizerFlags, $WordCountFlags)
        }


    In other words, newer Studio versions need 6 parameters when creating filebased TM (that's why the error message states the number 6 ;-) ).

    I may eventually publish my heavily changed toolkit on GitHub, but it's still lacking some TM-related updates... and I don't have much time to finish that :-\.

  • Oh, but the second error may be a showstopper - you need Professional license in order to be able to use the Project Automation API.

    So if you don't have that, don't even bother digging deeper into PowerShell Toolkit...

  • Hi,

    Just an update to let you know that there is an updated version of the PowerShell Toolkit here:

    No major changes, but support for Studio4/5 and couple of things here and there:

    • The paths to the .dll files are now identified regardless of the operating system(32-bit of 64-bit)
    • The user can select which version of Studio is in use (Studio4 or Studio5)
    • The script now creates in "SampleRoundtrip.ps1" a sample text file with custom content
    • The "Get-Project" function only requires as parameter the path to the .sdlproj file
    • The "New-Project" function automatically creates the source file directory
    • Updated the "New-FileBasedTM" function from TMHelper module to use the new implemention from Studio
    • Updated the "New-Project" function from "SampleRoundtrip.ps1” to use the new implementation from Studio

    Thanks to  for updating it and to  for his advice during the process.  I know this doesn't solve all the problems raised as some of the things require changes in Studio but this is an improvement which I hope will be useful.

    Regards

    Paul

    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

  • To give back something to the community, here is my modification of the Powershell Toolkit.
    I dare to say that after all the modifications and enhancements it has hardly something to do with the original toolkit anymore...

    https://github.com/EvzenP/STraSAK/

    I have also a GUI launcher created as Powershell script, but since it's somehow contradicting the main purpose of scriptable automation (i.e. avoiding clicking in GUI), I'm probably not going to release it anyway ;-)

  • Thanks Evzen, it's great that you have shared your work. I hope it's helpful for other localization engineers out there working with powershell as extensively as you do.

    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

  • The point is that the "consumers" don't need to know anything about Powershell.
    It's just that the scripts are written in Powershell... but that doesn't say anything about the environment they can be used in!

    I really don't understand where this weird asumption comes from... it's like if people would assume that they need to know C# if they want to use Trados Studio or Microsoft Office... :-\

  • Perhaps you should have posted this into the TP forum and not the developers forum then? I assumed incorrectly based on you sharing code for coders.

    Still happy to see you share your work though :-)

    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