Files
kintone-customize-manager/.sisyphus/notepads/i18n-integration/issues.md
2026-03-15 12:46:35 +08:00

48 lines
1.3 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.

## [2026-03-14] Locale Not Synced Between Processes
### 问题描述
Renderer process 和 Main process 的 locale 状态没有同步。
### 复现步骤
1. 用户在 UI 中切换语言 (例如从 zh-CN 到 en-US)
2. localeStore 更新 localStoragei18next 切换语言
3. 但是 Main process 的 `config.json` 仍然是旧值
4. Main process 的错误消息使用旧语言
### 根本原因
- `localeStore.setLocale()` 只更新 Zustand state
- 没有调用 `window.api.setLocale()` 同步到 Main process
### 解决方案
需要在以下位置添加同步逻辑:
1. **localeStore.ts**: 修改 `setLocale` action
```typescript
setLocale: async (locale) => {
set({ locale });
await window.api.setLocale({ locale });
}
```
2. **App.tsx**: 在初始化时从 Main process 读取 locale
```typescript
useEffect(() => {
const initLocale = async () => {
const result = await window.api.getLocale();
if (result.success) {
useLocaleStore.getState().setLocale(result.data);
i18n.changeLanguage(result.data);
}
};
initLocale();
}, []);
```
### 影响范围
- `src/renderer/src/stores/localeStore.ts`
- `src/renderer/src/App.tsx` 或 `src/renderer/src/main.tsx`
### 优先级
高 - 影响用户体验Main process 错误消息语言不一致