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

  1. Availability states on this device

    The basic call. Pick a language pair and read the raw Translator.availability() result: available, downloadable, downloading or unavailable. For each one the page says what a mobile app should do next. It also shows why downloadable can be a privacy mask, and checks the companion LanguageDetector that shipped on Android in 157.

  2. 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() and onLine. 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 by downloadprogress, plus cancel and retry.

  3. Memory & input limits

    Android-only limits from the Chromium source: each translate() call is capped at 256 KiB of UTF-8, and going over throws QuotaExceededError, while inputQuota still 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.

  4. Failure & policy gates

    Every way create() refuses, each run for real and none of them downloading anything: no user gesture (NotAllowedError), an iframe denied by allow="translator 'none'", a bad language tag (RangeError), an unsupported pair (NotSupportedError) and an aborted signal (AbortError). Also shows what the TranslatorAPIAllowed enterprise policy looks like from inside a page.

  5. Offline chat composer

    A practical example: a phone-first support chat where your message is language-detected with LanguageDetector and translated with Translator before 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 kTranslationAPIAndroidDesktopWhat a page sees
TranslationAPIMaxInputSizeBytes256 KiB (262,144 bytes) per call0 (no cap)translate() rejects with QuotaExceededError (requested, quota); inputQuota is still Infinity
TranslationAPIModelIdleUnloadTimeout1 minuteneverthe first call after a minute idle reloads about 79–84 MiB per language pair, so it takes longer
Runtime flag TranslationAPIdefault-on from 161stable since 138typeof Translator
TranslatorAPIAllowed policysupported from 161supportedevery 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