Skip to content

Add Simplified Chinese to the browser extension - #78

Open
myml wants to merge 2 commits into
oddbit:mainfrom
myml:feat/ext-zh-cn
Open

myml wants to merge 2 commits into
oddbit:mainfrom
myml:feat/ext-zh-cn

Conversation

@myml

@myml myml commented Oct 14, 2026

Copy link
Copy Markdown

What

Follow-up to the review of #71. The admin app gained Simplified Chinese there, and this extension's README promised the admin app's language set, so a browser reporting zh-CN met a Chinese dashboard next to an English popup.

  • src/i18n/zh.ts carries the 69 keys the popup, the form, the error messages and the options page read.
  • zh joins SUPPORTED_LANGUAGES. The table map beside it is typed over that list, so a language registered without a table fails the typecheck rather than resolving to undefined at the first t().
  • The language is the browser's, read by its primary subtag, so zh-CN, zh-SG and zh-Hans all resolve to zh. A script variant the set does not carry, zh-TW or zh-HK, also resolves to zh and reads Simplified: the extension carries one Chinese table and has no picker to choose another. detectLanguage() documents that, and a test pins it as a decision rather than an accident. A Traditional table would have to be matched before the primary subtag is taken, which this does not do.
  • The README no longer enumerates the languages. It points at SUPPORTED_LANGUAGES, which is also where a new locale is registered, so the claim cannot drift from the code.

Tests

  • The parity suites iterate SUPPORTED_LANGUAGES instead of naming id and sv, so this locale and any later one are covered the day they register. The accepts en, id, sv case became every-language acceptance plus an assertion on the exact array, and a new case checks that each table declares its own code in _lang.
  • A new popup case renders with navigator.language set to zh-CN and asserts the Chinese labels, which is the whole path from the browser to the strings on screen. Every other case in that file runs against the en-US pin in tests/setup.ts.
  • Mutating the array to drop zh fails four cases; dropping a placeholder from the zh table fails the placeholder parity case.
  • yarn test: 9 files, 165 tests pass. yarn typecheck: clean. yarn build, scripts/verify-build.mjs: both targets build, 7 referenced files present, 45.1 KB zips.

The Chinese labels are the widest strings the popup and options page carry, so RELEASE.md gains a step that checks them for clipping on those two surfaces before a tag.

myml added 2 commits October 14, 2026 17:22
The admin app gained Simplified Chinese in oddbit#71, and this extension's README
promised the admin app's set, so a browser reporting zh-CN met a Chinese
dashboard beside an English popup. zh.ts carries the 69 keys and joins
SUPPORTED_LANGUAGES, whose table map is typed over the list, so a language
registered without a table fails the typecheck instead of serving undefined.

The language is the browser's, read by its primary subtag, so zh-CN, zh-SG
and zh-Hans all resolve to zh. A script variant the set does not carry,
zh-TW or zh-HK, also resolves to zh and reads Simplified: the extension
carries one Chinese table and has no picker. detectLanguage() now says so,
and a test pins it as a decision rather than an accident.

The parity suites iterate SUPPORTED_LANGUAGES instead of naming id and sv, so
this locale and any later one are covered the day they register, and the
"accepts en, id, sv" case is replaced by every-language acceptance plus an
assertion on the exact array. A new popup case renders with
navigator.language set to zh-CN and asserts the Chinese labels, which is the
whole path from the browser to the strings on screen.

CHANGELOG.md gains the entry under Unreleased, RELEASE.md gains the locale
step and the Chinese clip check on the two narrowest surfaces.
The README enumerated three languages and claimed they mirrored the admin
app, which needed an edit for every locale on either side and read as false
the moment one landed on only one side. It points at SUPPORTED_LANGUAGES
now, which is also where a new locale is registered, and the test summary
line no longer counts the languages it covers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant