MDN self-hosted library · e01.org

Translator: targetLanguage property

Translator and Language Detector APIs

Open notebook · 1 cells web-api-instance-property upstream source

Translator and Language Detector APIs

The targetLanguage read-only property of the Translator interface returns the language that the input text will be translated into.

A Translator instance's targetLanguage is set when creating it via a create() call.

Value

A string specifying the source language. This will be a valid BCP 47 language tag.

Examples

const translator = await Translator.create({
  sourceLanguage: "en",
  targetLanguage: "ja",
});

// Logs "ja"
console.log(translator.targetLanguage);

Specifications

Browser compatibility

See also