Documentation Center

Example 4 - Integrating the TRADOS Workbench

It is possible to get translations for texts also from other applications. This example demonstrates how the TRADOS Workbench can be used for automatic translation.

0001 Option Explicit
0002
0003 Dim TW3App As TW4Win.Application
0004 Dim TW3Mem As TW4Win.TranslationMemory
0005
0006 Public Sub PSL_OnAutoTranslate(Translations As PslTranslations, _
0007                       ByVal MinMatch As Long, ByVal MaxCount As Long)
0008   Dim TUnit As TranslationUnit, i As Integer
0009
0010   If TW3Mem Is Nothing Then Exit Sub
0011
0012   TW3Mem.Search (Translations.SourceString)
0013   Set TUnit = TW3Mem.TranslationUnit
0014
0015   For i = 1 To TW3Mem.HitCount
0016     Translations.Add(TUnit.Target, TUnit.Source, TUnit.Score, "TW")
0017     TUnit.Next
0018   Next i
0019 End Sub
0020
0021 Public Sub PSL_OnStartScript()
0022   Set TW3App = CreateObject("TW4Win.Application")
0023
0024   If TW3App Is Nothing Then
0025     MsgBox("Can't open the TRADOS Workbench")
0026     Exit Sub
0027   End If
0028
0029   Set TW3Mem = TW3App.TranslationMemory
0030   TW3Mem.Open("c:\ddata\demo\trados\psldemoed.tmw", "User")
0031 End Sub

To start the TRADOS Workbench takes quite a while, so it make sense to start the Workbench directly when the macro is started (lines 21 to 31). The Workbench application object and translation memory object are global (lines 3 and 4) and will exist until the system macro is stopped or SDL Passolo is closed.

If the user presses F8 in the editor windows of SDL Passolo the call back handler PSL_OnAutoTranslate will be called. Translations.SourceString contains the string that needs to get translated. In line 12 the text will be looked up in the translation memory. The translations returned from the translation memory will be added to the collection of translations in lines 15 to 18.

How to use it

Select PslTrados as the system macro in the dialog Macro and active the system macro with the command Tools / System Macro / Start System Macro.

Open a translation list and double click a text that you want to translate. In the editor window press F8. The result could look like this: