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

UPDATE (December 2022): This post below might be interesting only for historical reasons, but even that is highly doubtful. The updated solution to the merge and split problem is published here.

One of the complaints OmegaT gets is the 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 attempts was Dimitry Prihodko’s Merge utility (don’t bother to download it, it won’t work as expected, just read on). 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 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 confirmation 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 native English speakers wanted to edit the .properties (somewhat hastily put together, sorry), that would be really awesome.

But as of now,
Good luck

13 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!

  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

  3. Hello Kos, first of all, thanks so much for the script. I installed a couple of days ago and it worked flawlessly on the first document I tried but today, as I had to use it on a different document, even though the confirmation dialogue appears and shows the correct merging segments and I confirm that I want to reopen/refresh the file, the segments do not get merged! In other words, nothing happens! Very weird! Do you have any idea of what might be happening and how to “fix it”? The segmentation settings are set to “project specific”. Thanks so much!

    • Hi Marco,
      If there’s a hard break or a tab between the text presented in OmegaT as two segments, there’s nothing you can do with or without this script to merge them into one, except editing the source file. If it’s a line break, and the source file is .docx, there’s a file filter option to segment on line breaks or present them as tags, but you need to be careful with this option, as it applies either globally or to the whole project, not to the current segment or current file.

      If it’s not the things described above, I’ll need to see what you’re trying to merge, and, possibly, your segmentation.conf

      • Thank you so much for your quick and helpful response. I had three instances where I wanted to merge the segments within the same document and the plugin worked in one of them but not the other two so it probably has to do with the possible issues you mentioned. I will check the source file and report back. Thank you so much! Best regards!

      • AWESOME!!! It was exactly as you described. The segments that were not being merged had line breaks in them! (duh! 🙂 ) I did fix the source file, clicked on “Reload” and then “re-copied” the source files. It worked perfectly! Thanks again! Awesome plug in and support!!!! Best regards!

  4. Pingback: #OmegaT Merge/Split script updated | Translator's Recipes
  5. I got an error, something like “can’t run project segmentation rules!”, here’s how to deal with that: “This script works only if project-specific segmentation is enabled (Project → Properties… → Segmentation… → ☑Make the segmentation rules project specific).” as per

    The steps for me, a noob in OmegaT scripting, were:
    1. Download and install 7zip (open source software)
    2. Download from the specific link to Source Forge (2nd paragraph of this page’s post)
    3. Using 7zip, extract the .tar.bz2 file into ‘C:\Program Files\OmegaT\scripts’ or your script folder (check it on Tools > Scripting > File > Access Scripts folder). You can also right-click the .tar.bz2 file and choose “Extract…”
    4. On OmegaT, go to Tools > Scripting and find “Merge and split segments” from the list on the left, then click on Run.

    So thanks a million for making this available and congrats on making it to #1 on google for “omegat merge segments”! lol

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 )

Connecting to %s