demo · v130
Multi-Language Sampler
The Language Detector API (Chrome 130, Origin Trial) can detect the language of any text. This demo runs detection on multiple text samples in parallel and shows the top language, confidence score, and alternatives for each. Paste your own text samples or use the presets below.
Checking Language Detector API availability…
// Chrome 130 (Origin Trial): Language Detector API
const detector = await translation.createLanguageDetector();
// Detect a single text
const results = await detector.detect('Bonjour le monde');
// → [{ detectedLanguage: 'fr', confidence: 0.99 }, …]
// Detect multiple texts concurrently
const texts = ['Hello', 'Hola', 'Bonjour', 'こんにちは'];
const allResults = await Promise.all(
texts.map(text => detector.detect(text))
);
// Each returns array sorted by confidence (highest first)
// With confidence threshold
const topResult = results.find(r => r.confidence > 0.5);
console.log(topResult?.detectedLanguage); // 'fr'