Auto-translate app text prioritizing Local Cache and on-device ML Kit (local server), then Gemini API, with fallback to the Free Google API.
- Prioritize on-device translation via a built-in local server using Google ML Kit.
- Added translation support for android.text.StaticLayout$Builder to reduce UI jank by replacing text synchronously when possible.
- LSPosed or another Xposed Framework variant must be installed and enabled.
- Install the downloaded APK from the link above.
- Open the LSPosed Manager app, navigate to Modules, and enable XPTranslateText.
- Select the apps you want to translate from the module settings in LSPosed.
- Open the XPTranslateText app, enable the "Local Translation Server" switch, and choose your source/target languages.
- Kill your app and restart it.
After restart, the selected apps should display translated text automatically.
-
android.widget.TextView & Custom Components:
- Automatically translates text set via the
setText()method. - Translation pipeline:
- Local Translation Cache (memory + SQLite) to avoid repeated work.
- Local ML Kit Server (on-device, 127.0.0.1:18181) with short timeouts to keep UI responsive.
- Gemini API (gemini-2.0-flash-lite) as network fallback.
- Free Google API as the final fallback.
- Automatically translates text set via the
-
android.text.StaticLayout$Builder:
- Intercepts
StaticLayout.Builder.build()and attempts a synchronous replacement when translations are readily available (cache/DB) or quickly obtained from the local ML Kit server. - If not immediately available, it returns the original layout and prefetches translations asynchronously for subsequent renders.
- Spans and formatting are preserved.
- Intercepts
-
android.webkit.WebView:
- Performs real-time translation of visible webpage text via a JS bridge.
- Pipeline: Local ML Kit Server β Gemini API β Free Google API (no caching for WebView).
- Tested and confirmed working on:
- Android 13 with LSPosed (v1.9.2-it(7024))
- Android 15 with LSPosed (v1.9.2-it(7024))
- Android 16 with LSPosed (v1.9.2-it(7412))
| Before | After |
|---|---|
![]() |
![]() |
XPTranslateText/
βββ app/
β βββ key.jks # Generated by GitHub Actions
β βββ build.gradle
βββ gradlew
βββ gradlew.bat
βββ keystore.properties # Local-only, not committed
βββ settings.gradle
- Runs as a foreground service on
127.0.0.1:18181. - Endpoint:
/translate?src=xx&dst=yy&q=...src=autoenables automatic language detection (ML Kit Language ID).
- Models are downloaded on-demand and kept on-device; last-used times are tracked to help with maintenance.


