Vanilla JavaScript Projects

Project 06, AI in the browser

Live Translator

Type in one language and read it in another as you go. The input language is detected for you, and you can listen to the translation.

Hello নমস্কার
Runs on
Chrome on-device AI
Model
Chrome translation packs
First download
Per language pair
Your browser
Checking

Translate

Checking for Chrome's on-device translator

Detected: none yet0 / 1000
Ready

Recent

    How it works

    1. Detect the languageLanguageDetector returns likely languages with confidence scores. Without it, the page guesses from the script, such as Bengali or Arabic letters.
    2. Get a translatorTranslator.create() prepares the language pair, downloading it once if needed. Each pair is cached for the session.
    3. Translate on pauseTyping is debounced, so a translation runs half a second after you stop.
    // Which language is this?
    const detector = await LanguageDetector.create();
    const [best] = await detector.detect("Good morning!");
    // { detectedLanguage: "en", confidence: 0.98 }
    
    // Translate English to Bengali on the device
    const ok = await Translator.availability({ sourceLanguage: "en", targetLanguage: "bn" });
    const translator = await Translator.create({ sourceLanguage: "en", targetLanguage: "bn" });
    const text = await translator.translate("Good morning!");