You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit cae6bf5
Browse filesBrowse the repository at this point in the historyBrowse files
fix(docs): resolve a browser tag by BCP 47 truncation, one subtag at a time (#223)
normalizeLanguage took two shots at every Accept-Language tag -- the exact tag, then the substring before the first hyphen -- and LANGUAGE_MAPPING held only Chinese and Korean rows. So a browser sending a single region tag with no q-list got English for de-AT, fr-CA, es-MX and ja-JP, and zh-Hant-TW skipped past zh-Hant to zh and landed on Simplified.
resolveSupportedLanguage walks the tag the way RFC 4647 section 3.4 defines lookup: whole tag, drop the last subtag, repeat. Most specific first, because short-to-long would answer Simplified for every Traditional tag carrying a region. The table is consulted at every step and beats truncation where they disagree -- it is an editorial ruling about what a tag means, truncation is the mechanical default -- which is also what lets zh-TW-x-private reach Traditional. Both paths exit through one membership check against i18n.languages, so neither can return a locale the site does not publish.
Six rows truncation now subsumes (zh-CN, zh-SG, zh-Hans, zh-Hant, ko, ko-KR) are removed so the table reads as an exceptions list. A table carrying region rows teaches that region tags belong in it, which is why de-AT was never added and never worked. A differential run over a 167-tag corpus shows pruned and full agree on all 167.
Before column measured against a real rebuild of the pre-fix tree, not read off the source: 66 tags change, all in the card's direction; every regression row unchanged. nan-Hant-TW and yue-HK still reach English -- truncation does not leak a non-Mandarin tag into zh-Hant through its script subtag.
Case-sensitivity of the lookup is unchanged and filed as #220.
Closes#217
0 commit comments