Translator and Language Detector APIs
The expectedInputLanguages read-only property of the LanguageDetector interface returns the expected languages to be detected in the input text. Specifying expected input languages helps improve the accuracy of the language detection.
A LanguageDetector instance's expectedInputLanguages are set when creating it via a LanguageDetector.create_static call.
Value
An array of strings specifying the expected input languages. These will be valid BCP 47 language tag.
Examples
const detector = await LanguageDetector.create({
expectedInputLanguages: ["en-US", "zh"],
});
// Logs ["en-US", "zh"]
console.log(detector.expectedInputLanguages);
Specifications
Browser compatibility
See also
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
