feat: First iteration, multi themes, I18N

This commit is contained in:
gauvainboiche
2026-10-08 11:58:18 +02:00
parent 9240fa3c3c
commit aa9721ac2a
53 changed files with 3363 additions and 1 deletions
+23
View File
@@ -0,0 +1,23 @@
import { readFileSync } from 'node:fs';
import { fileURLToPath } from 'node:url';
import { buildContext } from '../public/js/engine/context.js';
export const PUBLIC_DIR = fileURLToPath(new URL('../public/', import.meta.url));
export const readJson = (relativePath) => JSON.parse(readFileSync(PUBLIC_DIR + relativePath, 'utf8'));
export function loadContext() {
return buildContext({
rules: readJson('data/rules.json'),
generators: readJson('data/generators.json'),
upgrades: readJson('data/upgrades.json'),
});
}
/** Flatten nested locale JSON to dotted keys, like services/i18n.js does. */
export function flatKeys(object, prefix = '') {
return Object.entries(object).flatMap(([key, value]) => {
const path = prefix ? `${prefix}.${key}` : key;
return value && typeof value === 'object' ? flatKeys(value, path) : [path];
});
}