LanguageDetector: expectedInputLanguages property
MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونهکد
{{APIRef("Translator and Language Detector APIs")}}{{SeeCompatTable}}{{securecontext_header}}
The **expectedInputLanguages** read-only property of the {{domxref("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 {{domxref("LanguageDetector.create_static", "create()")}} call.
Value
An array of strings specifying the expected input languages. These will be valid {{glossary("BCP 47 language tag", "BCP 47 language tags")}}.
Examples
js
const detector = await LanguageDetector.create({
expectedInputLanguages: ["en-US", "zh"],
});
// Logs ["en-US", "zh"]
console.log(detector.expectedInputLanguages);Specifications
{{Specifications}}
Browser compatibility
{{Compat}}
See also
- Using the Translator and Language Detector APIs