Skip to content

Update Toolkit to work with Trados Studio 2022 and Trados Studio 2024… #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions Modules/DependencyLoader/DependencyLoader.psd1
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
@{

# Script module or binary module file associated with this manifest
ModuleToProcess = 'DependencyLoader.psm1'

# Version number of this module.
ModuleVersion = '1.0.0.0'

# ID used to uniquely identify this module
GUID = '{469B2B87-6367-4015-AF55-0C9CE7F68A52}'

# Author of this module
Author = 'Trados AppStore Team'

# Company or vendor of this module
CompanyName = 'SDL Limited as part of the RWS Holdings Plc group of companies'

# Copyright statement for this module
Copyright = 'Copyright © 2011 - 2022 SDL Limited as part of the RWS Holdings Plc group of companies (\"RWS Group\").'

# Description of the functionality provided by this module
Description = 'A PowerShell module to Load the other modules and their dependencies and resolve the versioning conflicts.'

# Minimum version of the Windows PowerShell engine required by this module
PowerShellVersion = '2.0'

# Minimum version of the .NET Framework required by this module
DotNetFrameworkVersion = '2.0'

# Minimum version of the common language runtime (CLR) required by this module
CLRVersion = '2.0.50727'

# Processor architecture (None, X86, Amd64, IA64) required by this module
ProcessorArchitecture = 'None'

# Modules that must be imported into the global environment prior to importing
# this module
RequiredModules = @()

# Assemblies that must be loaded prior to importing this module
RequiredAssemblies = @()

# Script files (.ps1) that are run in the caller's environment prior to
# importing this module
ScriptsToProcess = @()

# Type files (.ps1xml) to be loaded when importing this module
TypesToProcess = @()

# Format files (.ps1xml) to be loaded when importing this module
FormatsToProcess = @()

# Modules to import as nested modules of the module specified in
# ModuleToProcess
NestedModules = @()

# Functions to export from this module
FunctionsToExport = '*'

# Cmdlets to export from this module
CmdletsToExport = '*'

# Variables to export from this module
VariablesToExport = '*'

# Aliases to export from this module
AliasesToExport = '*'

# List of all modules packaged with this module
ModuleList = @()

# List of all files packaged with this module
FileList = @(
'.\DependencyLoader.psm1'
'.\DependencyLoader.psd1'
)

# Private data to pass to the module specified in ModuleToProcess
PrivateData = ''

}
46 changes: 46 additions & 0 deletions Modules/DependencyLoader/DependencyLoader.psm1
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
param ([String] $studioVersion = "Studio18")

# Helper module that loads all the others and resolve the versioning conflicts between powershell versions and Trados versions
$scriptPath = $MyInvocation.MyCommand.Path
$scriptParentDiv = Split-Path $scriptPath -Parent;
$moduleNames = @("GetGuids", "PackageHelper", "ProjectHelper", "TMHelper")

Add-Dependencies $studioVersion;

foreach ($moduleName in $moduleNames)
{
Import-Module -Name $moduleName -Scope Global -ArgumentList $studioVersion
}

function Add-Dependencies {
param([String] $StudioVersion)

$assemblyResolverPath = $scriptParentDiv + "\DependencyResolver.dll"
$versionNumber = [regex]::Match($StudioVersion, "\d+").Value;

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

if ($versionNumber -le 16)
{
$appPath = "$ProgramFilesDir\Sdl\Sdl Trados Studio\$StudioVersion\"
}
else {
$appPath = "$ProgramFilesDir\Trados\Trados Studio\$StudioVersion\"
}

# $appPath = "C:\Users\aflorescu\Code\TradosStudio\Bin\Mixed Platforms\Debug"
# Solve dependency conficts
Add-Type -Path $assemblyResolverPath;
$assemblyResolver = New-Object DependencyResolver.AssemblyResolver("$appPath\");
$assemblyResolver.Resolve();

Add-Type -Path "$appPath\Sdl.ProjectAutomation.Core.dll"
Add-Type -Path "$appPath\Sdl.ProjectAutomation.FileBased.dll"
Add-Type -Path "$appPath\Sdl.ProjectAutomation.Settings.dll"
Add-Type -Path "$appPath\Sdl.LanguagePlatform.TranslationMemory.dll"
}
Binary file added Modules/DependencyLoader/DependencyResolver.dll
Binary file not shown.
6 changes: 3 additions & 3 deletions Modules/PackageHelper/PackageHelper.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ ModuleVersion = '1.0.0.0'
GUID = '{766899a3-186e-4bf2-b39f-b7d001d67105}'

# Author of this module
Author = 'Patrik Mazanek'
Author = 'Trados AppStore Team'

# Company or vendor of this module
CompanyName = 'SDL'
CompanyName = 'SDL Limited as part of the RWS Holdings Plc group of companies'

# Copyright statement for this module
Copyright = '© 2011 SDL. All rights reserved.'
Copyright = 'Copyright © 2011 - 2022 SDL Limited as part of the RWS Holdings Plc group of companies (\"RWS Group\").'

# Description of the functionality provided by this module
Description = 'A PowerShell module to help project package management'
Expand Down
17 changes: 1 addition & 16 deletions Modules/PackageHelper/PackageHelper.psm1
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
param([String]$StudioVersion = "Studio5")

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

Add-Type -Path "$ProgramFilesDir\SDL\SDL Trados Studio\$StudioVersion\Sdl.ProjectAutomation.FileBased.dll"
Add-Type -Path "$ProgramFilesDir\SDL\SDL Trados Studio\$StudioVersion\Sdl.ProjectAutomation.Core.dll"

$LanguagesSeparator = "\s+|;\s*|,\s*"

$ProjectPackageExtension = ".sdlppx"
$ReturnPackageExtension = ".sdlrpx"
param ([string] $studioVersion = "Studio18")

function Export-Package {
<#
Expand Down
6 changes: 3 additions & 3 deletions Modules/ProjectHelper/ProjectHelper.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ ModuleVersion = '1.0.0.0'
GUID = '{5eae9ba2-b21e-4b59-b60a-6f519ec522dc}'

# Author of this module
Author = 'Patrik Mazanek'
Author = 'Trados AppStore Team'

# Company or vendor of this module
CompanyName = 'SDL'
CompanyName = 'SDL Limited as part of the RWS Holdings Plc group of companies'

# Copyright statement for this module
Copyright = '© 2011 SDL. All rights reserved.'
Copyright = 'Copyright © 2011 - 2022 SDL Limited as part of the RWS Holdings Plc group of companies (\"RWS Group\").'

# Description of the functionality provided by this module
Description = 'A PowerShell module to automate SDL Trados Studio project management'
Expand Down
68 changes: 23 additions & 45 deletions Modules/ProjectHelper/ProjectHelper.psm1
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
param([String]$StudioVersion = "Studio5")

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

Add-Type -Path "$ProgramFilesDir\SDL\SDL Trados Studio\$StudioVersion\Sdl.ProjectAutomation.FileBased.dll"
Add-Type -Path "$ProgramFilesDir\SDL\SDL Trados Studio\$StudioVersion\Sdl.ProjectAutomation.Core.dll"
Add-Type -Path "$ProgramFilesDir\SDL\SDL Trados Studio\$StudioVersion\Sdl.ProjectApi.dll"
param ([string] $studioVersion = "Studio18")

# Helper for handling PowerShell runspace issues with multithreaded event handlers
# https://stackoverflow.com/questions/53788232/system-threading-timer-kills-the-powershell-console/53789011

Add-Type -TypeDefinition @'
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -56,30 +46,6 @@ public class RunspacedDelegateFactory

$LanguagesSeparator = "\s+|;\s*|,\s*"

$StudioVersionsMap = @{
Studio2 = "10.0.0.0"
Studio3 = "11.0.0.0"
Studio4 = "12.0.0.0"
Studio5 = "14.0.0.0"
Studio15 = "15.0.0.0"
Studio16 = "16.0.0.0"
}

function Get-DefaultProjectTemplate {
##########################################################################################################
# Due to API bug basing new projects on "Default.sdltpl" template instead of actual default project template,
# we need to find the real default template configured in Trados Studio by reading the configuration files
$StudioVersionAppData = $StudioVersionsMap[$StudioVersion]
# Get default project template GUID from the user settings file
$UserSettingsFilePath = "${Env:AppData}\SDL\SDL Trados Studio\$StudioVersionAppData\UserSettings.xml"
$DefaultProjectTemplateGuid = (Select-Xml -Path $UserSettingsFilePath -XPath "//Setting[@Id='DefaultProjectTemplateGuid']").Node.InnerText
# Get user's project templates and get the default one using the GUID
$ProjectTemplates = [Sdl.ProjectApi.ApplicationFactory]::CreateApplication().LocalProjectServers[0].ProjectTemplates
$DefaultProjectTemplate = ($ProjectTemplates | Where-Object -Property Guid -eq $DefaultProjectTemplateGuid).FilePath

return $DefaultProjectTemplate
}

function New-Project {
<#
.SYNOPSIS
Expand Down Expand Up @@ -168,7 +134,7 @@ Analyze task is run after scanning, converting and copying to target languages.
# If this parameter is not specified, default project template set in Trados Studio will be used.
[Parameter (ParameterSetName = "ProjectTemplate")]
[Alias("PrjTpl")]
[String] $ProjectTemplate = $(Get-DefaultProjectTemplate),
[String] $ProjectTemplate = $null,

# Path to project file (*.sdlproj) on which the created project will be based.
[Parameter (ParameterSetName = "ProjectReference")]
Expand Down Expand Up @@ -219,9 +185,15 @@ Analyze task is run after scanning, converting and copying to target languages.
# Get project creation reference, depending on provided parameters
switch ($PsCmdlet.ParameterSetName) {
"ProjectTemplate" {
$ProjectTemplate = (Resolve-Path -LiteralPath $ProjectTemplate).ProviderPath
$ProjectCreationReference = New-Object Sdl.ProjectAutomation.Core.ProjectTemplateReference $ProjectTemplate
break
if ($ProjectTemplate)
{
$ProjectTemplate = (Resolve-Path -LiteralPath $ProjectTemplate).ProviderPath
$ProjectCreationReference = New-Object Sdl.ProjectAutomation.Core.ProjectTemplateReference $ProjectTemplate
break
}

$ProjectCreationReference = $null;
break;
}
"ProjectReference" {
$ProjectReference = (Resolve-Path -LiteralPath $ProjectReference).ProviderPath
Expand Down Expand Up @@ -252,7 +224,14 @@ Analyze task is run after scanning, converting and copying to target languages.
}

# Crete new project using creation reference and constructed project info
$Project = New-Object Sdl.ProjectAutomation.FileBased.FileBasedProject ($ProjectInfo, $ProjectCreationReference)
if ($ProjectCreationReference)
{
$Project = New-Object Sdl.ProjectAutomation.FileBased.FileBasedProject ($ProjectInfo, $ProjectCreationReference)
}
else
{
$Project = New-Object Sdl.ProjectAutomation.FileBased.FileBasedProject ($ProjectInfo)
}

# Get project languages
$TargetLanguagesList = @($Project.GetProjectInfo().TargetLanguages.IsoAbbreviation)
Expand Down Expand Up @@ -1097,7 +1076,7 @@ function Validate-Task {

function Validate-TaskSequence {
param (
[Sdl.ProjectAutomation.FileBased.TaskSequence] $TaskSequenceToValidate
[Sdl.ProjectAutomation.Core.TaskSequence] $TaskSequenceToValidate
)

ForEach ($Task in $TaskSequenceToValidate.SubTasks) {
Expand All @@ -1111,8 +1090,7 @@ Export-ModuleMember Get-Project
Export-ModuleMember Remove-Project
Export-ModuleMember ConvertTo-TradosLog
Export-ModuleMember Export-TargetFiles
Export-ModuleMember Update-MainTMs
Export-ModuleMember Update-MainTMs
Export-ModuleMember PseudoTranslate -Alias Pseudo
Export-ModuleMember Get-BilingualFileMappings
Export-ModuleMember Get-TaskFileInfoFiles
Export-ModuleMember Get-DefaultProjectTemplate
Export-ModuleMember Get-TaskFileInfoFiles
6 changes: 3 additions & 3 deletions Modules/TMHelper/TMHelper.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ ModuleVersion = '1.0.0.0'
GUID = '{6ccd7a22-904b-4494-8795-88b1f41f0199}'

# Author of this module
Author = 'Patrik Mazanek'
Author = 'Trados AppStore Team'

# Company or vendor of this module
CompanyName = 'SDL'
CompanyName = 'SDL Limited as part of the RWS Holdings Plc group of companies'

# Copyright statement for this module
Copyright = '© 2011 SDL. All rights reserved.'
Copyright = 'Copyright © 2011 - 2022 SDL Limited as part of the RWS Holdings Plc group of companies (\"RWS Group\").'

# Description of the functionality provided by this module
Description = 'A PowerShell module to help SDL Translation Memories management'
Expand Down
28 changes: 10 additions & 18 deletions Modules/TMHelper/TMHelper.psm1
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
param([String]$StudioVersion = "Studio5")

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"
param ([string] $studioVersion = "Studio18")

# Helper for handling PowerShell runspace issues with multithreaded event handlers
# https://stackoverflow.com/questions/53788232/system-threading-timer-kills-the-powershell-console/53789011
Expand Down Expand Up @@ -203,8 +193,10 @@ Creates "Contoso Main en-US_de-DE.sdltm", "Contoso Main en-US_fr-FR.sdltm" and "
$TM = New-Object Sdl.LanguagePlatform.TranslationMemoryApi.FileBasedTranslationMemory ($TMPath, $Description, $TMSourceLanguage, $TMTargetLanguage, $FuzzyIndexes, $Recognizers)
} elseif ($_StudioVersion -eq 4) {
$TM = New-Object Sdl.LanguagePlatform.TranslationMemoryApi.FileBasedTranslationMemory ($TMPath, $Description, $TMSourceLanguage, $TMTargetLanguage, $FuzzyIndexes, $Recognizers, $TokenizerFlags, $WordCountFlags)
} else {
} elseif ($_StudioVersion -le 16) {
$TM = New-Object Sdl.LanguagePlatform.TranslationMemoryApi.FileBasedTranslationMemory ($TMPath, $Description, $TMSourceLanguage, $TMTargetLanguage, $FuzzyIndexes, $Recognizers, $TokenizerFlags, $WordCountFlags, $true)
} else {
$TM = New-Object Sdl.LanguagePlatform.TranslationMemoryApi.FileBasedTranslationMemory ($TMPath, $Description, $TMSourceLanguage, $TMTargetLanguage, $FuzzyIndexes, $Recognizers, $TokenizerFlags, $WordCountFlags)
}

# Add the created TM to output array (if exists)
Expand Down Expand Up @@ -748,13 +740,13 @@ Export-ModuleMember Get-DefaultFuzzyIndexes
Export-ModuleMember Get-DefaultRecognizers
Export-ModuleMember Get-DefaultTokenizerFlags
Export-ModuleMember Get-DefaultWordCountFlags
Export-ModuleMember Get-Language
Export-ModuleMember Get-Languages
Export-ModuleMember Get-Language
Export-ModuleMember Get-Languages
Export-ModuleMember Get-TMSourceLanguage
Export-ModuleMember Get-TMTargetLanguage
Export-ModuleMember Get-TMFuzzyIndexes
Export-ModuleMember Get-TMTargetLanguage
Export-ModuleMember Get-TMFuzzyIndexes
Export-ModuleMember Get-TMRecognizers
Export-ModuleMember Get-TMTokenizerFlags
Export-ModuleMember Get-TMTokenizerFlags
Export-ModuleMember Get-TMWordCountFlags
Export-ModuleMember Import-TMX
Export-ModuleMember Export-TMX
Export-ModuleMember Export-TMX
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ https://windowsserver.uservoice.com/forums/301869-powershell/suggestions/1597627
https://windowsserver.uservoice.com/forums/301869-powershell/suggestions/11088702-start-process-doesn-t-work-if-in-a-directory-name

## Version history
### STraSAK v1.9 &nbsp; &nbsp; &nbsp; (2024-07-12)
* Added support for Studio 2022 and Studio 2024

### STraSAK v1.8 &nbsp; &nbsp; &nbsp; (2021-01-13)
* Added support for Studio 2021

Expand Down
Loading