MessageTranslationService

Service interface for translating chat messages on-device.

Google flavor provides an ML Kit implementation; fdroid/desktop/iOS provide a no-op that returns TranslationResult.Unavailable, which hides the translate action entirely.

Inheritors

Functions

Link copied to clipboard
abstract suspend fun downloadLanguageModels(languageTags: List<String>): DownloadResult

Download the translation models for the given language tags. Only meaningful on google flavor.

Link copied to clipboard
abstract suspend fun isLanguageAvailable(locale: String): Boolean

Check whether translating into the given locale is possible on this platform (model downloadable).

Link copied to clipboard
abstract suspend fun translate(text: String, targetLocale: String): TranslationResult

Translate plain chat text to the target locale, detecting the source language on-device. Never downloads language models — missing models are reported as TranslationResult.ModelDownloadRequired so the UI can ask the user before pulling ~30MB per language.