v148 · AI · JavaScript
Language Pair Explorer
The Translator API requires you to check availability for a specific source→target language pair before creating a translator. Translator.availability() returns available (model already on device), downloadable (pair is supported but the language pack must download, and Translator.create() then requires a user gesture), downloading (a download is already in flight), or unavailable. This explorer checks any pair and shows a matrix of common language combinations.
Check a specific pair
Common pairs matrix (click any cell to check)
available (on device)
downloadable / downloading
unavailable
not checked · ! = API not present
// The same options object goes to availability() and create()
const options = { sourceLanguage: 'en', targetLanguage: 'fr' };
const availability = await Translator.availability(options);
// 'available' | 'downloadable' | 'downloading' | 'unavailable'
if (availability === 'unavailable') {
console.warn('Pair or device not supported — run your fallback');
} else if (availability === 'available') {
const translator = await Translator.create(options);
console.log(await translator.translate('Hello, world!'));
} else {
// 'downloadable' / 'downloading': create() needs a USER GESTURE,
// otherwise it rejects with NotAllowedError.
btn.addEventListener('click', async () => {
const translator = await Translator.create({
...options,
monitor(m) {
m.addEventListener('downloadprogress', (e) => {
console.log(`${Math.round(e.loaded * 100)}%`);
});
},
});
console.log(await translator.translate('Hello, world!'));
});
}
see also
- Live Translator — translate text in real time
- Translate Chain — multi-step translation
- Batch Translator — batch text processing
- Document Translator — full-document translation
references
implementation reference
Need the exact API surface, compatibility boundaries, errors, lifecycle, and source links? Read the matching gendn reference ↗