v148 · AI · demo
Language Sniffer
Type or paste text below. The on-device LanguageDetector returns a ranked list of candidate languages with confidence scores — no network request required.
Language candidates
Waiting for input…
// Check availability
const available = await LanguageDetector.availability({
expectedInputLanguages: ['en', 'fr', 'de', 'es', 'ja', 'zh', 'ar', 'pt']
});
// → 'available' | 'downloadable' | 'downloading' | 'unavailable'
// Create a detector
const detector = await LanguageDetector.create({
expectedInputLanguages: ['en', 'fr', 'de', 'es', 'ja', 'zh', 'ar', 'pt'],
monitor(m) {
m.addEventListener('downloadprogress', e => {
console.log(`Language model download: ${Math.round(e.loaded * 100)}%`);
});
}
});
// Detect language(s)
const results = await detector.detect('Bonjour, comment allez-vous?');
// Returns: [
// { detectedLanguage: 'fr', confidence: 0.97 },
// { detectedLanguage: 'it', confidence: 0.02 },
// ...
// ]
see also
- Multilingual Sorter — sort sentences by detected language
- Back to feature index
- Translator and Language Detector APIs spec
- ChromeStatus entry
implementation reference
Need the exact API surface, compatibility boundaries, errors, lifecycle, and source links? Read the matching gendn reference ↗