v157 · concept 1 · basic

Availability & expected languages

LanguageDetector.availability() is the cheap first call a phone page makes. It never downloads, needs no tap, and works before you know anything about the text. Passing expectedInputLanguages asks a sharper question: can the model on this device detect these languages? This page sends both versions and shows the raw value each one returned.

ask about specific languages

Try ja-Latn (romanised Japanese, supported), kl (not in Chromium's list), or not a tag! (invalid).

No check run yet.

one call per language

Some languages are supported and some aren't, so a single unavailable for a list doesn't tell you which one caused it. This sweep calls availability() once for each tag in the box above, then once more with the whole list.

Per-language availability on this device
expectedInputLanguagesRaw valueWhat it means
Not checked yet.

what the four values mean on a phone

Languages Chromium accepts in expectedInputLanguages

Copied from kSupportedLanguages in third_party/blink/renderer/modules/ai/on_device_translation/language_detector.cc. A tag outside this list makes availability() return unavailable and create() reject with NotSupportedError (“Language not available”). Chromium matches by best fit, so en-GB resolves to en.

the code

if (!("LanguageDetector" in self)) { /* not exposed: old build, insecure context, other browser */ }
const any = await LanguageDetector.availability();
const mine = await LanguageDetector.availability({
  expectedInputLanguages: navigator.languages, // validated as BCP 47 first: bad tags throw RangeError
});
// "unavailable" here can mean "one of these languages isn't supported". Ask per language to find out which.

see also