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