v148 · AI · demo

Translate Chain

Watch a sentence hop through five languages and back. Each step uses a separate Translator instance — the output of one becomes the input of the next — all on-device.

Checking Translator API…
// Chain: en → fr → ja → de → es → en
const chain = [
  { from: 'en', to: 'fr' },
  { from: 'fr', to: 'ja' },
  { from: 'ja', to: 'de' },
  { from: 'de', to: 'es' },
  { from: 'es', to: 'en' },
];

let text = 'The quick brown fox jumps over the lazy dog.';
for (const { from, to } of chain) {
  const t = await Translator.create({
    sourceLanguage: from,
    targetLanguage: to,
  });
  text = await t.translate(text);
  console.log(`[${from}→${to}]`, text);
}

see also

implementation reference

Need the exact API surface, compatibility boundaries, errors, lifecycle, and source links? Read the matching gendn reference ↗