v138 · miscellaneous

Language Detector API

A JavaScript API for detecting the language of text, with confidence levels.

concepts

  1. Language Detect

    On-device language detector. Runs in the same model family as Summarizer/Translator/Prompt; no network round-trip, no privacy export.

  2. Confidence ranking

    The API returns ranked candidates with confidence scores. Set a threshold and fall back to “unknown” rather than mislabel a 20-character snippet.

  3. Detect-then-translate pipeline

    The canonical combo with Translator: inbox of mixed-language messages, per-message detection with confidence threshold, only translate above-threshold messages into the reader's locale. Per-pair translator sessions cached. Counts skipped vs translated.

  4. Multilingual inbox

    An email inbox with messages in Spanish, French, Japanese, Arabic, Hindi, and English. Click a message or "Detect all" to run on-device language detection — ranked confidence breakdown shown per message. Compose new text and detect its language instantly, all without a server round-trip.

why it shipped

An important supplement to translation is language detection. This can be combined with translation, e.g. taking user input in an unknown language and translating it to a specific target language. Browsers today often already have langauge detection capabilities, and we want to offer them to web developers through a JavaScript API, supplementing the translation API.

references