Skip to content
Closed
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
5 changes: 1 addition & 4 deletions src/commands/language.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,9 @@ export async function language(ctx: LanguageContext): Promise<string | null> {
ctx.config.ui = { ...ctx.config.ui, locale: selected };
await saveConfig(ctx.config);

// Show success message in the NEW language
// Show success message in the NEW language (hot-reload works immediately)
const newDisplayName = LANGUAGE_DISPLAY_NAMES[selected];
console.log(chalk.green(`\n✓ ${t('commands.language.changed', { language: newDisplayName })}`));

// Show restart hint for full effect
console.log(chalk.gray(`\n${t('commands.language.restartHint')}`));
console.log();

return null;
Expand Down
28 changes: 21 additions & 7 deletions src/i18n/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,26 @@ import type { SupportedLocale } from './localeDetector.js';

// Import all locale files statically for bundling
import en from './locales/en.json' with { type: 'json' };
import es from './locales/es.json' with { type: 'json' };
import fr from './locales/fr.json' with { type: 'json' };
import ptBr from './locales/pt-br.json' with { type: 'json' };
import zhCn from './locales/zh-cn.json' with { type: 'json' };

// We'll add other locales as they're generated
// For now, use English as fallback for all
// Resources with actual translations where available, English fallback for others
const resources: Record<string, { translation: typeof en }> = {
en: { translation: en },
// These will use en.json as fallback until translations are generated
'zh-cn': { translation: en },
es: { translation: es },
fr: { translation: fr },
'pt-br': { translation: ptBr },
'zh-cn': { translation: zhCn },
// These still use English as fallback until translations are generated
// Run `bun scripts/generate-translations.ts` with OPENROUTER_API_KEY to generate
'zh-tw': { translation: en },
fr: { translation: en },
de: { translation: en },
it: { translation: en },
es: { translation: en },
ja: { translation: en },
ko: { translation: en },
ru: { translation: en },
'pt-br': { translation: en },
tr: { translation: en },
pl: { translation: en },
cs: { translation: en },
Expand All @@ -37,10 +41,17 @@ let initialized = false;

/**
* Initialize i18next with the specified locale
* If already initialized, just changes the language
*/
export async function initI18n(locale: SupportedLocale): Promise<void> {
currentLocale = locale;

// If already initialized, just change the language
if (initialized) {
await i18next.changeLanguage(locale);
return;
}

await i18next.init({
lng: locale,
fallbackLng: 'en',
Expand All @@ -54,6 +65,9 @@ export async function initI18n(locale: SupportedLocale): Promise<void> {
// Return key if translation missing (for debugging)
returnNull: false,
returnEmptyString: false,
// Keep locale codes lowercase (e.g., 'pt-br' not 'pt-BR')
// This ensures resource keys match what we define
lowerCaseLng: true,
});

initialized = true;
Expand Down
Loading
Loading