Translator and Language Detector APIs
The sourceLanguage read-only property of the Translator interface returns the expected language of the input text to be translated.
A Translator instance's sourceLanguage is set when creating it via a Translator.create_static 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 "en"
console.log(translator.sourceLanguage);
Specifications
Browser compatibility
See also
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
