i18n and UI fix

This commit is contained in:
2026-03-14 23:16:15 +08:00
parent 43289845fc
commit f7ad51b9ec
69 changed files with 5970 additions and 286 deletions

View File

@@ -0,0 +1,23 @@
# i18n Dependencies Installation Evidence
Date: 2026-03-13
## Installed Packages
```
+-- @lobehub/i18n-cli@1.26.1
+-- i18next-browser-languagedetector@8.2.1
+-- i18next@25.8.18
`-- react-i18next@16.5.8
`-- i18next@25.8.18 deduped
```
## Verification Command
```bash
npm ls i18next react-i18next i18next-browser-languagedetector @lobehub/i18n-cli
```
## Status: ✅ COMPLETE
All 4 i18n dependencies installed successfully.

View File

@@ -0,0 +1,84 @@
# Task 03: Locale File Structure - Evidence
## Status: ✅ COMPLETE (Pre-existing)
## Directory Structure Created
```
src/renderer/src/locales/
├── default/
│ ├── common.json (31 keys)
│ ├── domain.json (31 keys)
│ ├── settings.json (24 keys)
│ └── errors.json (20 keys)
├── zh-CN/
│ ├── common.json (31 keys)
│ ├── domain.json (31 keys)
│ ├── settings.json (24 keys)
│ └── errors.json (20 keys)
├── ja-JP/
│ ├── common.json (31 keys)
│ ├── domain.json (31 keys)
│ ├── settings.json (24 keys)
│ └── errors.json (20 keys)
└── en-US/
├── common.json (31 keys)
├── domain.json (31 keys)
├── settings.json (24 keys)
└── errors.json (20 keys)
```
## Verification
- [x] Directories created: default/, zh-CN/, ja-JP/, en-US/
- [x] Files created: common.json, domain.json, settings.json, errors.json
- [x] Each file has >5 translation keys (minimum 20 per file)
- [x] Flat key structure used (no nested objects)
## Sample Content
### common.json (default)
```json
{
"appName": "Kintone Manager",
"save": "保存",
"cancel": "取消",
"delete": "删除",
"edit": "编辑",
...
}
```
### domain.json (default)
```json
{
"title": "域名管理",
"addDomain": "添加域名",
"editDomain": "编辑域名",
...
}
```
### settings.json (default)
```json
{
"title": "设置",
"language": "语言",
"selectLanguage": "选择语言",
...
}
```
### errors.json (default)
```json
{
"networkError": "网络错误",
"invalidDomain": "无效的域名",
"connectionFailed": "连接失败",
...
}
```
## Notes
- Structure was already in place from prior work
- All translations follow flat key structure
- Chinese is the default/source language
- English and Japanese translations provided

View File

@@ -0,0 +1,33 @@
# Task 04: Locale Store - Compilation Evidence
## Date: 2026-03-13
## Files Created
- src/renderer/src/stores/localeStore.ts
## Verification
### TypeScript Check
```bash
npx tsc --noEmit
# Result: PASSED (no errors)
```
### Store Implementation
- Uses Zustand with persist middleware
- Imports LocaleCode and DEFAULT_LOCALE from @shared/types/locale
- Persists only the locale state value (partialize pattern)
- Exports useLocaleStore hook
### State Shape
```typescript
interface LocaleState {
locale: LocaleCode; // "zh-CN" | "ja-JP" | "en-US"
setLocale: (locale: LocaleCode) => void;
}
```
### Default Value
- locale: "zh-CN" (from DEFAULT_LOCALE constant)
## Status: COMPLETED

View File

@@ -0,0 +1 @@
TypeScript compilation: SUCCESS

View File

@@ -0,0 +1,40 @@
# Task 06: Configure @lobehub/i18n-cli
## Completed Actions
1. **Installed @lobehub/i18n-cli@^1.26.1** as dev dependency
2. **Added npm script**: `"i18n": "lobe-i18n"` to package.json
3. **Verified CLI works**: `npm run i18n -- --help` returns usage info
## Existing Configuration (.i18nrc.js)
```javascript
module.exports = {
entry: ['src/renderer/src/locales/default/*.json'],
output: 'src/renderer/src/locales',
entryLocale: 'zh-CN',
outputLocales: ['en-US', 'ja-JP'],
apiKey: process.env.OPENAI_API_KEY || '',
apiModel: 'gpt-4o-mini',
};
```
## CLI Usage
```bash
# Run translation
npm run i18n
# With markdown translation
npm run i18n -- --with-md
# Lint translations
npm run i18n -- --lint
```
## Notes
- Source locale: zh-CN (in `locales/default/`)
- Output locales: en-US, ja-JP
- API key must be set via `OPENAI_API_KEY` environment variable
- Uses gpt-4o-mini model for translation