On Device Translator
class OnDeviceTranslator(engine: TranslationEngine, downloadTimeoutMs: Long) : Translator, TranslationAvailability
Translator and TranslationAvailability backed by an on-device TranslationEngine.
Translation never blocks a message: when the language is unknown or unsupported, the model cannot be downloaded in time, or translation fails, the original text is returned with translated = false. The text itself is never logged.
Parameters
download Timeout Ms
how long a missing model may take to download before the original text is sent instead (the download continues to be useful only if the engine keeps it)
Functions
Link copied to clipboard
True if sourceLanguage (or, with null, translation in general) can be translated now.
Link copied to clipboard
open suspend override fun translateToEnglish(text: String, languageHint: String?): TranslationResult