Merge and split segments in OmegaT (update)

OmegaT script for merging and splitting segments has gotten a few improvements:

  • It can show the text to be split or merged with or without tags
  • If tags are to be shown, they can be formatted with a different font color and size to make the actual text more readable
  • If a split is attempted while text cursor is inside a tag, the script won’t add a rule and will inform the user about it
  • The preview of the split or merge to be performed now has horizontal borders to make it easier to see the possible result

So, these are the options that can be configured by the user:

enforceProjectSRX   = true   //if true, the script will make sure project-specific segmentation is enabled
separateMappingRule = true   //if true, the script will add a separate group for its rules
showTags            = true   //if false, tags won't be shown in the confirmation message
paintTags           = true   //if true, tags will be shown in different font size and color
tagColor            = "gray" //tag color
tagSize             = 1      //tag size

Comments in those lines should make it pretty clear what option does what. To change an option, go to Tools → Scripting…, then in the list of scripts, select Merge or split segments. In the text area on the right part of the screen, scroll down a bit (to about line 30), find the option you want to change, edit it, press Ctrl+S to save, and run the script.

The script is available on GitHub and FS.net

If you need more info about installing and using OmegaT scripts, see this quick guide.

If you find this script useful, leave a comment.

There’s also a very easy way to say thank you.
Your support will make more scripts like this possible.

Happy merging and splitting!

Scripts in OmegaT (quick guide)

A quick and easy intro to 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 willing to write their own scripts.
  2. The bundled scripts are located in 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 adding and removing scripts can be complicated.
  3. Luckily, OmegaT permits setting an arbitrary location for scripts. Do that! 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 as you need them.
    It makes sense to place the scripts folder into the OmegaT config folder (the folder where OmegaT stores its settings) just for convenience.

    But it can, of course, be any other folder.
  4. Copy the scripts you need to the folder that was set for scripts.
    If you’re downloading from GitHub, you might need to show 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 got saved in your Downloads folder, just move it into the folder set for your scripts.
  5. In OmegaT, open Tools → Scripting, in the newly open Scripting window select the script you need (left part of the window) and hit Run (lower left corner).
  6. If you need to run a script quite often, there is a way to 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 in the lower part of the Scripting window
    Select “Add Script”
  7. The script thus installed is available under Tools, or can be run by pressing Control+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

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!

Unlock Text Caret on #OmegaT Startup

As many have probably noticed, in OmegaT it’s now possible to unlock cursor. This means that one can select and copy text anywhere in the Editor pane without using the mouse. With the unlocked cursor you simply press up or down, and the text caret will move beyond the target segment. The lock is triggered with F2. Cool! But there’s no way to make this behavior default — every time OmegaT is started, cursor is locked.

Since I prefer it to be unlocked most of the time, here’s a little workaround. Below is a little script that needs to go into scripts_folder/application_startup/:

def gui() {
    editor.editor.lockCursorToInputArea = false
    editor.editor.updateLockInsertMessage()
}
return

This little snippet should be saved as a plaintext file with extension groovy, for instance, unlock.groovy. Next time OmegaT 4.2 or newer is started, the cursor is going to be unlocked from the get-go!

Zip current #OmegaT project

Here is a script that packs the current OmegaT project into a zip-file in the same location as the project folder.

Since the script doesn’t exclude anything, it might be a good idea to use another script to remove target and backup files.

Big kudos to cApStAn sprl for sponsoring the script for zipping.

 

#OmegaT Segment Status in Notes

OmegaT is just an excellent translation tool, but there’s still some room for improvement when it comes to using it for revising translated materials. I really hope that in future what I’m about to present in this post will become completely obsolete, but for now it might be welcomed by people who needed to mark segments with different status markers.

A big shout-out goes to Marc Prior for coming up with the idea and backing up the development.

Continue reading

Clear #OmegaT volatile and backup files

OmegaT has a great safety feature: it automatically backs up project memory files (i. e. project_save.tmx) on every project (re)load, plus it creates another backup file on every save (if the project was changed since the last load or save). Those backup files can be used in an extremely rare case when something happens to the main project memory and all of the work seems to be lost. It happened to me once when I was only starting to use OmegaT as my main tool, and was I glad this backup feature was thought of!

But this very feature can become a tiny problem, especially in ongoing projects where project_save.tmx keeps on growing bigger and bigger. While creating backups is great and very helpful, there’s no routine to remove old backup files. It isn’t uncommon in some of the projects that I work at that project_save.tmx is a few MB’s, but omegat folder where that file is located, is over 100 MB’s or more, and only because of all the backups. With modern disk sizes it’s not a big deal, and it doesn’t degrade OmegaT’s performance a bit, but sometimes there’s a need to make a project slim again (like when you’re going to send it to your colleague or client, or copy it to cloud storage or another computer, or you’re obsessed with keeping everything trim and slim and tidy).

240px-broom_icon-svg

So, anyway, after all these numerous words here’s what I’m getting at. At Sourceforge.net (download link) there’s this script that removes all the backups of project_save.tmx (including the ones created in team projects before performing sync), everything in target folder (as usually in the projects that need this cleaning, source files are changed, but old target files sometimes just keep on piling up), and also three TMX files created in the root of the project every time target files are produced.
About a year ago I put together the original version of this script, but this new version downloadable from Sourceforge.net contains a few improvements and can easily be localised if you care to be warned about file deletion in your language.

Use it to your heart’s content and your own risk, and I’ll be very thankful for any questions, suggestions or comments.

DISCLAIMER: If you lose your work without any hope to recover because all backups have been deleted by this script, it ain’t my fault. You should backup regularly and not hope that OmegaT will do it for you.


But as of now,
Good luck!