Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions apps/frontend/src/renderer/stores/settings-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,18 @@ export const useSettingsStore = create<SettingsState>((set) => ({
}
}));

/**
* Migrate legacy language codes to current BCP 47 tags.
*/
function migrateLanguageCode(settings: AppSettings): AppSettings {
const language = settings.language as string | undefined;
if (language === 'zh') {
return { ...settings, language: 'zh-CN' };
}

return settings;
}

/**
* Check if settings need migration for onboardingCompleted flag.
* Existing users (with tokens or projects configured) should have
Expand Down Expand Up @@ -333,15 +345,20 @@ export async function loadSettings(): Promise<void> {
try {
const result = await window.electronAPI.getSettings();
if (result.success && result.data) {
// Apply migration for onboardingCompleted flag
const migratedSettings = migrateOnboardingCompleted(result.data);
// Apply migrations
const migratedSettings = migrateLanguageCode(migrateOnboardingCompleted(result.data));
store.setSettings(migratedSettings);

// If migration changed the settings, persist them
// If migrations changed the settings, persist them
const updates: Partial<AppSettings> = {};
if (migratedSettings.onboardingCompleted !== result.data.onboardingCompleted) {
await window.electronAPI.saveSettings({
onboardingCompleted: migratedSettings.onboardingCompleted
});
updates.onboardingCompleted = migratedSettings.onboardingCompleted;
}
if (migratedSettings.language !== result.data.language) {
updates.language = migratedSettings.language;
}
if (Object.keys(updates).length > 0) {
await window.electronAPI.saveSettings(updates);
}

// Only mark settings as loaded on SUCCESS
Expand Down
5 changes: 3 additions & 2 deletions apps/frontend/src/shared/constants/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
* Available languages and display labels
*/

export type SupportedLanguage = 'en' | 'fr';
export type SupportedLanguage = 'en' | 'fr' | 'zh-CN';

export const AVAILABLE_LANGUAGES = [
{ value: 'en' as const, label: 'English', nativeLabel: 'English' },
{ value: 'fr' as const, label: 'French', nativeLabel: 'Français' }
{ value: 'fr' as const, label: 'French', nativeLabel: 'Français' },
{ value: 'zh-CN' as const, label: 'Chinese (Simplified)', nativeLabel: '简体中文' }
] as const;

export const DEFAULT_LANGUAGE: SupportedLanguage = 'en';
26 changes: 26 additions & 0 deletions apps/frontend/src/shared/i18n/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@ import frTaskReview from './locales/fr/taskReview.json';
import frTerminal from './locales/fr/terminal.json';
import frErrors from './locales/fr/errors.json';

// Import Chinese (Simplified) translation resources
import zhCnCommon from './locales/zh-CN/common.json';
import zhCnNavigation from './locales/zh-CN/navigation.json';
import zhCnSettings from './locales/zh-CN/settings.json';
import zhCnTasks from './locales/zh-CN/tasks.json';
import zhCnWelcome from './locales/zh-CN/welcome.json';
import zhCnOnboarding from './locales/zh-CN/onboarding.json';
import zhCnDialogs from './locales/zh-CN/dialogs.json';
import zhCnGitlab from './locales/zh-CN/gitlab.json';
import zhCnTaskReview from './locales/zh-CN/taskReview.json';
import zhCnTerminal from './locales/zh-CN/terminal.json';
import zhCnErrors from './locales/zh-CN/errors.json';

export const defaultNS = 'common';

export const resources = {
Expand Down Expand Up @@ -55,6 +68,19 @@ export const resources = {
taskReview: frTaskReview,
terminal: frTerminal,
errors: frErrors
},
'zh-CN': {
common: zhCnCommon,
navigation: zhCnNavigation,
settings: zhCnSettings,
tasks: zhCnTasks,
welcome: zhCnWelcome,
onboarding: zhCnOnboarding,
dialogs: zhCnDialogs,
gitlab: zhCnGitlab,
taskReview: zhCnTaskReview,
terminal: zhCnTerminal,
errors: zhCnErrors
}
} as const;

Expand Down
Loading
Loading