I meant to write a short article about OmegaT script basics for a long time, but never found time to do so. This mishap got fixed without me, and out of gratitude I’m posting my translation of Gli script di OmegaT by LanguageLane.
OmegaT scripts
This is the first article in a series that is going to present some features and usage techniques of an advanced computer assisted program OmegaT. Let’s start with scripts, which are a very useful piece of software and can be thought of as a way for OmegaT script writers to add new functionality to the program and make it capable of performing operations that are not (yet) implemented by the developers. This article describes how to load scripts in OmegaT and shows where to find useful scripts created by OmegaT users.
What are scripts and how do they work?
Installing Scripting feature in OmegaT
Assigning a shortcut to a script
What are OmegaT scripts and how do they work?
A script is a text file that contains programming instructions to perform certain actions withing OmegaT. One can expand OmegaT capabilities by the use of scripts. Script writers can create scripts capable of performing various types of actions: replacing text in target segments, saving files that contain only certain segments, controlling translated text in different ways, exporting the entire project translation memory, or only a part of it, etc.
OmegaT scripts are located in one particular folder (which may or may not be inside the OmegaT installation folder). When you run a script, OmegaT searches for its code in the folder with the scripts, and executes it.
Installing Scripting feature in OmegaT
Depending on the OmegaT version installed on your computer, it might be necessary to add the Scripting functionality via plug-in. Currently, OmegaT is available at www.omegat.org website in two versions: Standard (2.6.3-08) and Latest (3.0.8). I recommend using the latest version because of its feature-richness, and this version is well tested and thoroughly checked. Its only drawback compared to the standard version is that the documentation is not up to date and user guide doesn’t include all the details. In the latest version the scripting functionality is preinstalled, so there is no need to install anything extra. But in the standard version the scripting functionality needs to be installed as a plug-in. Let’s see how to do it.
Installing the scripting functionality (only for those who have installed the standard version of OmegaT)
- Go to http://sourceforge.net/projects/omegat-plugins/files/OmegaT-Scripting/
- Select the most recent version (currently it’s OmegaT update3 2.5.0 and later)
- Select the zip file OmegaT-Scripting_x.x.x.x.zip (where x‘s indicate the version number). Caution: Do not download OmegaT-Scripting-src_x.x.x.x.zip, since this file contains Scripting plugin source code and is intended for use by scripting functionality developers.
- The downloading of .zip will commence. Select a folder on your computer where to save this .zip file
- Unzip the downloaded .zip file into plugin folder located inside the OmegaT installation folder (for example C:\Program Files\OmegaT\plugins).
- Launch OmegaT. Now under Tools menu you’ll find a new item that says Scripting…
At this point it becomes possible to use scripts.
Using a script
To use a script:
- Click Tools → Scripting…
- Select the script you want to run in the list on the left. The top horizontal part of the windows shows you the text of the script, while the bottom horizontal part will contain messages printed during and after script execution.
- If needed, set some parameters in the script’s code (for example, in the script “Search and Replace” you must specify strings to search for and to replace with.)
- Click on the Run button to run the script.
- Download the script you want to a folder on your computer (or if you know how to write them yourself, write one ad hoc).
- Click Tools → Scripting…
- The Scripting window will open.
- In the upper part of the window there is a field Scripts folder that shows the path to the directory where OmegaT searches for the scripts to display.
- Open this scripts folder path by the means of your operating system (to do this, you can select the path in the Scripting window, copy it, and then paste it into the address bar of your File Manager).
- Copy the new script into that folder.
- One of the quickest options to update the script list in the Scripting window is to click Choose… button and re-select the path to the folder that contains the scripts. The new script will appear in the script list displayed in the left part of the window.
Where to find OmegaT scripts?
A good number of OmegaT script is automatically installed during the installation of OmegaT itself. So for most common operations you may not need to download and install anything extra.
A terrific source of new scripts is Kos Ivantsov’s blog Translator’s Recipes. This blog contains many useful scripts written by Kos.
Assigning a shortcut to a script
OmegaT allows you to assign keyboard shortcuts to scripts to be able to invoke them quickly from the main window without needing to go to Tools → Scripting…
To do this, perform the following steps:
- Click menu Tools → Scripting…
- The Scripting window will open.
- In the list on the left select the script you want to assign a keyboard shortcut to.
- In the lower part of the window, right click on one of the buttons with numbers.
- Select the option Add script. The selected number will be bracketed by two angle brackets (<3>, for example).
From this point the selected script can be invoked by pressing CTRL+SHIFT+Fn, where n is the selected number. In the example on the screenshot it is CTRL+SHIFT+F3.
Hi,
Thanks for this article. I was wondering why there isn’t a Script path folder in the MacOS version. I have the latest version of OmegaT.
Hi! How can I use python / Tcl scripts in OmegaT? It seems they aren’t supported,
Not directly. There’s a way to enable jython, or you may use a js or groovy script that will pass the necessary stuff to an external application or script, and then wait (if needed) for the output to process it further.