docs: translate repository documentation to English (#72)

This commit is contained in:
vin authored and GitHub committed 2026-02-06 22:14:06 +08:00
1 parent 2ae2216f1e
commit 18389b9753
8 files changed
+456 -441

No files matched your search

@@ -1,30 +1,30 @@
# 设计:多语言支持
# Design: Multilingual Support
## 架构
## Architecture
应用使用 `react-i18next` 进行国际化,并配合 `i18next-browser-languagedetector` 进行语言检测。配置集中在 `src/localization/i18n.ts` 中。
The application uses `react-i18next` for i18n and `i18next-browser-languagedetector` for language detection. Configuration is centralized in `src/localization/i18n.ts`.
### 语言资源
### Language Resources
翻译资源将作为 JSON 对象构建在 `i18n.ts` 中(如果太大则分文件)。
我们将在 `resources` 对象中添加 `zh-CN` 键。
Translation resources are built as JSON objects in `i18n.ts` (or split into files if they grow large).
We add a `zh-CN` key in the `resources` object.
### 默认语言策略
### Default Language Strategy
我们将引入 `LanguageDetector` 插件。
`i18n.use(LanguageDetector).init({...})` 将被配置为首先检查 `localStorage`,然后检查 `navigator`(浏览器/系统语言)。
`fallbackLng` 将保持为 `'en'`,作为最后的兜底。
We introduce the `LanguageDetector` plugin.
`i18n.use(LanguageDetector).init({...})` is configured to check `localStorage` first, then `navigator` (browser/system language).
`fallbackLng` remains `'en'` as the final fallback.
### 键映射
### Key Mapping
我们将把现有的英文字符串映射到语义键(例如 `home.title`, `settings.theme`)。
Existing English strings are mapped to semantic keys (for example, `home.title`, `settings.theme`).
## 数据流
## Data Flow
1. 应用启动。
2. `i18next` 初始化,通过 `LanguageDetector` 确定语言:
* 检查 `localStorage` 是否有保存的偏好。
* 如果无,检查 `navigator.language`。
* 如果检测到的语言受支持(`en` 或 `zh-CN`),则使用该语言。
* 否则,使用 `fallbackLng` (`en`)。
3. 组件使用 `useTranslation` hook 根据当前语言获取字符串。
1. App starts.
2. `i18next` initializes and determines language via `LanguageDetector`:
* Check whether `localStorage` has a saved preference.
* If not, check `navigator.language`.
* If detected language is supported (`en` or `zh-CN`), use it.
* Otherwise, use `fallbackLng` (`en`).
3. Components use `useTranslation` to resolve strings for the active language.