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 .
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
- Go to the Yu Tang GitHub page: https://gist.github.com/yu-tang/a6833d687e436ddd5135#file-activate_source_text-groovy.
- Click on the Raw button to see a text only version of the script.
- Save this page on your computer (CTRL+S in most browsers). Usually it will be saved with this name: activate_source_text.groovy.txt.
- Remove the .txt extension.
- Copy the activate_source_text.groovy file in the script path of your installation of OmegaT and assign a shortcut to the script.
- For details on how to install a script see my post on Importing OmegaT scripts.
How to Use the Script
- Activate the script. If you have assigned a shortcut to it (recommended), you can do it quickly through the shortcut.
- Open an OmegaT project and go to the segment for which you want to activate the source.
- 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.).
- 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
The following procedure allows to leverage this script to add terms to the glossary on-the-fly:
- Select the target term in the target segment.
- Press F2 to activate the source segment.
- Select the source term in the source segment.
- Press CTRL+SHIFT+G to open the Add Term window. OmegaT insterts the source and target term automatically.
- Insert a comment in the appropriate field (if necessary).
- 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: