demo · v130
detect → translate pipeline
The chromestatus motivation pairs the Language Detector with the Translator API by name: "taking user input in an unknown language and translating it to a specific target language". This demo wires the two together — type or paste text, the on-device detector identifies the source, and the on-device translator emits a translation in your chosen target.
requires the Built-in AI APIs
Enable
chrome://flags/#language-detection-api and chrome://flags/#translation-api (or join the Built-in AI origin trial). If either API is missing, the page falls back to a character-script heuristic for detection and skips the translation step gracefully.
try a sample
1. user input
→
2. detect (LanguageDetector)
…
→
3. translate (Translator)
the code
const input = "Bonjour, j'aimerais commander un café.";
// 1. Detect (Chrome 130 ships LanguageDetector to stable).
const detector = await LanguageDetector.create();
const ranked = await detector.detect(input);
const source = ranked[0].detectedLanguage; // "fr" with confidence ~0.99
// 2. Translate (Translator API is the sister proposal — same explainer).
const translator = await Translator.create({
sourceLanguage: source,
targetLanguage: "en",
});
const output = await translator.translate(input);
// "Hello, I would like to order a coffee."