v148 · AI APIs · Language Detection
Content Router
Route content to language-appropriate handlers using LanguageDetector.detect(). Type or paste text — the on-device model identifies the language and routes the content to the matching locale handler, with confidence scores and fallback logic.
Checking Language Detector API…
Try sample texts
Detection result
—
No text detected yet
Confidence
—
↓
Routed to:
Awaiting detection…
Routing table
| Language | BCP 47 | Handler |
|---|
Detection + routing code
const detector = await LanguageDetector.create({
expectedInputLanguages: ['en', 'es', 'fr', 'de', 'ja', 'zh', 'ar', 'pt', 'ru']
});
async function routeContent(text) {
const results = await detector.detect(text);
const { detectedLanguage, confidence } = results[0];
// Route to appropriate handler
const handler = routingTable[detectedLanguage]
?? routingTable[detectedLanguage.split('-')[0]]
?? fallbackHandler;
await handler(text, confidence);
}
references
implementation reference
Need the exact API surface, compatibility boundaries, errors, lifecycle, and source links? Read the matching gendn reference ↗