I often find myself doing multiple search & replace of the same words again and again in pre-translated segments and I'm thinking there's got to be a way to automate that somewhow, perhaps using a script. Any ideas?
I often find myself doing multiple search & replace of the same words again and again in pre-translated segments and I'm thinking there's got to be a way to automate that somewhow, perhaps using a script. Any ideas?
Hello,
Absolutely, Trados Studio has a feature that can help you with this. It's called "MultiTerm Replace" and it allows you to replace multiple terms in one go. Here's how you can use it:
Step 1: Open your project in Trados Studio.
Step 2: Go to the "Review" tab.
Step 3: Click on "Search" in the "Editing" group.
Step 4: In the "Search" dialog box, click on the "Replace" tab.
Step 5: Enter the term you want to find in the "Search for" box.
Step 6: Enter the term you want to replace it with in the "Replace with" box.
Step 7: Click on "Add to List". This will add the pair to the list of terms to be replaced.
Step 8: Repeat steps 5 to 7 for all the terms you want to replace.
Step 9: Once you've added all the terms, click on "Replace All".
This will replace all instances of the terms in the list throughout your project. Please note that this feature is case-sensitive, so make sure to enter the terms exactly as they appear in your text.
I hope this helps! If you have any other questions, feel free to ask.
Best regards,
RWS Community AI
Excuse me, say what?!
I'm not seeing "Editing" in the Review tab, but I do have it in my Home tab:
I'm not seeing "Search", and Find and Replace simply open the normal Find/Replace window:
Not seeing an "Add to list" option here.
Can someone help me out? It sounds like an interesting feature.
And something else... do you have the French UI and a French operating system language? This may also change things. Have you checked with Windows Spy to make sure the references are correct?
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 script from Paul won’t work on AutoHotkey 2.0. There are major changes on 2.0 and this version is not back-compatible with 1.1.
You should be getting a lot of errors with 2.0. I’m wondering if you are actually running the script…
Uninstall AutoHotkey 2.0 or at least ensure you’re using AutoHotkey 1.1.37.01.
Thanks Paul and Jesús! So I uninstalled AHK 2.0 and installed 1.1.37.01 – same result :-(
I'm using the script exactly as Paul wrote it, except for the link to the settings file. I'm using the English UI for both Windows and Trados. Windows Spy isn't telling me anything particular. So again, the script is triggered when I close the drop-down box, cycles through all the replacements, tells me the operation is complete, but nothing gets changed in the target column. I'm owing a beer (at least one!) to anyone who can help me solve this!
ok - I was testing a bit and I happened to do it on my laptop screen instead of the external monitor I used before and it failed... as yours does.
The positioning of the dropdown menu and the final message box in the script is dependent on the position of the active window (Trados Studio) when the hotkey is pressed. The coordinates are retrieved using WinGetPos, PosX, PosY,,, A
, which gets the position of the active window in screen coordinates, and these are then used to position the GUIs.
When moving between screens with different resolutions or scaling settings, the relative position of the window can change, and it might end up being displayed partially or fully off-screen and throw off the way the script works. To mitigate this issue I used SysGet
to get the size and position of the monitor where the active window is located, and then ensure that the GUIs are positioned within these bounds.
So try this... and fingers crossed you have the same issue!
^!h:: ; The hotkey for Ctrl+Alt+H to start the process global filePaths := {} ; Create an associative array to store full file paths global fileNames := "" ; Create a variable to store the file names global PosX, PosY ; Create global variables to store the dropdown menu's position Gui, Add, DropDownList, w450 vFilePath ; Add a dropdown list to the GUI with width of 400 Gui, Font, s12 ; Set the font size to 12 Loop, Read, c:\AHK scripts\settings.txt ; Read the hardcoded settings file line by line { SplitPath, A_LoopReadLine, name, dir, ext, name_no_ext, drive ; Split the file path into parts fileNames .= name_no_ext . "|" ; Add the file name (without extension) to the string, separated by "|" filePaths[name_no_ext] := A_LoopReadLine ; Store the full file path in the associative array } fileNames := SubStr(fileNames, 1, StrLen(fileNames) - 1) ; Remove the last "|" GuiControl,, FilePath, %fileNames% ; Set the items of the dropdown list WinGetPos, PosX, PosY, Width, Height, A ; Get the position and size of the active window SysGet, Monitor, MonitorWorkArea, % "Monitor" . ((PosX + Width / 2) // (A_ScreenWidth / A_ScreenCount) + 1) ; Get the work area of the monitor where the window's center is located if (PosX < MonitorLeft) PosX := MonitorLeft else if (PosX > MonitorRight - 500) ; 500 is the width of the GUIs PosX := MonitorRight - 500 if (PosY < MonitorTop) PosY := MonitorTop else if (PosY > MonitorBottom - 100) ; 100 is the height of the GUIs PosY := MonitorBottom - 100 PosY := PosY - 150 ; Subtract 150 from PosY Gui, Show, x%PosX% y%PosY% w500 h100, Select a file ; Show the GUI at the position of the active window with a larger window WinSet, AlwaysOnTop, On, A ; Make the GUI always stay on top of other windows return GuiClose: ; When the GUI is closed Gui, Submit, NoHide ; Store the dropdown list's current selection in the variable filePath filePath := filePaths[filePath] ; Retrieve the full file path from the associative array Gui, Destroy ; Destroy the GUI GoSub, StartReplace ; Continue with the search and replace operation return StartReplace: WinActivate, ahk_exe SDLTradosStudio.exe ; Activate SDL Trados Studio Loop, Read, %filePath% ; Read the selected file line by line { StringSplit, line, A_LoopReadLine, `t ; Split the line into "line1" (search term) and "line2" (target term) searchTerm := line1 ; Assign the search term targetTerm := line2 ; Assign the target term ; Click in the "Find what" field ControlClick, Edit2, ahk_exe SDLTradosStudio.exe Sleep, 100 ; Select all text and delete it Send, {Home}+{End}{Del} Sleep, 100 ; Send the search term keystrokes Send, {Text}%searchTerm% Sleep, 100 ; Click in the "Replace with" field ControlClick, Edit1, ahk_exe SDLTradosStudio.exe Sleep, 100 ; Select all text and delete it Send, {Home}+{End}{Del} Sleep, 100 ; Send the target term keystrokes Send, {Text}%targetTerm% Sleep, 100 ; Click the "Replace All" button ControlClick, WindowsForms10.BUTTON.app.0.ea119_r8_ad19, ahk_exe SDLTradosStudio.exe Sleep, 100 } ; PosY := PosY - 150 ; Subtract 150 from PosY Gui, 2:New, +AlwaysOnTop ; Create a new GUI for our custom message box Gui, 2:Font, s12 ; Set the font size to 12 Gui, 2:Add, Text, w500 h50, The search and replace operation is complete. ; Add a text element to the GUI Gui, 2:Show, x%PosX% y%PosY% w500 h100, Operation Complete ; Show the GUI at the position of the dropdown menu with the title "Operation Complete" Sleep, 500 ; Wait for 500 milliseconds (half a second) WinActivate, Operation Complete ; Activate the GUI window using its unique title return 2GuiClose: ; When the custom message box is closed Gui, 2:Destroy ; Destroy the GUI return
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
Oh! Now you can reproduce the issue! But who would have thought the issue might lie in multiple screens? I do use multiple screens; two of them are connected to my laptop. I tried your new script, but alas, not luck. So just to check, I disconnected the two external monitors and rebooted to try it out on my laptop screen alone. Again, no luck. Still cycling through the replacements and gives me an "Operation complete" message, but nothing gets changed in the target column. I'm really puzzled! And unfortunately not technical enough to work on a solution. But definitely eager to keep trying anything else you might suggest. That said, have a wonderful weekend, my friend!
Can you try running the script with administrative rights?
Right-click on the AutoHotkey script (.ahk) file and select "Run as administrator".
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
WindowsForms10.BUTTON.app.0.ea119_r8_ad19
This control name can be the reason of the Replace All button never getting clicked. In my Trados Studio is:
WindowsForms10.BUTTON.app.0.2eed1ca_r7_ad19
Rene: You need to look here in the Spy tool while hoovering the mouse over the Replace All button:
Then copy the control name & paste it to the script.
Bingo! This works for me :-) On first try, it didn't work, but then I moved Trados from my external monitor to my laptop screen and voilà! Thanks so much Jesús and mucho thanks also to Paul for bringing us closer to the solution. Looks like I owe you guys a beer!
One quick question about accents. Replacements with accented characters are transformed in the process. For example, "é" in the replacements lists becomes "é" in the target column. Is there an easy way to address that?
Thanks again and happy Sunday to both of you!
René
Running the script as an administrator did not make any difference, but Jesús solution above does work, provided I have Trados on my laptop screen and not on a external monitor. So it looks like it is indeed an issue with the positioning of the window. Really appreciate you help with this, Paul. Thanks so much once again!
Actually, don't bother with my last question. I just found out diacritics are conveyed properly when the replacements file is saved as UTF-8 with BOM
Actually, don't bother with my last question. I just found out diacritics are conveyed properly when the replacements file is saved as UTF-8 with BOM