LanguageDetector: expectedInputLanguages property
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
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 create() call.
Value
An array of strings specifying the expected input languages. These will be valid BCP 47 language tags.
Examples
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 |
Browser compatibility
| desktop | mobile | server | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
expectedInputLanguages property
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
- Experimental. Expect behavior to change in the future.
- See implementation notes.