feat(i18n): Add internationalization support with English and French locales (#1)

feat(i18n): Add internationalization support with English and French locales
This commit is contained in:
Calesthio
2026-03-19 08:00:40 -07:00
committed by GitHub
5 changed files with 944 additions and 54 deletions

View File

@@ -8,6 +8,7 @@ import { dirname, join } from 'path';
import { fileURLToPath } from 'url';
import { exec } from 'child_process';
import config from './crucix.config.mjs';
import { getLocale, currentLanguage, getSupportedLocales } from './lib/i18n.mjs';
import { fullBriefing } from './apis/briefing.mjs';
import { synthesize, generateIdeas } from './dashboard/inject.mjs';
import { MemoryManager } from './lib/delta/index.mjs';
@@ -231,12 +232,20 @@ if (discordAlerter.isConfigured) {
const app = express();
app.use(express.static(join(ROOT, 'dashboard/public')));
// Serve loading page until first sweep completes, then the dashboard
// Serve loading page until first sweep completes, then the dashboard with injected locale
app.get('/', (req, res) => {
if (!currentData) {
res.sendFile(join(ROOT, 'dashboard/public/loading.html'));
} else {
res.sendFile(join(ROOT, 'dashboard/public/jarvis.html'));
const htmlPath = join(ROOT, 'dashboard/public/jarvis.html');
let html = readFileSync(htmlPath, 'utf-8');
// Inject locale data into the HTML
const locale = getLocale();
const localeScript = `<script>window.__CRUCIX_LOCALE__ = ${JSON.stringify(locale).replace(/<\/script>/gi, '<\\/script>')};</script>`;
html = html.replace('</head>', `${localeScript}\n</head>`);
res.type('html').send(html);
}
});
@@ -263,6 +272,15 @@ app.get('/api/health', (req, res) => {
llmProvider: config.llm.provider,
telegramEnabled: !!(config.telegram.botToken && config.telegram.chatId),
refreshIntervalMinutes: config.refreshIntervalMinutes,
language: currentLanguage,
});
});
// API: available locales
app.get('/api/locales', (req, res) => {
res.json({
current: currentLanguage,
supported: getSupportedLocales(),
});
});