Skip to content

dangerLT/firefox-translator

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Translator

An Android translator app that performs text and image translation completely offline using on-device models.

Supports automatic language detection and transliteration for non-latin scripts. There's also a built-in word dictionary.

Get it on F-Droid

How It Works

Complete offline translation - download language packs once, translate forever without internet.

Language packs contain the full translation models, translation happens on your device, no requests are sent to external servers.

Screenshots

Tech

  • Translation models are firefox-translations-models
  • OCR models are Tesseract
  • Automatic language detection is done via cld2
  • Dictionary is based on data from Wiktionary, exported by Kaikki
    • For Japanese specifically, there's a second "word dictionary" (Mecab) for transliterating Kanji

This app also offers an API to other apps (check ITranslationService.aidl), so that they can request translations to be performed for them.

Manual offline setup

If you want to use this app on a device with no internet access, you can put the language files on Documents/dev.davidv.translator. Check OFFLINE_SETUP.md for details.

Running on x86-64 emulator

This app works fine on aarch64, and it "works" on x86-64 -- in quotes because it currently requires AVX2, which is not available on the standard emulator, nor in the ABI.

You can be cheeky and run a VM with a good CPU configuration like this

cd $ANDROID_SDK/emulator
export LD_LIBRARY_PATH=$PWD/lib64:$PWD/lib64/qt/lib
$ANDROID_SDK/emulator/qemu/linux-x86_64/qemu-system-x86_64 -netdelay none -netspeed full -avd Medium_Phone_API_35 -qt-hide-window -grpc-use-token -idle-grpc-timeout 300 -qemu -cpu max
# The important bit is
# `-qemu -cpu max`

If you don't do this, you will just get a SIGILL when trying to load the library.

Building

bash build.sh

will trigger a build in a docker container, matching the CI environment.

Releasing

  • Bump app/build.gradle.kts versionName and versionCode
  • Create a changelog in fastlane/metadata/android/en-US/changelogs as ${versionCode}.txt
  • Create a tag that is v${versionName} (eg: v0.1.0)
  • Create a Github release named v${versionName} (eg: v0.1.0)
    • Upload the signed APK to the release

Signing APK

bash sign-apk.sh keystore.jks keystorepass pass alias

will sign the file built by build.sh (app/build/outputs/apk/aarch64/release/app-aarch64-release-unsigned.apk) and place the signed copy, with version number, in signed/

Verification info

SHA-256 hash of signing certificate: 2B:38:06:E7:45:D8:09:01:8A:51:BE:58:D0:63:5F:FC:74:CC:97:33:43:94:07:AB:1E:D0:42:4A:4D:B3:E1:FB

Funding

This project was funded through the NGI Mobifree Fund, a fund established by NLnet.

About

Use Firefox Translation Models for on-device translation on Android

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Kotlin 82.5%
  • Python 6.0%
  • Rust 6.0%
  • C++ 2.4%
  • CMake 1.5%
  • Shell 0.7%
  • Other 0.9%