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:
- It should display the text with something approaching the final layout and formatting.
- It should be updated continually.
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:
Windows users who are not already using Firefox can download it from www.mozilla.org; most Linux users will already have it installed, or can install it via their distributions' repositories. To add an automatic refresh function to Firefox, install the "ReloadEvery" add-on.
Opera is available for all platforms; it is also very fast and requires low hardware resources. Download it from www.opera.com (or for Linux users: through your distribution's repository). The automatic refresh function is built in.
Chrome is also available for all platforms. Download Chrome from www.google.com/chrome. To add the auto refresh function to Chrome, download and install the Auto Refresh Plus extension from the Web Store.
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:
- Using Firefox: with File > Open File
- Using Opera: with Opera > Page > Open
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