Apertium Android

From Apertium
Jump to navigation Jump to search

The goal of the 'official' Apertium Android app is to provide example code on how to integrate Apertium offline translation into an Android app. It requires a minimum set of permissions that enable developers to showcase and test their work from a phone.



The current version can be downloaded here. The source code is available at http://apertium.svn.sourceforge.net/viewvc/apertium/trunk/apertium-mobile/apertium-android/.

Ideas for further improvements:


Stuff can go in the 'basic Apertium app' if 1) it doesent require scary permissions and 2) it doesent make the app harder to understand as example code on how to integrate Apertium offline translation into other apps.


Developers: Integrating Apertium into your own Android app

Here are the recommended places to store stuff. We recommend that you use the ApertiumInstallation utility class included in the demo app.

    File packagesDir = new File(getFilesDir(), "packages"); // where packages' data are installed
    File bytecodeDir = new File(getFilesDir(), "bytecode"); // where packages' bytecode are installed. Must be private
    File bytecodeCacheDir = new File(getCacheDir(), "bytecodecache"); // where bytecode cache is kept. Must be private
    IOUtils.cacheDir = new File(getCacheDir(), "apertium-index-cache"); // where cached transducerindexes are kept
    ai = new ApertiumInstallation(packagesDir, bytecodeDir, bytecodeCacheDir);
    ai.rescanForPackages();


And then use apertiumInstallation.installJar(tmpjarfilelocation, pkg); to install pairs.

To do a translation, use

	String mode = ai.titleToMode.get(currentModeTitle);
	String pkg = ai.modeToPackage.get(mode);
	Translator.setBase(ai.getBasedirForPackage(pkg), ai.getClassLoaderForPackage(pkg));
	Translator.setMode(mode);


And lastly.... Translator.translate() to translate :-)


Apertium extended

Apertium extended Android app would be a full-feature app with:

  • a cool Android 4 interface using loads of cool visual libraries
  • OCR,
  • SMS translation,
  • TTS, STT
  • and a zillion of scary permissions (internet + read SMS + read SD card should scare you off unless you really trust the source of the app).
  • option to use online translation API(s?)
  • mind reading?

History