v161 · built-in ai · android
Translator API on Android
Chrome for Android 161 exposes the Translator API, so a mobile web app can translate text with an on-device model, without sending it to a cloud endpoint. It's the same API as on desktop. The phone is what changes: the language pack has to be downloaded over a connection that may be metered, the translation service shares a phone's memory, and an admin can switch the whole thing off with the TranslatorAPIAllowed policy. These demos make those differences visible, and none of them ever downloads a model unless you tap a button that says it will.
Running these demos. On Chrome 161+ for Android, and on Chrome desktop 138+, Translator is on by default. On an older Android build, launch Chrome with --enable-features=TranslationAPI (or --enable-blink-features=TranslationAPI). There's no chrome://flags entry. --enable-experimental-web-platform-features does not turn it on, because the feature isn't marked experimental. A managed device can also disable it with the TranslatorAPIAllowed policy. Every page reports the value the browser actually returned.
concepts
-
Availability states on this device
The basic call. Pick a language pair and read the raw
Translator.availability()result:available,downloadable,downloadingorunavailable. For each one the page says what a mobile app should do next. It also shows whydownloadablecan be a privacy mask, and checks the companionLanguageDetectorthat shipped on Android in 157. -
Download on a constrained device
An inspection tool that reads the real signals a phone page has:
navigator.connection(including Save-Data),deviceMemory,storage.estimate()andonLine. It combines them with availability to decide whether to translate now, ask first, or wait for Wi-Fi. The download itself needs your tap, with a<progress>bar fed bydownloadprogress, plus cancel and retry. -
Memory & input limits
Android-only limits from the Chromium source: each
translate()call is capped at 256 KiB of UTF-8, and going over throwsQuotaExceededError, whileinputQuotastill reports Infinity. An idle language pair (about 80 MiB) is unloaded after a minute. Includes a byte-accurate chunk planner and a timer for the slower first call after an idle unload. -
Failure & policy gates
Every way
create()refuses, each run for real and none of them downloading anything: no user gesture (NotAllowedError), an iframe denied byallow="translator 'none'", a bad language tag (RangeError), an unsupported pair (NotSupportedError) and an aborted signal (AbortError). Also shows what theTranslatorAPIAllowedenterprise policy looks like from inside a page. -
Offline chat composer
A practical example: a phone-first support chat where your message is language-detected with
LanguageDetectorand translated withTranslatorbefore it leaves the device. The composer is sticky and keeps clear of the safe area, Enter is IME-safe, and the offline state is shown. If the model isn't on the device, the message is sent clearly labelled as untranslated. There's no fake translation.
what is different on Android (from the Chromium source)
Parameter on kTranslationAPI | Android | Desktop | What a page sees |
|---|---|---|---|
TranslationAPIMaxInputSizeBytes | 256 KiB (262,144 bytes) per call | 0 (no cap) | translate() rejects with QuotaExceededError (requested, quota); inputQuota is still Infinity |
TranslationAPIModelIdleUnloadTimeout | 1 minute | never | the first call after a minute idle reloads about 79–84 MiB per language pair, so it takes longer |
Runtime flag TranslationAPI | default-on from 161 | stable since 138 | typeof Translator |
TranslatorAPIAllowed policy | supported from 161 | supported | every pair is unavailable; create() throws NotSupportedError and logs the console warning “The translation is disallowed by policy.” |
the API
// 1. Ask, never assume. This call does not download anything.
const state = await Translator.availability({ sourceLanguage: "es", targetLanguage: "en" });
// "available" | "downloadable" | "downloading" | "unavailable"
// 2. Only inside a tap: create() may start a language-pack download.
button.onclick = async () => {
const ac = new AbortController();
const translator = await Translator.create({
sourceLanguage: "es", targetLanguage: "en", signal: ac.signal,
monitor(m) { m.addEventListener("downloadprogress", (e) => progress.value = e.loaded); },
});
// 3. On Android, keep each call under 256 KiB of UTF-8.
out.textContent = await translator.translate(text);
};
why it shipped
The motivation on ChromeStatus is local translation for mobile web apps: low latency and offline support, pairing with the Language Detector API shipped on Chrome for Android in M157.
Page text stays on the device, and translation keeps working on a bad connection once the language pack is installed. Making the TranslatorAPIAllowed policy work on Android means managed fleets can turn off both the API and its model downloads. Firefox's position is negative and Safari has given no signal, so treat the API as progressive enhancement on every platform.
references
- ChromeStatus entry: Translator API on Android (5106126157905920)
- Spec: Translator and Language Detector APIs
- Writing Assistance APIs: shared model availability, download and privacy infrastructure
- Explainer (webmachinelearning/translation-api)
- Chrome docs: Translation with built-in AI
- TranslatorAPIAllowed enterprise policy
- crbug.com/428227642: Android launch tracking
- Chromium: components/on_device_translation/features.cc (Android limits)
- ChromeStatus: Translator API (desktop, 5172811302961152)