项目文件夹

文件
caorushizi b782329ae2 feat(extension): add i18n with system/zh/en language toggle
The MediaGo extension shipped Chinese-only (50+ hardcoded strings across
popup, options, background). Wire up i18next + react-i18next so the UI
follows the browser language by default and lets the user override to
zh / en in a new LanguageCard on the options page.

- `ExtensionSettings.language: "system" | "zh" | "en"` (default system),
  persisted via existing `chrome.storage.local`
- `resolveLanguage()` maps system -> `chrome.i18n.getUILanguage()` or
  navigator.language with a zh/en fallback
- Bootstrap one i18next instance per page (popup / options), subscribe
  to `chrome.storage.onChanged` so switching on one surface updates the
  other without a reload
- Background service worker emits `LocalizedMessage` descriptors
  (`{ key, values? }`) for toast copy; popup calls `t(key, values)` so
  the SW never has to carry an i18n instance
- Full zh/en coverage for popup, options, error paths
- Chrome-native `_locales/{en,zh_CN}/messages.json` + `__MSG_*__` for
  `manifest.name` / `description` / `action.default_title` so the
  chrome://extensions row and toolbar tooltip follow the browser UI
  language (independent dimension from the in-UI toggle, by design)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-21 11:16:03 +08:00

43 行
1.2 KiB
JSON

{
"name": "@mediago/extension",
"private": true,
"version": "0.1.0",
"type": "module",
"description": "Browser extension that sniffs downloadable video resources and sends them to a MediaGo server (Desktop or Docker).",
"scripts": {
"dev": "vite",
"build": "vite build",
"lint": "oxlint .",
"type:check": "tsc --noEmit"
},
"dependencies": {
"@fontsource-variable/geist": "^5.2.6",
"@fontsource-variable/jetbrains-mono": "^5.2.6",
"@fontsource-variable/source-serif-4": "^5.2.6",
"@mediago/shared-common": "workspace:*",
"@radix-ui/react-label": "^2.1.7",
"@radix-ui/react-slot": "^1.2.3",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"i18next": "^25.6.0",
"lucide-react": "^0.548.0",
"react": "^19.2.4",
"react-dom": "^19.2.4",
"react-i18next": "^16.0.1",
"sonner": "^1.7.4",
"tailwind-merge": "^3.3.1"
},
"devDependencies": {
"@crxjs/vite-plugin": "^2.2.0",
"@tailwindcss/vite": "^4.1.14",
"@types/chrome": "^0.1.26",
"@types/react": "^19.2.14",
"@types/react-dom": "^19.2.2",
"@vitejs/plugin-react": "^6.0.1",
"tailwindcss": "^4.1.14",
"tw-animate-css": "^1.4.0",
"typescript": "^6.0.2",
"vite": "^8.0.3"
}
}