const translator = await Translator.create({
sourceLanguage: "en",
targetLanguage: "ja",
});
const stream = translator.translateStreaming(myTextString);
let translation = "";
for await (const chunk of stream) {
console.log(chunk);
translation += chunk;
}
console.log("Complete translation:", translation);Translator: translateStreaming() method / notebook
Translator: translateStreaming() method
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.