demo · v138
Batch translator
Eight UI strings translated in one pass using a single Translator session. Reusing the session avoids the model-loading overhead on every call. Watch the strings resolve one by one and measure total time. Falls back to a simulated translation if the API is absent.
checking support…
One Translator session is created, then reused for all 8 strings. Session creation pays the model-load cost once; each subsequent translate() call costs only inference.
0
translated
8
total strings
—
total ms
—
ms / string
| # | Source (English) | Translation | Status |
|---|
the code
const strings = ['Add to cart', 'Sign in', /* ... */];
// Create ONE session — pays model-load cost once
const translator = await Translator.create({
sourceLanguage: 'en',
targetLanguage: 'es',
});
// Reuse session for all strings — only inference cost each time
const results = await Promise.all(
strings.map((s) => translator.translate(s))
);
translator.destroy(); // release model memory
see also
- Translator API — feature index
- ChromeStatus entry
- Chrome Translator API docs