OmegaT Scripts: a Script for Activating the Source Segment

This post describes how to use a small script that allows, using a keyboard key, to put the cursor in the source text of an active segment of the OmegaT editor. The script was created by the script guru Yu Tang .

(Print version)

[Leggi questo articolo in italiano]

I find this script very useful for 3 frequent tasks:

  • If you want to select a part of the source segment without using the mouse and look for it in TM through the Find window (CTRL+F).
  • When you need to copy a part of the source segment and paste it in the target and do not want to use the mouse for this operation.
  • When you have to insert a new term in the glossary and do not want to use the mouse for selecting the source term.

How to Install the Script

  1. Go to the Yu Tang GitHub pagehttps://gist.github.com/yu-tang/a6833d687e436ddd5135#file-activate_source_text-groovy.
  2. Click on the Raw button to see a text only version of the script.
  3. Save this page on your computer (CTRL+S in most browsers). Usually it will be saved with this name: activate_source_text.groovy.txt
  4. Remove the .txt extension.
  5. Copy the activate_source_text.groovy file in the script path of your installation of OmegaT and assign a shortcut to the script.
  6. For details on how to install a script see my post on Importing OmegaT scripts.

How to Use the Script

  1. Activate the script. If you have assigned a shortcut to it (recommended), you can do it quickly through the shortcut.
  2. Open an OmegaT project and go to the segment for which you want to activate the source.
  3. Press F2. The cursor will be moved to the source text. You can now do all the selection and searching operations you want (select a string to search in TM, select a term to add through CTRL+SHIFT+G etc.).
  4. If you  press F2 again, the cursor will go back to the target segment and, if you had selected something in the source, the selected text will be inserted automatically in the target segment.

Note on Fake Source Editing

When you put the cursor on the source text you'll discover that you can also edit it. This editing is not real! You are not changing anything on the source text. When you press F2 again and return to the target text, any change made to the source text is lost. The only way to edit a source file is to open it directly in the source folder using the appropriate software!

Inserting Glossary Terms On-the-fly

Inserting glossary terms on the fly

The following procedure allows to leverage this script to add terms to the glossary on-the-fly:

  1. Select the target term in the target segment.
  2. Press F2 to activate the source segment.
  3. Select the source term in the source segment.
  4. Press CTRL+SHIFT+G to open the Add Term window. OmegaT insterts the source and target term automatically.
  5. Insert a comment in the appropriate field (if necessary).
  6. Press OK to save the added terms to the glossary.



PS (for Linux users): on some Linux versions pressing the F2 button open a small dialog with a wide and disturbing border (requiring the resizing of the small window). To solve this issue, you have to change a line in the script. To edit the script, open it with a suitable editor (one with line numbers, e.g. Geany) and go to line 147. Line 147 should read:

dialog.rootPane.setWindowDecorationStyle JRootPane.NONE

dasmi Saturday 16 January 2016 - 06:31 am | | Translator tools

four comments

Giang

As I activated this script I got an error: activate_source_text >> This script is not available before OmegaT 4.

Need help!

Giang, - 15-04-’17 07:40

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.