convertor/docs/i18n.md
Your Name 53b83b425f feat: rebrand to ConvertX-CN, fix TypeScript error, add docs
- Fix TypeScript TS2345 error in i18n/service.ts by parsing cookie from header
- Rebrand all ConvertX references to ConvertX-CN
- Change default language from en to zh-TW
- Fix footer to always display English 'Powered by ConvertX-CN'
- Update GitHub links to pi-docket/ConvertX-CN
- Add /docs folder with documentation:
  - getting-started.md
  - configuration.md
  - converters.md
  - i18n.md
- Update all locale files with new branding
2026-01-20 10:29:17 +08:00

89 lines
1.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 多語言支援i18n
ConvertX-CN 支援多種語言的使用者介面。
## 支援語言
| 語言代碼 | 語言名稱 |
| -------- | ---------------- |
| zh-TW | 繁體中文(預設) |
| zh-CN | 简体中文 |
| en | English |
| ja | 日本語 |
| ko | 한국어 |
## 語言切換
1. 在網站右上角的導航列可看到語言選擇器(圖示)
2. 點擊後選擇偏好語言
3. 語言偏好會自動保存到 Cookie 中
4. 下次訪問時會記住您的偏好
## 自動偵測
首次訪問時,系統會根據瀏覽器的語言設定自動選擇最適合的語言。
優先順序:
1. Cookie 中儲存的語言偏好
2. 瀏覽器的 `Accept-Language` 標頭
3. 預設語言(繁體中文)
## 新增語言
如要添加新語言支援,請按以下步驟:
### 1. 建立翻譯檔案
`src/locales/` 目錄新增語言檔案,例如 `fr.json`(法文):
```json
{
"common": {
"appName": "ConvertX-CN",
"poweredBy": "Propulsé par",
...
},
"nav": {
"history": "Historique",
...
}
}
```
### 2. 註冊語言
`src/i18n/index.ts` 中:
```typescript
// 導入新語言檔案
import fr from "../locales/fr.json";
// 在 supportedLocales 陣列中添加
export const supportedLocales: LocaleConfig[] = [
// ... 現有語言
{ code: "fr", name: "French", nativeName: "Français" },
];
// 在 translations 物件中註冊
const translations: Record<SupportedLocale, TranslationData> = {
// ... 現有翻譯
fr: fr as TranslationData,
};
```
### 3. 更新類型定義
`SupportedLocale` 類型中添加新語言代碼:
```typescript
export type SupportedLocale = "zh-TW" | "zh-CN" | "en" | "ja" | "ko" | "fr";
```
## 貢獻翻譯
歡迎提交 Pull Request 來新增或改進翻譯!請確保:
- 翻譯完整(包含所有 key
- 語法正確
- 遵循現有的翻譯風格