docs: 更新文档和配置,移除未使用的权限和过时描述

This commit is contained in:
雨霖铃
2026-06-07 09:30:42 +08:00
parent 86870864a9
commit 3f73adc015
4 changed files with 65 additions and 70 deletions
+42
View File
@@ -0,0 +1,42 @@
# i18n 开发指南
## 概述
项目使用 Chrome 扩展标准的 `chrome.i18n` API 进行本地化,通过 `src/utils/chromeI18n.ts` 提供类型安全的 React Hook 包装。
## 配置
- **翻译文件**: `public/_locales/{zh_CN,en}/messages.json`Chrome 扩展标准格式)
- **默认语言**: `zh_CN`(在 `wxt.config.ts``manifest.default_locale` 中配置)
## 使用方式
```typescript
import { useI18n } from '@/utils/chromeI18n';
```
## 翻译键格式
- **直接 key**: `t('dashboard_title')` → 查找 `dashboard_title`
- **命名空间格式(兼容旧用法)**: `t('common:buttons.search')` → 查找 `common_buttons_search`
- **带命名空间参数**: `useI18n(['common', 'features'])`,会自动尝试 `common_key``features_key`
## 占位符支持
```typescript
t('router_notFoundDescription', { entryPointType: 'popup' });
```
## Hook 返回值
```typescript
{ t, i18n: { language, changeLanguage }, isLoaded }
```
## 回退策略
当翻译 key 未命中时,返回 key 本身(开发模式下在控制台记录 warning)
## 限制
`chrome.i18n` 无法动态切换语言,语言跟随浏览器设置,切换后需刷新页面