Howto - Adding a preview function to OmegaT

HowTo: Adding a preview function to OmegaT

Background

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 how a preview function can be set up.

Principles

There are many ways in which a preview function can be created, and this HowTo describes several of them. However, don't expect to be able to achieve this with just a few clicks. Whatever solution you choose, you must follow the instructions carefully and, above all, understand the principles.

Ideally, a viewer should do two things:

1. It should display the text with something approaching the final layout and formatting.
2. It should be updated continually.

Browser

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). In Chrome, hit the Auto Refresh button in the extension section. Note: I have not tested this function in Chrome.

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. 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 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.

Three conversion utilities are described here: Abiword, LibreOffice and Textutil.

Abiword and LibreOffice are a word processor and 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; installing on a Mac is tricker and Mac users may prefer to use an alternative. Download Abiword here.

LibreOffice is a fully-functioned 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.

If you are using Mac OS X, you can use the preinstalled Textutil utility. (Linux users: don't confuse this with the Linux Textutil utility, which is completely unrelated.)

The preview.tcl listener script

Although you could use Abiword or LibreOffice to convert from .docx or .odt to .html, it would be impractical to do so repeatedly during the translation process. A more efficient alternative is to use a script that "listens" for a change in your translated file (i.e. it detects when the file has been updated, which happens when you hit Ctrl+s, Ctrl+d in OmegaT), and then launches the converter which converts the file to .html. A script named preview.tcl is available for this purpose. It is written in the tcl/tk scripting language, and therefore requires tcl/tk to run.

To use preview.tcl:

Windows users: Get tcl/tk here and install it. If you're using Linux or Mac OS X, you probably already have it installed. (Linux users in particular: you need both tcl and tk, not just tcl.)

Everyone: Download preview.zip. Unzip the files and put them anywhere you like (but in the same folder). Open a command prompt/terminal/console and type in:

cd path

where path is the full pathname of the folder in which you placed preview.tcl. Then type in:

wish ui_preview.tcl

All being well, the preview.tcl interface should appear. On this, you can select the name of the target file (in /target in your OmegaT project), the frequency with which the script is to check whether this file has changed, and the file conversion utility that you have installed. When you have selected all those, you can hit the Start button.

preview_ss.png

A European Commission press release (in .odt format) in OmegaT and below it the instantaneous target text displayed in Opera. Bottom right: the preview.tcl utility. The layout shown here is just for the sake of example; you can of course arrange the windows as you like.

Putting it all together

By now you will have realized that to add the preview function, you may have to install and configure quite a lot of new (but thankfully free) software. Depending upon your target file format and your chosen solution, that may be as many as six(!) new pieces of software. Here's an overview:

preview_flow.png

Summary/installation

You need:

Troubleshooting

Assuming that you have installed tcl/tk, preview.tcl, a converter and a suitable browser, if your target file is not being updated when you make changes in the target file, check the following:



Copyright Marc Prior 2012