v130 · miscellaneous
Language Detector API
A JavaScript API for detecting the language of text, with confidence levels.
concepts
-
Language Detect
On-device
LanguageDetector.detect()with ranked confidence output. Falls back to a character-script heuristic when the API is missing. -
Detect → translate pipeline
The motivation by name: pipe detection straight into the Translator API. Three-step pipeline (input → detect → translate) wired up end-to-end on-device, with a target-language picker.
-
Confidence budget tuner
The product question every team faces: where should the confidence threshold be? Six representative inputs (long paragraph, single word, code-switch, transliteration, emoji, short non-English sentence), three product strategies (auto-translate, suggest-only, two-tier), one slider. See exactly which inputs each strategy translates, asks about, or silently skips at any threshold.
-
Multi-Language Sampler
Detect multiple text samples in parallel. Add your own samples or use presets spanning English, French, Spanish, German, Japanese, Russian. Shows top language, confidence %, and alternative candidates for each.
-
Language Router
Route incoming support messages to the right team by detected language — entirely on-device. Paste any message, click Route, and watch it land in the English, French, Spanish, German, Japanese or multilingual queue based on detected language and a configurable confidence threshold.
-
Batch Classifier
Classify a list of product reviews or text snippets in one pass. A single
LanguageDetectorinstance is created once and reused across all items — results stream in row-by-row as each detection completes. Add your own snippets and inspect the per-item language code and confidence score.
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.