Using scripts in OmegaT (a quick guide)

A quick and easy introduction to the OmegaT scripts:

  1. OmegaT comes bundled with several scripts. Some of them are of little practical use as they are included as examples for users who want to write their own scripts.
  2. The bundled scripts are located in the scripts subfolder of the folder where OmegaT is installed. Often the installation is done in a location where a regular user doesn’t have write permissions, which means that adding and removing scripts can be complicated.
  3. Luckily, OmegaT allows you to specify an arbitrary location for scripts. Do it! It can be any location where you can write to. It doesn’t matter if it contains no scripts at the moment: you can add only the ones you need, and only when you need them.
    It makes sense to place the scripts folder in the OmegaT config folder (the folder where OmegaT stores its settings) just for convenience.

    But of course it can be any other folder.
  4. Copy the scripts you need into the folder that was set up for scripts.
    If you’re downloading from GitHub, you may need to view the desired script in raw format, and then save the page. If it saves as filename.groovy.txt, just remove the .txt part. If the file was saved in your Downloads folder, just move it to the folder set up for your scripts.
  5. In OmegaT, open Tools → Scripting, in the newly opened Scripting window, select the script you need (left part of the window) and press Run (lower left corner).
  6. If you need to run a script often, you can assign shortcuts to up to 12 scripts:
    • Select the script you want to run with a shortcut.
    • Right-click on one of the 12 buttons at the bottom of the Scripting window.
    • Select “Add Script”.
  7. The script thus installed is available in the Tools menu, or can be run by pressing Ctrl+Shift+Fn (Fn is a function key at the top of the keyboard, n is a number between 1 and 12, and the number on the button in the Scripting window corresponds to the number on the function key).

Select Source Text in OmegaT (update)

In my previous post, I shared a small script that selects the current source text in OmegaT. When OmegaT 5.8/6 is released, that script is not going to be needed: this function has been included in the program itself.

Enjoy!

Select Source Text in OmegaT

There might be a number of situations when the whole text of the current segment’s source is needed for something other than translation itself: performing concordance or web search, writing a translation note in another application, asking your client or project manager about the text, etc.

Currently, in OmegaT it can be achieved in several fairly easy ways:

  • Selecting the text with the mouse (but who wants to do that?)
  • Inserting the source text into the target area (Ctrl+Shift+I or Ctrl+Shift+R) and selecting the text there
  • Unlocking the text caret with F2, and then using arrow buttons and Shift to select the text
    (If you want to have the caret unlocked by default when you start OmegaT, there’s a way to do it)

All that is fine, but it would be much nicer to have a simple shortcut to select that source text, similar to what Ctrl+A does (which in OmegaT Editor selects everything only in the target field, or the complete textual contents of other panes if the got focus). I’ve written a simple script that does just that, and though scripts can be bound only to Ctrl+Shift+F[1-12] keys, it’s better than not having a shortcut at all. Hopefully, this function might appear in OmegaT itself, but before it happened, here you have it:
Get it from SF.net
Get it from GitHub

To learn how to install and use OmegaT scripts, see this quick guide.

Happy selecting!

Jumping between segments in OmegaT

Going to the segment you need is quite easy in OmegaT (in most cases, but when it’s not, there is the wonderful scripting functionality).

Continue reading

Compact glossary layout updated

As announced previously, an alternative glossary pane layout was made available as a plugin. The newest update (v.1.1.0) now includes 4 variants of that compact layout:

  • 1A
    • source: target [comment] | target [comment] | [comment] (separator | is styled as normal text — the same as in the original version)
  • 1B
    • source: target [comment] | target [comment] | [comment] (separator | is styled as target terms)
  • 2A
    • source: target (comment), target (comment), (comment) (separator , is styled as normal text)
  • 2B
    • source: target (comment), target (comment), (comment) (separator , is styled as target terms)

Once again, here’s the project itself, and here is where you can download the compiled version. If you run OmegaT on Java8, make sure to download the right build. On Java11 it doesn’t matter which build is used.

Comments, bug reports, complains, latest gossips and donations are always welcome.

Take care and good luck!

Export #OmegaT Project to Excel (UPDATE)

The earlier version of this script was described in this article. Here I’m announcing the update to the script which makes it possible to include:

  • Segment ID for each segment (applicable only for some file types)
  • Translator’s ID of the segment’s translation creator
  • Translator’s ID of the segment’s translation editor
  • Segment notes
  • Visual marks to show segments’ uniqueness or repetitions (grayish background, marks 1 or + in the dedicated column: for the first occurrence, or further instances of the repeated segment, respectfully)
  • Visual marks for alternative translations (different font color, mark a with a different background in the dedicated column)
  • Visual marks for untranslated segments (mark NT in the dedicated column)
  • Visual marks for paragraph boundaries (upper border over the source and target text which visually groups the text belonging to the same paragraph)

All of the above features are optional, though they are on by default. To disable or change them, editing the script is required, but all those lines are very easy to understand, they have comments, and are placed almost in the very beginning of the script:

Scripting window with the script options in focus

Unlike the earlier version, the script produces the tabular output:

Segment #Source TextTarget TextUniq/AlSegment IDCreatorChangerNote

The script can be downloaded from
SF.net repository
GitHub repository

To learn how to install and use OmegaT scripts, see this quick guide.

Comments, suggestions, complaints, and donations are always welcome!

Happy spreadsheeting!

Export OmegaT project to an HTML table

A few years ago I wrote a script that exported the whole OmegaT to an HTML table. I used it a lot myself, and I know quite a few other people found it helpful too. The problem with the table produced by that script was that it had no way to show repeated or alternatively translated segments. I’ve rewritten the script since, but never published an announcement about that new version. Now I did a few more changes, and thought that it’s about time to fix that omission.

Continue reading

Alternative OmegaT Glossary Layout

It has been possible for quite some time now to choose which Glossary pane layout to use in OmegaT. Selection isn’t that great, only two layouts are provided: Default and Dictionary. But at the same time this feature had been introduced, it became possible to add custom layouts via plugins. I haven’t seen any, but the possibility is there. And just recently, Hiroshi Miura, a very prolific OmegaT developer, published a plugin skeleton just for this purpose. I used what he generously shared, and made an alternative compact layout for the Glossary pane.

It puts target terms right after the source term on the same line, and separates them only by a vertical bar and spaces. If there’s a comment for the term, it follows it immediately enclosed in square brackets. If OmegaT is set up to merge multiple target definitions for the same source term, and there are duplicated entries (i.e. two or more identical target terms for the same source term) with different comments, the comments will be separated by the vertical bar, but the term itself won’t be repeated.

To enable this layout in OmegaT, download the plugin (the ready-to-use jar is in the Releases section), put it into plugins subfolder in your OmegaT config folder, restart OmegaT, and select it under PreferencesGlossaryGlossary layout: → Compact Glossary Layout

Happy translating!

A [slightly more] sane initial OmegaT setup. Part I

Over the years of my daily use of OmegaT (I started using it back in 2009), I helped quite a few translators to make their first steps with the program. The funny thing is that almost every time a new person tries to learn the program, we change some of the same defaults to make it more usable and comfortable. So I thought it might be a good idea to collect those few initial setup changes here as a small series of posts so that anyone could refer to them at any point.

The first thing I always have new users change is the Editor behavior.

Continue reading

OmegaT Live preview (based on LibreOffice)

Below you’ll find a quick and dirty live preview solution for OmegaT on GNU/Linux.

In order for it to work, you’ll need any command line converter to convert your target files to PDF, and any PDF viewer to view the converted file. In the solution provided here Zathura PDF viewer is used. It is a very lightweight, keyboard-driven (albeit with vi-like keybindings) application that can invert document colors using a custom color scheme, and, most importantly, it reloads documents as they are changed, but keeps the previously open position, which makes it ideal for live previewing. Target files are converted using LibreOffice since I had it installed anyway; but any other command line tool that converts to PDF would do.

Continue reading