Difference between revisions of "Apertium Android"

From Apertium
Jump to navigation Jump to search
(12 intermediate revisions by 4 users not shown)
Line 1: Line 1:
  +
{{TOCD}}
This is about the current Apertium Android
 
   
 
The goal of the 'official' Apertium Android app is to provide example code on how to integrate Apertium offline translation into an Android app.
For historical versions, please see
 
   
  +
It requires internet permission to enable users to download language pairs (and developers to showcase their work from a phone).
* [[Apertium Android 2009 project by Enrique Benimeli]]
 
* [[Apertium On Mobile GSOC 2012 project by Arink Verma]]
 
   
  +
If you want a more fully-featured app, try [[Mitzuli]].
   
== Apertium basic offline translator ==
 
   
  +
<gallery>
The goal of the 'official' Apertium Android app is to provide example code on how to integrate Apertium offline translation into an Android app.
 
  +
Image:Device-2012-08-07-051235.png|Main screen
It requires a minimum of permissions that enable developers to showcase and test their work from a phone.
 
  +
</gallery>
   
   
The current version can be downloaded [https://play.google.com/store/apps/details?id=org.apertium.android here]
+
The current version can be downloaded [https://play.google.com/store/apps/details?id=org.apertium.android here].
  +
The source code is available at http://apertium.svn.sourceforge.net/viewvc/apertium/trunk/apertium-mobile/apertium-android/
+
The source code is available at https://github.com/apertium/apertium-android.
   
 
Ideas for further improvements:
 
Ideas for further improvements:
Line 20: Line 21:
 
* theme/colors doesent provide correct visual feedback (you can't see if you press buttons)
 
* theme/colors doesent provide correct visual feedback (you can't see if you press buttons)
 
* language detection - for example using https://code.google.com/p/language-detection/
 
* language detection - for example using https://code.google.com/p/language-detection/
* factor unused stuff into 'Apertium extended' app
+
* factor unused stuff from Arink's original work into 'Apertium extended' app
   
   
 
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.
 
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.
  +
  +
<pre>
  +
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();
  +
</pre>
  +
  +
  +
And then use apertiumInstallation.installJar(tmpjarfilelocation, pkg); to install pairs.
  +
  +
To do a translation, use
  +
<pre>
  +
String mode = ai.titleToMode.get(currentModeTitle);
  +
String pkg = ai.modeToPackage.get(mode);
  +
Translator.setBase(ai.getBasedirForPackage(pkg), ai.getClassLoaderForPackage(pkg));
  +
Translator.setMode(mode);
  +
</pre>
  +
  +
  +
And lastly.... Translator.translate() to translate :-)
  +
   
   
Line 29: Line 60:
   
 
Apertium extended Android app would be a full-feature app with:
 
Apertium extended Android app would be a full-feature app with:
  +
* store pairs in SD card (requires permission to read SD card)
 
  +
* load pairs from SD card (for example experimental pairs or pairs not hosted in Apertium regi)
 
* a cool Android 4 interface using loads of cool visual libraries
 
* a cool Android 4 interface using loads of cool visual libraries
 
* OCR,
 
* OCR,
Line 35: Line 67:
 
* TTS, STT
 
* 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).
 
* 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 ==
  +
  +
* GSOC 2012 [[User:Arinkverma/Apertium on mobile]]
  +
* Decemter 2012 Enhancements WRT memory, see https://sourceforge.net/mailarchive/message.php?msg_id=30266147
  +
  +
  +
  +
[[Category:User interfaces]]
  +
[[Category:Mobile]]
  +
[[Category:Android]]

Revision as of 05:56, 10 May 2018

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 internet permission to enable users to download language pairs (and developers to showcase their work from a phone).

If you want a more fully-featured app, try Mitzuli.



The current version can be downloaded here.

The source code is available at https://github.com/apertium/apertium-android.

Ideas for further improvements:

  • theme/colors doesent provide correct visual feedback (you can't see if you press buttons)
  • language detection - for example using https://code.google.com/p/language-detection/
  • factor unused stuff from Arink's original work into 'Apertium extended' app


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:

  • store pairs in SD card (requires permission to read SD card)
  • load pairs from SD card (for example experimental pairs or pairs not hosted in Apertium regi)
  • 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