Merging and Splitting Segments in #OmegaT without editing segmentation rules.

One of the complains OmegaT gets is impossibility to split and merge segments without editing projects’ or global segmentation rules.  There were a few attempts to address the issue, but they required a third-party utility that would edit segmentation.conf. One of the most recent attempt was Dimitry Prihodko’s Merge utility. If I understood it right, Dimitry asked Yu Tang to rework his thingy, and Yu Tang came up with a Groovy script that did all the merging using only OmegaT internals. It wasn’t limited to any OS or dependent on other tools (so much for hard Pascal coding, Dimitry). There was only a minor issue that the script couldn’t be used to split segments. And that’s what I’ve added and what I’m sharing here.

The script and its .properties (only English and Russian so far) can be downloaded from

The script works only with the project specific segmentation. When the script is invoked, it will try to split the current segment or merge it with the next. It will try to split the segment when there’s a selection in the current source that goes from the split point up to the end of the segment (right before the segment marker). If anything else is selected, even in the current source, it will be ignored and the merge with the next segment will be attempted.

So, in order to merge just run the script, and it will try to put the current and the next segments together. If a segment needs to be split, activate it, select the part that needs to become the next segment (till the very end), and run the script.

The script will show a confirm message with the perspective merge/split result, so it could be canceled. It will also prompt to reload the project, and that prompt was added because there might be a situation when several rules need to be added, and reloading after each of them would be a waste of time.

Of course, the script isn’t too universal, and if one joined two segments together and later wanted to split them, the chances are it won’t work as the added rules will clash. Or there might be a rule somewhere that is simply wider than the one just added, so the desired split or merge wouldn’t actually occur. And therefore from time to time one might need to call up Project properties and get their hands dirty with the rules.

All the credits go to Yu Tang for cool Groovy coding and Dimitry Prihodko for the idea and hard pushing. Any further help and/or comments are very welcome. If any of native English speakers wanted to edit the .properties (somewhat hastily put together, sorry), that would be really awesome.

But as of now,
Good luck


6 thoughts on “Merging and Splitting Segments in #OmegaT without editing segmentation rules.

  1. Very good job Kos, Dimitry and Yu Tang!

    I tried the script on a test project and it works correctly. I will use for real projects and see how it works.

    As for the properties file, I noticed an error in the English version:

    wrongSelected=Selection in not at the end of the segment, trying to merge…
    must be
    wrongSelected=Selection is not at the end of the segment, trying to merge…

    Now OmegaT is a complete CAT!

      • The script no longer works with the version 4.0.1:
        The script “C:\Program Files (x86)\OmegaT\scripts\merge_split.groovy” is running…
        An error occurred
        javax.script.ScriptException: javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.escapeNonRegex() is applicable for argument types: (java.lang.String) values:

  2. hello,
    I have tried the newest version 0.4.11 in my Omegat 3.6.0_3 in Linux. I think it used to work for me. Now when I run the script it tells me “Nothing to merge! Terminating now!”. Please help.
    thank you

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s