LanguageDetector: expectedInputLanguages property
Experimental:This is anexperimental technology
Check theBrowser compatibility table carefully before using this in production.
Secure context: This feature is available only insecure contexts (HTTPS), in some or allsupporting browsers.
TheexpectedInputLanguages read-only property of theLanguageDetector interface returns the expected languages to be detected in the input text. Specifying expected input languages helps improve the accuracy of the language detection.
ALanguageDetector instance'sexpectedInputLanguages are set when creating it via acreate() call.
In this article
Value
An array of strings specifying the expected input languages. These will be validBCP 47 language tags.
Examples
js
const detector = await LanguageDetector.create({ expectedInputLanguages: ["en-US", "zh"],});// Logs ["en-US", "zh"]console.log(detector.expectedInputLanguages);Specifications
| Specification |
|---|
| Translator and Language Detector APIs> # dom-languagedetector-expectedinputlanguages> |