HowTo: Adding a preview function to OmegaT


Most modern CAT tools display the text in segment-oriented form rather than with its ultimate layout and formatting. Although this has many advantages, it can be very useful for the translator to be able to see the ultimate layout and formatting whilst translating. For this reason, many CAT tools provide a preview function that shows the layout and formatting without the translator having to create the final document and open it in a separate application (usually a word processor). OmegaT does not have an integral preview function, but it is possible to provide much the same functionality using additional software. This HowTo describes the general principles for setting up a preview function.


Ideally, a viewer should do two things:


If you are translating .html files, a convenient solution is to use a browser with an automatic refresh function to provide a ready-made preview function. Examples of browsers with an automatic refresh function:

You may prefer not to use your usual browser for the preview function so as to keep it free for Internet browsing rather than having constantly to switch tabs, so you can regard installing an additional browser for the preview function as an advantage.

After selecting and installing a suitable browser (and/or the required add-on), open your translated file in the /target folder of your project:

Now enable automatic refreshing. In both Firefox and Opera, this can be done by right-clicking in the translated .html file you have opened, then Reload every > select a desired interval (e.g. 5 seconds).

You now have a preview function. To update the display, you must still save and create your target document in OmegaT with Ctrl+s, Ctrl+d. The change will then become visible after a delay of at most the interval you selected (plus the time taken by OmegaT to save and produce the target files). Your browser won't automatically scroll as you work through the text; you have to do that yourself. But it will at least stay at the same point in the text when the view is updated.

Previewing word-processing files

Opening your translated target file in a browser is easy when your source file is in .html format, but translations more often involve word-processing files, which in OmegaT are usually handled in .docx or .odt format. You can still use the browser solution described above to preview the translations of these files, but you will then also need a) a converter to convert the file to .html format, and b) a utility to launch the converter automatically so that you don't have to convert the files manually.

Two programs that can be used as converters are described here: Abiword and LibreOffice.

Abiword and LibreOffice are a word processor and an office suite respectively. Both are free, available for a number of different platforms, and can convert .docx and .odt files to .html format.

Abiword is a relatively small download and is very fast in use. It has a command-line function for converting .docx and .odt files to .html format. It is very easy for Linux users and fairly easy for Windows users to install. Download Abiword here.

LibreOffice is a fully featured office suite similar to Microsoft Office. It can also be used to convert .docx and .odt files to .html format, but to do so from the command line, it also requires Unoconv, a plug-in. Download LibreOffice here; download the Unoconv plug-in here.

Once you have installed either Abiword or the LibreOffice+Unoconv combination, you can convert the target files produced by OmegaT to html format in order for them to be read by the browser. Remember that you will first have to save in OmegaT and produce the translated documents, then launch the conversion utility, then wait for the display to be updated in the browser.

There are numerous ways of achiving this, but one practical solution is to use a script which "listens" for changes in the translated file(s) produced by OmegaT and then, when a change is detected, automatically launches the utility which converts the file(s) to html format in order for them to be read by the browser. A schematic diagram is shown below:


An example script that achieves this function is described in the Priorview Howto.

Copyright Marc Prior 2012