OmegaT Scripts

This is the first article of a series presenting some advanced features of the Computer Assisted Translation software OmegaT. Let's start with scripts, which are a way for OmegaT script writers to add new features to the software 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 where to find useful scripts created by OmegaT users. 

What are scripts and how do they work?

Script Download

Using a script

Where to find OmegaT scripts?

Assigning a shortcut to a script

(Print version)

[Leggi questo articolo in italiano]

What are OmegaT scripts and how do they work?

A script is a text file containing programming instructions to perform certain actions within OmegaT. OmegaT scripts are written using the programming language groovy; so the scripts filename pattern is: filename.groovy.

Scripts allow to expand OmegaT capabilities. Script writers can create scripts capable of performing several actions: replacing text in target segments, saving files containing only certain segments, checking translations in different ways, exporting the entire project translation memory, or only a part of it, etc.

OmegaT scripts are located in a local folder (which may or may not be inside the OmegaT installation folder). When you run a script, OmegaT searches for its code in the scripts folder and executes it.

Script Download

The download and installation of a script differ slightly according to the script creator and the site where the script has been published. The procedure to download a script is more or less the following:

  1. Open the web page where the script is published.
  2. Download the script file or copy the script content on a raw text file and save it with the .groovy extension.
  3. If the downloaded file is a compressed archive, unzip the archive using an appropriate software. Note: Developers using Linux often save script file in compressed files with the .tar.bz2 format. To unzip these files in Windows, I recommend to use the open-source software 7zip. Inside the zipped file you will file a file with the .groovy extension.
  4. Copy the .groovy file in the OmegaT scripts folder, as described in the next section.

Using a script

To import new scripts in the Scripting screen:
  1. Download the desired script to a local folder on your computer (or if you know how to write a script, just write it).
  2. Click Tools > Scripting
  3. The Scripting window appears.
  4. In the upper part of the window, the Scripts folder field shows the path where OmegaT looks for the scripts to display.
  5. Open this scripts directory in a File System window (to do this, select the path in the Scripting window, copy it, and then paste it into the address bar of your File Manager).
  6. Copy the new script into that folder.
  7. The quickest option to update the script list in the Scripting window is to click Choose… button and re-select the path of the folder containing the scripts. The new script will appear in the script list displayed on the left pane.

Script window

To use a script:

  1. Click Tools > Scripting
  2. Select the script you want to run in the list on the left. The top horizontal pane contains the text of the script, while the bottom horizontal pane displays messages printed during and after script execution.
  3. If needed, set some parameters in the script's code (e.g., in the "Search and Replace" script you must specify strings to search for and to replace with).
  4. Click on the Run button to run the script.

Where to find OmegaT scripts?

A good number of OmegaT script is automatically installed during the installation of OmegaT. So for most common operations you may not need to download and install anything extra.
A wonderful 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

Assigning a shortcut to a script

OmegaT allows you to assign keyboard shortcuts to scripts to invoke them quickly from the main window without the need to open the Tools > Scripting screen.

To assign shortcuts to scripts:

  1. Click Tools > Scripting…
  2. The Scripting screen appears.
  3. In the list on the left select the script you want to assign a keyboard shortcut to.
  4. In the lower part of the window, right click on one of the numbered buttons.
  5. Select the option Add script. The selected number will be bracketed by two angle brackets (e.g. <3>). 

Keyboard shortcut for executing a script

From now on, the selected script can be invoked by pressing CTRL+SHIFT+ Fn, where n is the selected number. In the example showed the shortcut it is CTRL+SHIFT+F3.

(Print version)

dasmi Wednesday 14 May 2014 - 06:57 am | | Translator tools

two comments

One or more comments are waiting for approval by an editor.

(optional field)
(optional field)

Comment moderation is enabled on this site. This means that your comment will not be visible until it has been approved by an editor.

Remember personal info?
Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.