Conversation
Internationalize all three UI layers — manifest (name/description), the
settings page, and content-script injected UI (buttons, popovers, tooltips) —
with English and Simplified Chinese catalogs under _locales.
Because chrome.i18n is locked to the browser UI locale, t() resolves against
bundled catalogs and a stored preference instead, enabling an in-extension
language picker (Follow browser / English / 简体中文) in the settings page.
The choice persists in chrome.storage.local; content scripts pick it up on the
next navigation. "Follow browser" maps the UI locale to a catalog (zh* → zh_CN,
else en), satisfying the "default by system language" TODO.
- src/lib/i18n.ts: bundled catalogs, t()/localizePage()/initLocale()/setLocale()
- src/_locales/{en,zh_CN}/messages.json: 98 keys, full parity
- build.mjs copies src/_locales → dist/_locales for manifest __MSG__ resolution
- tsconfig: resolveJsonModule for the bundled JSON imports
- src/lib/i18n.test.ts: covers locale switching, placeholder substitution, DOM localization
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add a third catalog with Taiwan vocabulary (設定/檔案/儲存庫/核准/權杖…), a "繁體中文" entry in the language picker, and Traditional-vs-Simplified auto-detection (zh-TW/HK/MO or Hant → zh_TW, other zh → zh_CN). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds full internationalization across all three UI layers, plus an in-extension language switcher in the settings page. Languages: English, Simplified Chinese (zh_CN), Traditional Chinese (zh_TW).
name/description/ toolbar tooltip via__MSG_*__+default_locale: en.Why a custom resolver instead of
chrome.i18nchrome.i18n.getMessageis locked to the browser UI locale and can't be overridden at runtime. To support a manual picker,t()resolves against bundled catalogs + a preference stored inchrome.storage.local:Follow browsermaps the UI locale to a catalog:zh-TW/HK/MOorHant→zh_TW; otherzh*→zh_CN; elseen— satisfies the TODO "默认语言根据系统语言".chrome.storage.local; settings page re-localizes in place; content scripts pick it up on the next navigation.Notes
src/_localesso esbuild bundles them andtscaccepts them (resolveJsonModule);build.mjscopies them todist/_localesfor the manifest's__MSG__resolution.chrome://extensionsname/description still follow the browser locale (manifest__MSG__is resolved by Chrome, not overridable in-app).Verification
pnpm typecheckcleanpnpm test— 188/188 (addedsrc/lib/i18n.test.ts: en/zh_CN/zh_TW switching, placeholder substitution, DOM localization)pnpm build— bundles all catalogs;dist/_locales/{en,zh_CN,zh_TW}present🤖 Generated with Claude Code