v151 · javascript · covered on mdn
LanguageDetector support for Traditional vs. Simplified Chinese
Detection results that previously reported bare "zh" for Chinese may now distinguish the scripts: "zh-Hans" (Simplified) and "zh-Hant" (Traditional) — chosen from the characters in the detected input text, not from any requested locale. Any code comparing detectedLanguage === "zh" may silently stop matching.
this feature is documented on MDN
MDN's reference covers the API in full — the interface and its members, create() and detect() with examples showing the detectedLanguage + confidence result structure, specifications, and browser compatibility. gendn doesn't duplicate that here; this page only records the Chrome 151 output-value change and its migration, which MDN does not yet cover (checked 2026-07-26; MDN page last modified 2025-10-28).
the Chrome 151 change
| What changed | Detection results that previously returned "zh" for Chinese text may now return "zh-Hans" or "zh-Hant", decided per detection from the input text's characters. detect() takes text — there is no requested-locale or region mapping. |
|---|---|
| How the script is decided | Chromium's ChineseScriptClassifier counts characters unique to each script (two UnicodeSets, one per script); the majority wins. Ties and all-common text default to zh-Hans; behavior is undefined for non-Chinese input (documented in chinese_script_classifier.h). Input is truncated (first 500 bytes, whitespace removed) before counting. |
| Direct proof | WPT detector.optional.https.window.js (pinned at 1985b47) — Simplified text (这是一个例句。) detects to zh-Hans, Traditional text (這是一個例句。) to zh-Hant |
| Migration | result.detectedLanguage === "zh" may never be true from 151 — match the language arc instead: tag === "zh" || tag.startsWith("zh-"). No deprecation shim; results change at 151. |
| Confidence | Remains model-defined and paired with the tag in the same result dictionary; the sources do not define it as a measure of script certainty. |
| Boundary | Chromium's Translate path runs the same classifier but converts its result to the legacy codes zh-CN/zh-TW for that API (language_detection_util.cc) — that is not the LanguageDetector output. Blink's supported-code list recognizes zh, zh-Hans, zh-Hant, and zh-Latn as input-side codes. |
| Chrome status | Chrome 151 — Enabled by default (milestone listing); feature detail (ChromeStatus API record, updated 2026-07-09): desktop + Android + WebView 151, status text “Proposed”; no flag, no trial program; tracking: crbug.com/519251262 |
| Compatibility | Interim, from ChromeStatus (BCD's api/LanguageDetector.json covers the general API at Chrome 138 but has no zh-variant entries): Chrome 151; Edge not separately reported; Firefox Opposed (recorded signal); Safari No signal; web developers Strongly positive |
| MDN | LanguageDetector (full API reference; no zh-variant coverage as of 2026-07-26) |
| ChromeStatus | 5138651886518272 — LanguageDetector support for Traditional vs. Simplified Chinese |
| Interactive demo | Chrome Platform Showcase — LanguageDetector zh variants |