Software Projects

Running the Apertium Translator on Android: Offline Machine Translation on a Mobile Device

Posted in Uncategorized by rmtheis on September 26, 2012

A few days ago I put together an Android app that runs the Apertium open source rule-based translation system.

For his excellent 2012 Google Summer of Code project, Mikel Artexte has converted several of the Apertium language pairs into standalone, self-contained Jar files that have no outside dependencies. The end result is a set of cool little embeddable modules that do real language translation on mobile devices without requiring a network connection at all.

One of the challenges I ran into while making this app was that the default Proguard settings cause the translation system to crash at runtime. To avoid this, I tried a whole bunch of settings and finally found a set of Proguard directives that preserve the Apertium offline translation, avoiding the crashing:

# Preserve Apertium offline translation
-dontwarn java.awt.**
-dontwarn javax.swing.**
-dontwarn org.apertium.ApertiumGUI
-keepattributes InnerClasses
-keep class org.apertium.**
-keepclassmembers class * {
    public *; protected *; private *;

Together, these settings preserve the translation-related classes packaged in the Apertium Jar files, saving them from Proguard’s obfuscation process that leads to crashing. These Proguard settings can be added on top of the default Android Proguard optimizations by adding the following line to the file:


With these settings in place, the translations work correctly, with the optimized translation results being returned after about 5000ms for a short phrase on my phone.

Overall, I’m pleased with the Android offline translation app results, particularly because these translations work without requiring a network connection. Another advantage is that this system can do translations for a few languages that are currently unsupported by Google Translate and Bing Translator.

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 )

Google photo

You are commenting using your Google 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