Translations Wanted! Apertium on Ubuntu 14.04 2

Posted by JD 04/14/2015 at 16:00

I was watching a Spanish movie the other day and noticed there wasn’t any English subtitles or audio. My Spanish is poor and it won’t get any better without a little help.

Apertium , the F/LOSS language translation package, to the rescue.

IRC to the Rescue

After screwing around with the packages in the Ubuntu repos, I had to hop onto the #apertium IRC channel to get some help.

Error: Unknown error matching regexp (code -28)
Not very useful. Googling that didn’t help either. I suspected the regex issue was due to incompatible regex libs/tools/script libs on the system, though it has never seen any non-official package before today.

Do not use the Ubuntu repo versions of Apertium.

After a few helpful attempts on IRC that still weren’t clear to me, I’m slow that way, their point became clear.

Wiki Instructions were unclear to me.
What I needed to do simple translations from Spanish to English was to install a nightly package PPA, then install the program and language pack.


wget http://apertium.projectjj.com/apt/install-nightly.sh -O – | sudo bash
sudo aptitude update # the script above did this, but …
sudo aptitude install apertium-en-es apertium
echo “Eso es un test” | apertium es-en
This is a test

Ok – working. Great! Things are easy when you know how.
Note – if you copy/paste the above, be certain to correct the stupid strange characters this blog enters – the wget line needs that. At least it didn’t work correctly here.

Not that apertium es-en “Eso es un test” does not work. It is not a supported mode.

SRT Translation

Next was to translate the SRT for the movie.


apertium es-en movie.es.srt movie.en.srt

Great, that worked all the way to the last line in the SRT. Of course i had tried using google translate before, which screwed with the timestamps and stopped working after 16 min into the movie. Also tried using the CLI interface to google translate – never got that working at all – trs / translate. Need to remove those.

Now, all is good. Of course, machine translations are NOT human translations, so don’t expect it to be conversational quality or grammatically close.

The newer Apertium packages are working their way though Debian and will be released eventually. Seems that Ubuntu PCRE packages are extremely old and break Apertium.

Hope this helps someone else.

A Script

I’ve attached the script used to pull CC1 and CC3 from Spanish TV recordings. It was modified to check for English output, if non-exists, apertium is called to translate the available Spanish SRT file into English SRT.

  1. someguy 04/14/2015 at 22:36

    for someone that’s paranoid about security, im surprised you’re telling people to pipe an unencrypted http shell file straight to sudo..

  2. JD 04/15/2015 at 09:28

    My thought process …

    99% of the people who find this article over the next few years won’t care.

    The people who do, will grab the file, review it (as it is on that instant) and then run it.

    The instructions were provided by the main person of Apertium, so if she/he really wanted to screw over our systems, that could easily be accomplished in the code, not some 20 line shell script.

    Regardless – for the security conscious, review the script BEFORE using it or doing those steps manually.